diff options
Diffstat (limited to 'src/main/java/ftbsc')
-rw-r--r-- | src/main/java/ftbsc/bscv/commands/BlockSearch.java | 57 | ||||
-rw-r--r-- | src/main/java/ftbsc/bscv/commands/Cursor.java | 10 |
2 files changed, 63 insertions, 4 deletions
diff --git a/src/main/java/ftbsc/bscv/commands/BlockSearch.java b/src/main/java/ftbsc/bscv/commands/BlockSearch.java new file mode 100644 index 0000000..dd5f663 --- /dev/null +++ b/src/main/java/ftbsc/bscv/commands/BlockSearch.java @@ -0,0 +1,57 @@ +package ftbsc.bscv.commands; + +import com.google.auto.service.AutoService; +import com.mojang.brigadier.arguments.IntegerArgumentType; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; + +import ftbsc.bscv.api.ILoadable; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.command.CommandSource; +import net.minecraft.command.Commands; + +import static ftbsc.bscv.Boscovicino.log; + +@AutoService(ILoadable.class) +public class BlockSearch extends AbstractCommand { + + @Override + public String getName() { return "block"; } + + public LiteralArgumentBuilder<CommandSource> register(LiteralArgumentBuilder<CommandSource> builder) { + return builder + .then( + Commands.literal("search") + .then( + Commands.argument("id", IntegerArgumentType.integer(0)) + .executes( ctx -> { + int block_id = ctx.getArgument("id", Integer.class); + int block_number = block_id >> 4; + int block_meta = block_id & 0b1111; + BlockState state = Block.stateById(block_id); + log("block #[%d:%d]::%d >> %s", block_number, block_meta, block_id, state.toString()); + return 1; + }) + ) + .then( + Commands.argument("number", IntegerArgumentType.integer(0)) + .then( + Commands.argument("meta", IntegerArgumentType.integer(0)) + .executes( ctx -> { + int block_number = ctx.getArgument("number", Integer.class); + int block_meta = ctx.getArgument("meta", Integer.class); + int block_id = (block_number << 4) | block_meta; + BlockState state = Block.stateById(block_id); + log("block #[%d:%d]::%d >> %s", block_number, block_meta, block_id, state.toString()); + return 1; + }) + ) + ) + ) + .executes(ctx -> { + log("no block specified"); + return 0; + }); + } + +} diff --git a/src/main/java/ftbsc/bscv/commands/Cursor.java b/src/main/java/ftbsc/bscv/commands/Cursor.java index 49a93aa..a54433d 100644 --- a/src/main/java/ftbsc/bscv/commands/Cursor.java +++ b/src/main/java/ftbsc/bscv/commands/Cursor.java @@ -4,6 +4,7 @@ import com.google.auto.service.AutoService; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import ftbsc.bscv.api.ILoadable; +import net.minecraft.block.BlockState; import net.minecraft.command.CommandSource; import net.minecraft.command.Commands; import net.minecraft.util.Direction; @@ -18,17 +19,18 @@ public class Cursor extends AbstractCommand { public LiteralArgumentBuilder<CommandSource> register(LiteralArgumentBuilder<CommandSource> builder) { return builder .then( - Commands.literal("pos") + Commands.literal("info") .executes(ctx -> { switch (MC.hitResult.getType()) { case BLOCK: BlockRayTraceResult result = (BlockRayTraceResult) MC.hitResult; Direction dir = result.getDirection(); - BlockPos pos =result.getBlockPos(); - log("Block @ %s (%s)", pos.toString(), dir.toString()); + BlockPos pos = result.getBlockPos(); + BlockState state = MC.level.getBlockState(pos); + log("Block @ %s (%s): %s", pos.toString(), dir.toString(), state.toString()); return 1; case ENTITY: - log("Entity @ %s", MC.hitResult.getLocation().toString()); + log("Entity @ %s (TODO!)", MC.hitResult.getLocation().toString()); return 1; default: case MISS: |