From c2874312d37a258ad88d600b7bf08fe7e58e4e49 Mon Sep 17 00:00:00 2001 From: alemi Date: Mon, 13 Nov 2023 04:26:27 +0100 Subject: [PATCH] feat: added item search command also renamed because it clashed with import --- .../commands/{Item.java => ItemCommand.java} | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) rename src/main/java/ftbsc/bscv/commands/{Item.java => ItemCommand.java} (69%) diff --git a/src/main/java/ftbsc/bscv/commands/Item.java b/src/main/java/ftbsc/bscv/commands/ItemCommand.java similarity index 69% rename from src/main/java/ftbsc/bscv/commands/Item.java rename to src/main/java/ftbsc/bscv/commands/ItemCommand.java index 2d4bd7f..e1e1b80 100644 --- a/src/main/java/ftbsc/bscv/commands/Item.java +++ b/src/main/java/ftbsc/bscv/commands/ItemCommand.java @@ -1,6 +1,7 @@ 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; @@ -8,11 +9,15 @@ import ftbsc.bscv.tools.Inventory; import net.minecraft.command.CommandSource; import net.minecraft.command.Commands; import net.minecraft.inventory.container.Slot; +import net.minecraft.item.Item; import static ftbsc.bscv.Boscovicino.log; @AutoService(ILoadable.class) -public class Item extends AbstractCommand { +public class ItemCommand extends AbstractCommand { + + @Override + public String getName() { return "item"; } public LiteralArgumentBuilder register(LiteralArgumentBuilder builder) { return builder @@ -32,6 +37,17 @@ public class Item extends AbstractCommand { return 1; }) ) + .then( + Commands.literal("search") + .then( + Commands.argument("id", IntegerArgumentType.integer(0)) + .executes(ctx -> { + int item_id = ctx.getArgument("id", Integer.class); + log("item #[%d] >> %s", item_id, Item.byId(item_id).toString()); + return 1; + }) + ) + ) .executes(ctx -> { Slot slot = Inventory.hotbar(MC.player).get(MC.player.inventory.selected); if (!slot.hasItem()) return 0;