feat: block and item id search
This commit is contained in:
parent
f1b2842357
commit
5adc5da6cd
2 changed files with 29 additions and 0 deletions
|
@ -9,6 +9,8 @@ import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.command.CommandSource;
|
import net.minecraft.command.CommandSource;
|
||||||
import net.minecraft.command.Commands;
|
import net.minecraft.command.Commands;
|
||||||
|
import net.minecraft.command.arguments.BlockStateArgument;
|
||||||
|
import net.minecraft.command.arguments.BlockStateInput;
|
||||||
|
|
||||||
import static ftbsc.bscv.Boscovicino.log;
|
import static ftbsc.bscv.Boscovicino.log;
|
||||||
|
|
||||||
|
@ -48,6 +50,19 @@ public class BlockSearch extends AbstractCommand {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
.then(
|
||||||
|
Commands.literal("id")
|
||||||
|
.then(
|
||||||
|
Commands.argument("name", BlockStateArgument.block())
|
||||||
|
.executes( ctx -> {
|
||||||
|
BlockStateInput arg = ctx.getArgument("name", BlockStateInput.class);
|
||||||
|
BlockState state = arg.getState();
|
||||||
|
int block_id = Block.getId(state);
|
||||||
|
log("block #[%d:%d] >> %s", block_id >> 4, block_id & 0xF, state.toString());
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
)
|
||||||
.executes(ctx -> {
|
.executes(ctx -> {
|
||||||
log("no block specified");
|
log("no block specified");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -8,6 +8,8 @@ import ftbsc.bscv.api.ILoadable;
|
||||||
import ftbsc.bscv.tools.Inventory;
|
import ftbsc.bscv.tools.Inventory;
|
||||||
import net.minecraft.command.CommandSource;
|
import net.minecraft.command.CommandSource;
|
||||||
import net.minecraft.command.Commands;
|
import net.minecraft.command.Commands;
|
||||||
|
import net.minecraft.command.arguments.ItemArgument;
|
||||||
|
import net.minecraft.command.arguments.ItemInput;
|
||||||
import net.minecraft.inventory.container.Slot;
|
import net.minecraft.inventory.container.Slot;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
|
||||||
|
@ -48,6 +50,18 @@ public class ItemCommand extends AbstractCommand {
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
.then(
|
||||||
|
Commands.literal("id")
|
||||||
|
.then(
|
||||||
|
Commands.argument("name", ItemArgument.item())
|
||||||
|
.executes( ctx -> {
|
||||||
|
ItemInput arg = ctx.getArgument("name", ItemInput.class);
|
||||||
|
Item item = arg.getItem();
|
||||||
|
log("item #[%d] >> %s", Item.getId(item), item.toString());
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
)
|
||||||
.executes(ctx -> {
|
.executes(ctx -> {
|
||||||
Slot slot = Inventory.hotbar(MC.player).get(MC.player.inventory.selected);
|
Slot slot = Inventory.hotbar(MC.player).get(MC.player.inventory.selected);
|
||||||
if (!slot.hasItem()) return 0;
|
if (!slot.hasItem()) return 0;
|
||||||
|
|
Loading…
Reference in a new issue