force cheat tab categories

This commit is contained in:
Sen 2025-06-30 15:00:13 +02:00
parent ac5ac815b0
commit eed510250d
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
2 changed files with 29 additions and 19 deletions

View file

@ -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));

View file

@ -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());