From eed510250dba747639510afc3805140a45a6c655 Mon Sep 17 00:00:00 2001 From: Sen Date: Mon, 30 Jun 2025 15:00:13 +0200 Subject: [PATCH] force cheat tab categories --- .../main/java/common/init/ItemRegistry.java | 6 ++- .../src/main/java/common/item/CheatTab.java | 42 +++++++++++-------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/common/src/main/java/common/init/ItemRegistry.java b/common/src/main/java/common/init/ItemRegistry.java index 307437be..4165b5a0 100755 --- a/common/src/main/java/common/init/ItemRegistry.java +++ b/common/src/main/java/common/init/ItemRegistry.java @@ -101,6 +101,8 @@ public abstract class ItemRegistry { private static void register(String name, Item item) { if(item.getBlock() != null) throw new IllegalArgumentException("Gegenstand " + name + " darf keinen Block besitzen"); + if(item.getTab() == null || item.getTab().isBlockTab()) + throw new IllegalArgumentException("Gegenstand " + name + " muss einen Gegenstand-Tab besitzen"); if(ITEM_MAP.containsKey(name)) throw new IllegalArgumentException("Gegenstand " + name + " ist bereits mit ID " + ITEM_IDS.get(ITEM_MAP.get(name)) + " registriert"); ITEMS.add(item); @@ -161,6 +163,8 @@ public abstract class ItemRegistry { for(Block block : BlockRegistry.blocks()) { Item item = block.registerItem(); if(item != null) { + if(item.getTab() == null || !item.getTab().isBlockTab()) + throw new IllegalArgumentException("Gegenstand für " + BlockRegistry.getName(block) + " muss einen Block-Tab besitzen"); ITEMS.add(item); ITEM_MAP.put(BlockRegistry.getName(block), item); ITEM_IDS.put(item, ITEMS.size()); @@ -307,7 +311,7 @@ public abstract class ItemRegistry { register("carrot_on_a_stick", (new ItemCarrotOnAStick()).setDisplay("Karottenrute")); register("charge_crystal", (new ItemEffect()).setDisplay("Energiekristall").setTab(CheatTab.MISC).setColor(TextColor.DMAGENTA)); register("pumpkin_pie", (new ItemFood(8, false)).setDisplay("Kürbiskuchen").setTab(CheatTab.MISC)); - register("fireworks", (new ItemFirework()).setDisplay("Feuerwerksrakete")); + register("fireworks", (new ItemFirework()).setDisplay("Feuerwerksrakete").setTab(CheatTab.TOOLS)); register("firework_charge", (new ItemFireworkCharge()).setDisplay("Feuerwerksstern").setTab(CheatTab.MATERIALS)); register("enchanted_book", (new ItemEnchantedBook()).setMaxAmount(1).setDisplay("Verzaubertes Buch").setTab(CheatTab.MAGIC)); register("bloodbrick", (new Item()).setDisplay("Blutroter Ziegel").setTab(CheatTab.MATERIALS)); diff --git a/common/src/main/java/common/item/CheatTab.java b/common/src/main/java/common/item/CheatTab.java index d824e096..10c438cc 100755 --- a/common/src/main/java/common/item/CheatTab.java +++ b/common/src/main/java/common/item/CheatTab.java @@ -6,98 +6,100 @@ import common.init.ItemRegistry; import common.init.Items; public enum CheatTab { - BLOCKS("Baumaterial") { + BLOCKS("Baumaterial", true) { protected Item getIconItem() { return Items.glass; } }, - NATURE("Gestein und Natur") { + NATURE("Gestein und Natur", true) { protected Item getIconItem() { return Items.grass; } }, - WOOD("Holz") { + WOOD("Holz", true) { protected Item getIconItem() { return Items.maple_planks; } }, - PLANTS("Pflanzen") { + PLANTS("Pflanzen", true) { protected Item getIconItem() { return Items.oak_leaves_spring; } }, - DECORATION("Dekoration") { + DECORATION("Dekoration", true) { protected Item getIconItem() { return Items.hay_block; } }, - TECHNOLOGY("Redstone & Technik") { + TECHNOLOGY("Redstone & Technik", true) { protected Item getIconItem() { return Items.tnt; } }, - GEMS("Erze & Teure Blöcke") { + GEMS("Erze & Teure Blöcke", true) { protected Item getIconItem() { return Items.diamond_block; } }, - VEHICLES("Fahrzeuge und Fortbewegung") { + VEHICLES("Fahrzeuge und Fortbewegung", false) { protected Item getIconItem() { return Items.minecart; } }, - SPAWNERS("Mob & Itemspawner") { + SPAWNERS("Mob & Itemspawner", false) { protected Item getIconItem() { return Items.wheat; } }, - NPCS("NPC- und Charakterspawner") { + NPCS("NPC- und Charakterspawner", false) { protected Item getIconItem() { return Items.book; } }, - TOOLS("Werkzeug") { + TOOLS("Werkzeug", false) { protected Item getIconItem() { return Items.flint_and_steel; } }, - LIQUIDS("Flüssigkeiten") { + LIQUIDS("Flüssigkeiten", false) { protected Item getIconItem() { return Items.water_bucket; } }, - COMBAT("Kampf") { + COMBAT("Kampf", false) { protected Item getIconItem() { return Items.bow; } }, - MAGIC("Tränke & Verzauberungen") { + MAGIC("Tränke & Verzauberungen", false) { protected Item getIconItem() { return Items.potion; } }, - MATERIALS("Werkstoffe") { + MATERIALS("Werkstoffe", false) { protected Item getIconItem() { return Items.leather; } }, - METALS("Metalle und Juwelen") { + METALS("Metalle und Juwelen", false) { protected Item getIconItem() { return Items.iron_ingot; } }, - MISC("Verschiedenes & Nahrung") { + MISC("Verschiedenes & Nahrung", false) { protected Item getIconItem() { return Items.charge_crystal; } }; private final String name; + private final boolean blocks; private ItemStack icon; - private CheatTab(String name) { + private CheatTab(String name, boolean blocks) { this.name = name; + this.blocks = blocks; } public int getIndex() { @@ -108,6 +110,10 @@ public enum CheatTab { return this.name; } + public boolean isBlockTab() { + return this.blocks; + } + public ItemStack getIcon() { if(this.icon == null) this.icon = new ItemStack(this.getIconItem());