added direction dtection
and command running based on that
This commit is contained in:
1 parent
5aea313479
commit
40dcd31bb0
1 file changed
+44
-18
@@ -8,6 +8,8 @@ import com.mojang.brigadier.CommandDispatcher;
|
|||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
import com.mojang.brigadier.arguments.BoolArgumentType;
|
import com.mojang.brigadier.arguments.BoolArgumentType;
|
||||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||||
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.pattern.CachedBlockPosition;
|
import net.minecraft.block.pattern.CachedBlockPosition;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
@@ -73,23 +75,27 @@ public class DrawCommand {
|
|||||||
.then(argument("radius", IntegerArgumentType.integer(1))
|
.then(argument("radius", IntegerArgumentType.integer(1))
|
||||||
.then(argument("height",IntegerArgumentType.integer(1))
|
.then(argument("height",IntegerArgumentType.integer(1))
|
||||||
.then(argument("pointing up?",BoolArgumentType.bool())
|
.then(argument("pointing up?",BoolArgumentType.bool())
|
||||||
.then(argument("block", BlockStateArgumentType.blockState())
|
.then(argument("which direction?", StringArgumentType.string())
|
||||||
.executes((c) -> drawConey(c.getSource(),
|
.then(argument("block", BlockStateArgumentType.blockState())
|
||||||
BlockPosArgumentType.getBlockPos(c, "center"),
|
.executes((c) -> selectCone(c.getSource(),
|
||||||
IntegerArgumentType.getInteger(c, "radius"),
|
BlockPosArgumentType.getBlockPos(c, "center"),
|
||||||
IntegerArgumentType.getInteger(c, "height"),
|
IntegerArgumentType.getInteger(c, "radius"),
|
||||||
BoolArgumentType.getBool(c, "pointing up?"),
|
IntegerArgumentType.getInteger(c, "height"),
|
||||||
BlockStateArgumentType.getBlockState(c, "block"), null)
|
BoolArgumentType.getBool(c,"pointing up?"),
|
||||||
)
|
StringArgumentType.getString(c,"which direction?"),
|
||||||
.then(literal("replace")
|
BlockStateArgumentType.getBlockState(c, "block"), null)
|
||||||
.then(argument("filter", BlockPredicateArgumentType.blockPredicate())
|
)
|
||||||
.executes((c) -> drawConey(c.getSource(),
|
.then(literal("replace")
|
||||||
BlockPosArgumentType.getBlockPos(c, "center"),
|
.then(argument("filter", BlockPredicateArgumentType.blockPredicate())
|
||||||
IntegerArgumentType.getInteger(c, "radius"),
|
.executes((c) -> selectCone(c.getSource(),
|
||||||
IntegerArgumentType.getInteger(c, "height"),
|
BlockPosArgumentType.getBlockPos(c, "center"),
|
||||||
BoolArgumentType.getBool(c, "pointing up?"),
|
IntegerArgumentType.getInteger(c, "radius"),
|
||||||
BlockStateArgumentType.getBlockState(c, "block"),
|
IntegerArgumentType.getInteger(c, "height"),
|
||||||
BlockPredicateArgumentType.getBlockPredicate(c,"filter")
|
BoolArgumentType.getBool(c,"pointing up?"),
|
||||||
|
StringArgumentType.getString(c,"which direction?"),
|
||||||
|
BlockStateArgumentType.getBlockState(c, "block"),
|
||||||
|
BlockPredicateArgumentType.getBlockPredicate(c,"filter")
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -264,12 +270,32 @@ public class DrawCommand {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int selectCone(ServerCommandSource source, BlockPos pos, int radius, int height, boolean pointup, String direction, BlockStateArgument block,
|
||||||
|
Predicate<CachedBlockPosition> replacement){
|
||||||
|
if(direction=="x"){
|
||||||
|
drawConex(source, pos, radius, height, pointup, block, replacement);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(direction=="y"){
|
||||||
|
drawConey(source, pos, radius, height, pointup, block, replacement);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(direction=="z"){
|
||||||
|
drawConez(source, pos, radius, height, pointup, block, replacement);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(direction!="x" && direction!="y" && direction!="z"){
|
||||||
|
Messenger.m(source,"Invalid direction, must be \"x\",\"y\" or \"z\"");
|
||||||
|
}
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
private static int drawConey(ServerCommandSource source, BlockPos pos, int radius, int height, boolean pointup, BlockStateArgument block,
|
private static int drawConey(ServerCommandSource source, BlockPos pos, int radius, int height, boolean pointup, BlockStateArgument block,
|
||||||
Predicate<CachedBlockPosition> replacement) {
|
Predicate<CachedBlockPosition> replacement) {
|
||||||
return (int) drawConey(source, pos, radius, height, block, replacement, pointup, false);
|
return (int) drawConey(source, pos, radius, height, block, replacement, pointup, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int drawConey(ServerCommandSource source, BlockPos pos, int radius, int height,BlockStateArgument block,
|
private static double drawConey(ServerCommandSource source, BlockPos pos, int radius, int height,BlockStateArgument block,
|
||||||
Predicate<CachedBlockPosition> replacement, boolean pointup, boolean solid) {
|
Predicate<CachedBlockPosition> replacement, boolean pointup, boolean solid) {
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|||||||
Reference in new issue
Block a user