moved everything to switch statement
It all works now
This commit is contained in:
1 parent
33f6b90839
commit
a1b6ef204a
1 file changed
+19
-61
@@ -289,44 +289,22 @@ public class DrawCommand
|
||||
private static int drawCircle(ServerCommandSource source, BlockPos pos, int offset, int radius,BlockStateArgument block, String orientation,
|
||||
Predicate<CachedBlockPosition> replacement, List<BlockPos> list, BlockPos.Mutable mbpos){
|
||||
int successes=0;
|
||||
if(orientation=="x"){
|
||||
for(int y=-radius;y<=radius;++y){
|
||||
for(int axis1=-radius;axis1<=radius;++axis1){
|
||||
|
||||
for(int z=-radius;z<=radius;++z){
|
||||
for(int axis2=-radius;axis2<=radius;++axis2){
|
||||
|
||||
if(y*y+z*z<=radius*radius){
|
||||
successes+=blockset(source, pos.getX()+offset, pos.getY()+y, pos.getZ()+z, replacement, list, mbpos, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(orientation=="y"){
|
||||
for(int x=-radius;x<=radius;++x){
|
||||
|
||||
for(int z=-radius;z<=radius;++z){
|
||||
|
||||
if(x*x+z*z<=radius*radius){
|
||||
successes+=blockset(source, pos.getX()+x, pos.getY()+offset, pos.getZ()+z, replacement, list, mbpos, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(orientation=="z"){
|
||||
for(int y=-radius;y<=radius;++y){
|
||||
|
||||
for(int x=-radius;x<=radius;++x){
|
||||
|
||||
if(y*y+x*x<=radius*radius){
|
||||
successes+=blockset(source, pos.getX()+x, pos.getY()+y, pos.getZ()+offset, replacement, list, mbpos, block);
|
||||
if(axis1*axis1+axis2*axis2<=radius*radius){
|
||||
switch (orientation){
|
||||
case "x":successes+=blockset(source, pos.getX()+offset, pos.getY()+axis1, pos.getZ()+axis2,replacement, list, mbpos, block);break;
|
||||
case "y":successes+=blockset(source, pos.getX()+axis1, pos.getY()+offset, pos.getZ()+axis2,replacement, list, mbpos, block);break;
|
||||
case "z":successes+=blockset(source, pos.getX()+axis2, pos.getY()+axis1, pos.getZ()+offset,replacement, list, mbpos, block);break;
|
||||
default:Messenger.m(source,"gi Invalid orientation, must be x, y or z");return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return successes;
|
||||
}
|
||||
|
||||
private static int drawSquare(ServerCommandSource source, BlockPos pos, int offset, int radius, BlockStateArgument block, String orientation,
|
||||
Predicate<CachedBlockPosition> replacement, List<BlockPos> list, BlockPos.Mutable mbpos){
|
||||
int success=0;
|
||||
@@ -334,14 +312,11 @@ public class DrawCommand
|
||||
for(int axis1=-radius;axis1<=radius;++axis1){
|
||||
|
||||
for(int axis2=-radius;axis2<=radius;++axis2){
|
||||
if(orientation=="x"){
|
||||
success+=blockset(source, pos.getX()+offset, pos.getY()+axis1, pos.getZ()+axis2,replacement, list, mbpos, block);
|
||||
}
|
||||
if(orientation=="y"){
|
||||
success+=blockset(source, pos.getX()+axis1, pos.getY()+offset, pos.getZ()+axis2,replacement, list, mbpos, block);
|
||||
}
|
||||
if(orientation=="z"){
|
||||
success+=blockset(source, pos.getX()+axis2, pos.getY()+axis1, pos.getZ()+offset,replacement, list, mbpos, block);
|
||||
switch (orientation){
|
||||
case "x":success+=blockset(source, pos.getX()+offset, pos.getY()+axis1, pos.getZ()+axis2,replacement, list, mbpos, block);break;
|
||||
case "y":success+=blockset(source, pos.getX()+axis1, pos.getY()+offset, pos.getZ()+axis2,replacement, list, mbpos, block);break;
|
||||
case "z":success+=blockset(source, pos.getX()+axis2, pos.getY()+axis1, pos.getZ()+offset,replacement, list, mbpos, block);break;
|
||||
default:Messenger.m(source,"gi Invalid orientation, must be x, y or z");return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -367,17 +342,6 @@ public class DrawCommand
|
||||
|
||||
int r = radius;
|
||||
|
||||
switch (orientation){
|
||||
case "x":break;
|
||||
case "y":break;
|
||||
case "z":break;
|
||||
default:{
|
||||
Messenger.m(source,"gi Invalid orientation, must be x,y or z");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(int i =0; i<height;++i) {
|
||||
if(pointup){
|
||||
r=radius-radius*i/height-1;
|
||||
@@ -385,18 +349,12 @@ public class DrawCommand
|
||||
r=radius*i/height;
|
||||
}
|
||||
switch(shape){
|
||||
case "circle":{
|
||||
affected+=drawCircle(source, pos, i, (int) Math.round(r), block, orientation, replacement, list, mbpos);
|
||||
Messenger.m(source,"gi Test circle "+shape+" I hope this works");
|
||||
}
|
||||
case "square":{
|
||||
affected+=drawSquare(source, pos, i, (int) Math.round(r), block, orientation, replacement, list, mbpos);
|
||||
Messenger.m(source,"gi Test circle "+shape+" I hope this works");
|
||||
}
|
||||
/*default:{
|
||||
Messenger.m(source,"gi !"+shape+"| is an incorrect shape, read options for which shapes are available");
|
||||
return 0;
|
||||
}*/
|
||||
case "circle":affected+=drawCircle(source, pos, i, (int) Math.round(r), block, orientation, replacement, list, mbpos);break;
|
||||
|
||||
case "square":affected+=drawSquare(source, pos, i, (int) Math.round(r), block, orientation, replacement, list, mbpos);break;
|
||||
|
||||
default:Messenger.m(source,"gi "+shape+" is an incorrect shape, read options for which shapes are available");return 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user