diff --git a/src/main/java/carpet/commands/DrawCommand.java b/src/main/java/carpet/commands/DrawCommand.java index 4b21d68d..e2ca0bb3 100644 --- a/src/main/java/carpet/commands/DrawCommand.java +++ b/src/main/java/carpet/commands/DrawCommand.java @@ -289,44 +289,22 @@ public class DrawCommand private static int drawCircle(ServerCommandSource source, BlockPos pos, int offset, int radius,BlockStateArgument block, String orientation, Predicate replacement, List 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 replacement, List 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; } } } @@ -366,17 +341,6 @@ public class DrawCommand CarpetSettings.impendingFillSkipUpdates = !CarpetSettings.fillUpdates; 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