From c2874312d37a258ad88d600b7bf08fe7e58e4e49 Mon Sep 17 00:00:00 2001 From: alemi Date: Mon, 13 Nov 2023 04:26:27 +0100 Subject: feat: added item search command also renamed because it clashed with import --- src/main/java/ftbsc/bscv/commands/Item.java | 43 ---------------- src/main/java/ftbsc/bscv/commands/ItemCommand.java | 59 ++++++++++++++++++++++ 2 files changed, 59 insertions(+), 43 deletions(-) delete mode 100644 src/main/java/ftbsc/bscv/commands/Item.java create mode 100644 src/main/java/ftbsc/bscv/commands/ItemCommand.java diff --git a/src/main/java/ftbsc/bscv/commands/Item.java b/src/main/java/ftbsc/bscv/commands/Item.java deleted file mode 100644 index 2d4bd7f..0000000 --- a/src/main/java/ftbsc/bscv/commands/Item.java +++ /dev/null @@ -1,43 +0,0 @@ -package ftbsc.bscv.commands; - -import com.google.auto.service.AutoService; -import com.mojang.brigadier.builder.LiteralArgumentBuilder; - -import ftbsc.bscv.api.ILoadable; -import ftbsc.bscv.tools.Inventory; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraft.inventory.container.Slot; - -import static ftbsc.bscv.Boscovicino.log; - -@AutoService(ILoadable.class) -public class Item extends AbstractCommand { - - public LiteralArgumentBuilder register(LiteralArgumentBuilder builder) { - return builder - .then( - Commands.literal("damage") - .executes(ctx -> { - Slot slot = Inventory.hotbar(MC.player).get(MC.player.inventory.selected); - if (!slot.hasItem()) return 0; - log( - String.format( - "A %.1f | S %.1f | DPS %.2f", - Inventory.itemAttackDamage(slot.getItem()), - Inventory.itemAttackSpeed(slot.getItem()), - Inventory.itemDPS(slot.getItem()) - ) - ); - return 1; - }) - ) - .executes(ctx -> { - Slot slot = Inventory.hotbar(MC.player).get(MC.player.inventory.selected); - if (!slot.hasItem()) return 0; - log(slot.getItem().toString()); - return 1; - }); - } - -} diff --git a/src/main/java/ftbsc/bscv/commands/ItemCommand.java b/src/main/java/ftbsc/bscv/commands/ItemCommand.java new file mode 100644 index 0000000..e1e1b80 --- /dev/null +++ b/src/main/java/ftbsc/bscv/commands/ItemCommand.java @@ -0,0 +1,59 @@ +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 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 ItemCommand extends AbstractCommand { + + @Override + public String getName() { return "item"; } + + public LiteralArgumentBuilder register(LiteralArgumentBuilder builder) { + return builder + .then( + Commands.literal("damage") + .executes(ctx -> { + Slot slot = Inventory.hotbar(MC.player).get(MC.player.inventory.selected); + if (!slot.hasItem()) return 0; + log( + String.format( + "A %.1f | S %.1f | DPS %.2f", + Inventory.itemAttackDamage(slot.getItem()), + Inventory.itemAttackSpeed(slot.getItem()), + Inventory.itemDPS(slot.getItem()) + ) + ); + 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; + log(slot.getItem().toString()); + return 1; + }); + } + +} -- cgit v1.2.3-56-ga3b1