Added square based pyramid
also edited command tree to make it more understandable. Cones are, after all, simply circular-based pyramids. I may or may not add octagons in the future.
This commit is contained in:
1 parent
2f78068875
commit
fcf2a6775c
1 file changed
+120
-5
@@ -71,7 +71,7 @@ public class DrawCommand {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
.then(literal("pyramid")
|
.then(literal("pyramid")
|
||||||
.then(literal("cone")
|
.then(literal("circular")
|
||||||
.then(argument("center", BlockPosArgumentType.blockPos())
|
.then(argument("center", BlockPosArgumentType.blockPos())
|
||||||
.then(argument("radius", IntegerArgumentType.integer(1))
|
.then(argument("radius", IntegerArgumentType.integer(1))
|
||||||
.then(argument("height",IntegerArgumentType.integer(1))
|
.then(argument("height",IntegerArgumentType.integer(1))
|
||||||
@@ -159,6 +159,94 @@ public class DrawCommand {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
.then(literal("square")
|
||||||
|
.then(argument("center", BlockPosArgumentType.blockPos())
|
||||||
|
.then(argument("radius", IntegerArgumentType.integer(1))
|
||||||
|
.then(argument("height",IntegerArgumentType.integer(1))
|
||||||
|
.then(argument("pointing up?",BoolArgumentType.bool())
|
||||||
|
.then(literal("x")
|
||||||
|
.then(argument("block", BlockStateArgumentType.blockState())
|
||||||
|
.executes((c) -> drawPyramid(c.getSource(),
|
||||||
|
BlockPosArgumentType.getBlockPos(c, "center"),
|
||||||
|
"square",
|
||||||
|
IntegerArgumentType.getInteger(c, "radius"),
|
||||||
|
IntegerArgumentType.getInteger(c, "height"),
|
||||||
|
BoolArgumentType.getBool(c,"pointing up?"),"x",
|
||||||
|
BlockStateArgumentType.getBlockState(c, "block"), null)
|
||||||
|
)
|
||||||
|
.then(literal("replace")
|
||||||
|
.then(argument("filter", BlockPredicateArgumentType.blockPredicate())
|
||||||
|
.executes((c) -> drawPyramid(c.getSource(),
|
||||||
|
BlockPosArgumentType.getBlockPos(c, "center"),
|
||||||
|
"square",
|
||||||
|
IntegerArgumentType.getInteger(c, "radius"),
|
||||||
|
IntegerArgumentType.getInteger(c, "height"),
|
||||||
|
BoolArgumentType.getBool(c,"pointing up?"),"x",
|
||||||
|
BlockStateArgumentType.getBlockState(c, "block"),
|
||||||
|
BlockPredicateArgumentType.getBlockPredicate(c,"filter")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.then(literal("y")
|
||||||
|
.then(argument("block", BlockStateArgumentType.blockState())
|
||||||
|
.executes((c) -> drawPyramid(c.getSource(),
|
||||||
|
BlockPosArgumentType.getBlockPos(c, "center"),
|
||||||
|
"square",
|
||||||
|
IntegerArgumentType.getInteger(c, "radius"),
|
||||||
|
IntegerArgumentType.getInteger(c, "height"),
|
||||||
|
BoolArgumentType.getBool(c,"pointing up?"),"y",
|
||||||
|
BlockStateArgumentType.getBlockState(c, "block"), null)
|
||||||
|
)
|
||||||
|
.then(literal("replace")
|
||||||
|
.then(argument("filter", BlockPredicateArgumentType.blockPredicate())
|
||||||
|
.executes((c) -> drawPyramid(c.getSource(),
|
||||||
|
BlockPosArgumentType.getBlockPos(c, "center"),
|
||||||
|
"square",
|
||||||
|
IntegerArgumentType.getInteger(c, "radius"),
|
||||||
|
IntegerArgumentType.getInteger(c, "height"),
|
||||||
|
BoolArgumentType.getBool(c,"pointing up?"),"y",
|
||||||
|
BlockStateArgumentType.getBlockState(c, "block"),
|
||||||
|
BlockPredicateArgumentType.getBlockPredicate(c,"filter")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.then(literal("z")
|
||||||
|
.then(argument("block", BlockStateArgumentType.blockState())
|
||||||
|
.executes((c) -> drawPyramid(c.getSource(),
|
||||||
|
BlockPosArgumentType.getBlockPos(c, "center"),
|
||||||
|
"square",
|
||||||
|
IntegerArgumentType.getInteger(c, "radius"),
|
||||||
|
IntegerArgumentType.getInteger(c, "height"),
|
||||||
|
BoolArgumentType.getBool(c,"pointing up?"),"z",
|
||||||
|
BlockStateArgumentType.getBlockState(c, "block"), null)
|
||||||
|
)
|
||||||
|
.then(literal("replace")
|
||||||
|
.then(argument("filter", BlockPredicateArgumentType.blockPredicate())
|
||||||
|
.executes((c) -> drawPyramid(c.getSource(),
|
||||||
|
BlockPosArgumentType.getBlockPos(c, "center"),
|
||||||
|
"square",
|
||||||
|
IntegerArgumentType.getInteger(c, "radius"),
|
||||||
|
IntegerArgumentType.getInteger(c, "height"),
|
||||||
|
BoolArgumentType.getBool(c,"pointing up?"),"z",
|
||||||
|
BlockStateArgumentType.getBlockState(c, "block"),
|
||||||
|
BlockPredicateArgumentType.getBlockPredicate(c,"filter")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
);
|
);
|
||||||
dispatcher.register(command);
|
dispatcher.register(command);
|
||||||
@@ -330,7 +418,7 @@ public class DrawCommand {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int drawCircle(ServerCommandSource source, BlockPos pos, int offset, int radius, int height, boolean pointup, BlockStateArgument block, String orientation,
|
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){
|
Predicate<CachedBlockPosition> replacement, List<BlockPos> list, BlockPos.Mutable mbpos){
|
||||||
int successes=0;
|
int successes=0;
|
||||||
if(orientation=="x"){
|
if(orientation=="x"){
|
||||||
@@ -371,13 +459,35 @@ public class DrawCommand {
|
|||||||
|
|
||||||
return successes;
|
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;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
private static int drawPyramid(ServerCommandSource source, BlockPos pos, String shape, int radius, int height, boolean pointup, String orientation, BlockStateArgument block,
|
private static int drawPyramid(ServerCommandSource source, BlockPos pos, String shape, int radius, int height, boolean pointup, String orientation, BlockStateArgument block,
|
||||||
Predicate<CachedBlockPosition> replacement) {
|
Predicate<CachedBlockPosition> replacement) {
|
||||||
return (int) drawPyramid(source, pos, radius, height, block, replacement, pointup, orientation, false, shape);
|
return (int) drawPyramid(source, pos, radius, height, block, replacement, pointup, orientation, false, shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double drawPyramid(ServerCommandSource source, BlockPos pos, int radius, int height,BlockStateArgument block,
|
private static double drawPyramid(ServerCommandSource source, BlockPos pos, int radius, int height, BlockStateArgument block,
|
||||||
Predicate<CachedBlockPosition> replacement, boolean pointup, String orientation, boolean solid, String shape) {
|
Predicate<CachedBlockPosition> replacement, boolean pointup, String orientation, boolean solid, String shape) {
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
BlockPos.Mutable mbpos = new BlockPos.Mutable(pos);
|
BlockPos.Mutable mbpos = new BlockPos.Mutable(pos);
|
||||||
@@ -397,8 +507,13 @@ public class DrawCommand {
|
|||||||
if(pointup==false){
|
if(pointup==false){
|
||||||
r=radius*i/height;
|
r=radius*i/height;
|
||||||
}
|
}
|
||||||
affected+=drawCircle(source, pos, i, (int) Math.round(r), height, pointup, block, orientation, replacement, list, mbpos);
|
if(shape=="circle"){
|
||||||
//circle(cx+_,cy,cz,'x',ceil(r),block) in scarpet implementation, _ is i here, and is added in offset parameter
|
affected+=drawCircle(source, pos, i, (int) Math.round(r), block, orientation, replacement, list, mbpos);
|
||||||
|
//circle(cx+_,cy,cz,'x',ceil(r),block) in scarpet implementation, _ is i here, and is added in offset parameter
|
||||||
|
}
|
||||||
|
if(shape=="square"){
|
||||||
|
affected+=drawSquare(source, pos, i, (int) Math.round(r), block, orientation, replacement, list, mbpos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CarpetSettings.impendingFillSkipUpdates = false;
|
CarpetSettings.impendingFillSkipUpdates = false;
|
||||||
|
|||||||
Reference in new issue
Block a user