From 0caef12b9fc4b4a8ea36cbfce7cdd07de16a6d44 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Wed, 7 Feb 2024 19:01:42 -0500 Subject: [PATCH] Make creative tabs more like the forge version --- .../simibubi/create/AllCreativeModeTabs.java | 35 ++++--------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/simibubi/create/AllCreativeModeTabs.java b/src/main/java/com/simibubi/create/AllCreativeModeTabs.java index 995cfb54f4..d9ea7e59bc 100644 --- a/src/main/java/com/simibubi/create/AllCreativeModeTabs.java +++ b/src/main/java/com/simibubi/create/AllCreativeModeTabs.java @@ -59,14 +59,14 @@ public class AllCreativeModeTabs { () -> FabricItemGroup.builder() .title(Components.translatable("itemGroup.create.base")) .icon(() -> AllBlocks.COGWHEEL.asStack()) - .displayItems(new RegistrateDisplayItemsGenerator(true, Tabs.BASE)) + .displayItems(new RegistrateDisplayItemsGenerator(true, () -> AllCreativeModeTabs.BASE_CREATIVE_TAB)) .build()); public static final TabInfo PALETTES_CREATIVE_TAB = register("palettes", () -> FabricItemGroup.builder() .title(Components.translatable("itemGroup.create.palettes")) .icon(() -> AllPaletteBlocks.ORNATE_IRON_WINDOW.asStack()) - .displayItems(new RegistrateDisplayItemsGenerator(false, Tabs.PALETTES)) + .displayItems(new RegistrateDisplayItemsGenerator(false, () -> AllCreativeModeTabs.PALETTES_CREATIVE_TAB)) .build()); private static TabInfo register(String name, Supplier supplier) { @@ -81,29 +81,6 @@ public static void register() { // fabric: just load the class } - public static ResourceKey getBaseTabKey() { - return BASE_CREATIVE_TAB.key(); - } - - public static ResourceKey getPalettesTabKey() { - return PALETTES_CREATIVE_TAB.key(); - } - - public enum Tabs { - BASE(AllCreativeModeTabs::getBaseTabKey), - PALETTES(AllCreativeModeTabs::getPalettesTabKey); - - private final Supplier> keySupplier; - - Tabs(Supplier> keySupplier) { - this.keySupplier = keySupplier; - } - - public ResourceKey getKey() { - return keySupplier.get(); - } - } - private static class RegistrateDisplayItemsGenerator implements DisplayItemsGenerator { private static final Predicate IS_ITEM_3D_PREDICATE; @@ -131,9 +108,9 @@ private static Predicate makeClient3dItemPredicate() { } private final boolean addItems; - private final Tabs tabFilter; + private final Supplier tabFilter; - public RegistrateDisplayItemsGenerator(boolean addItems, Tabs tabFilter) { + public RegistrateDisplayItemsGenerator(boolean addItems, Supplier tabFilter) { this.addItems = addItems; this.tabFilter = tabFilter; } @@ -307,7 +284,7 @@ public void accept(ItemDisplayParameters parameters, Output output) { private List collectBlocks(Predicate exclusionPredicate) { List items = new ReferenceArrayList<>(); for (RegistryEntry entry : Create.REGISTRATE.getAll(Registries.BLOCK)) { - if (!CreateRegistrate.isInCreativeTab(entry, tabFilter.getKey())) + if (!CreateRegistrate.isInCreativeTab(entry, tabFilter.get().key())) continue; Item item = entry.get() .asItem(); @@ -323,7 +300,7 @@ private List collectBlocks(Predicate exclusionPredicate) { private List collectItems(Predicate exclusionPredicate) { List items = new ReferenceArrayList<>(); for (RegistryEntry entry : Create.REGISTRATE.getAll(Registries.ITEM)) { - if (!CreateRegistrate.isInCreativeTab(entry, tabFilter.getKey())) + if (!CreateRegistrate.isInCreativeTab(entry, tabFilter.get().key())) continue; Item item = entry.get(); if (item instanceof BlockItem)