Skip to content

Commit aee3d7b

Browse files
authored
Make creative tabs more like the forge version (#1302)
1 parent d9c630d commit aee3d7b

File tree

1 file changed

+6
-29
lines changed

1 file changed

+6
-29
lines changed

src/main/java/com/simibubi/create/AllCreativeModeTabs.java

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ public class AllCreativeModeTabs {
5959
() -> FabricItemGroup.builder()
6060
.title(Components.translatable("itemGroup.create.base"))
6161
.icon(() -> AllBlocks.COGWHEEL.asStack())
62-
.displayItems(new RegistrateDisplayItemsGenerator(true, Tabs.BASE))
62+
.displayItems(new RegistrateDisplayItemsGenerator(true, () -> AllCreativeModeTabs.BASE_CREATIVE_TAB))
6363
.build());
6464

6565
public static final TabInfo PALETTES_CREATIVE_TAB = register("palettes",
6666
() -> FabricItemGroup.builder()
6767
.title(Components.translatable("itemGroup.create.palettes"))
6868
.icon(() -> AllPaletteBlocks.ORNATE_IRON_WINDOW.asStack())
69-
.displayItems(new RegistrateDisplayItemsGenerator(false, Tabs.PALETTES))
69+
.displayItems(new RegistrateDisplayItemsGenerator(false, () -> AllCreativeModeTabs.PALETTES_CREATIVE_TAB))
7070
.build());
7171

7272
private static TabInfo register(String name, Supplier<CreativeModeTab> supplier) {
@@ -81,29 +81,6 @@ public static void register() {
8181
// fabric: just load the class
8282
}
8383

84-
public static ResourceKey<CreativeModeTab> getBaseTabKey() {
85-
return BASE_CREATIVE_TAB.key();
86-
}
87-
88-
public static ResourceKey<CreativeModeTab> getPalettesTabKey() {
89-
return PALETTES_CREATIVE_TAB.key();
90-
}
91-
92-
public enum Tabs {
93-
BASE(AllCreativeModeTabs::getBaseTabKey),
94-
PALETTES(AllCreativeModeTabs::getPalettesTabKey);
95-
96-
private final Supplier<ResourceKey<CreativeModeTab>> keySupplier;
97-
98-
Tabs(Supplier<ResourceKey<CreativeModeTab>> keySupplier) {
99-
this.keySupplier = keySupplier;
100-
}
101-
102-
public ResourceKey<CreativeModeTab> getKey() {
103-
return keySupplier.get();
104-
}
105-
}
106-
10784
private static class RegistrateDisplayItemsGenerator implements DisplayItemsGenerator {
10885
private static final Predicate<Item> IS_ITEM_3D_PREDICATE;
10986

@@ -131,9 +108,9 @@ private static Predicate<Item> makeClient3dItemPredicate() {
131108
}
132109

133110
private final boolean addItems;
134-
private final Tabs tabFilter;
111+
private final Supplier<TabInfo> tabFilter;
135112

136-
public RegistrateDisplayItemsGenerator(boolean addItems, Tabs tabFilter) {
113+
public RegistrateDisplayItemsGenerator(boolean addItems, Supplier<TabInfo> tabFilter) {
137114
this.addItems = addItems;
138115
this.tabFilter = tabFilter;
139116
}
@@ -307,7 +284,7 @@ public void accept(ItemDisplayParameters parameters, Output output) {
307284
private List<Item> collectBlocks(Predicate<Item> exclusionPredicate) {
308285
List<Item> items = new ReferenceArrayList<>();
309286
for (RegistryEntry<Block> entry : Create.REGISTRATE.getAll(Registries.BLOCK)) {
310-
if (!CreateRegistrate.isInCreativeTab(entry, tabFilter.getKey()))
287+
if (!CreateRegistrate.isInCreativeTab(entry, tabFilter.get().key()))
311288
continue;
312289
Item item = entry.get()
313290
.asItem();
@@ -323,7 +300,7 @@ private List<Item> collectBlocks(Predicate<Item> exclusionPredicate) {
323300
private List<Item> collectItems(Predicate<Item> exclusionPredicate) {
324301
List<Item> items = new ReferenceArrayList<>();
325302
for (RegistryEntry<Item> entry : Create.REGISTRATE.getAll(Registries.ITEM)) {
326-
if (!CreateRegistrate.isInCreativeTab(entry, tabFilter.getKey()))
303+
if (!CreateRegistrate.isInCreativeTab(entry, tabFilter.get().key()))
327304
continue;
328305
Item item = entry.get();
329306
if (item instanceof BlockItem)

0 commit comments

Comments
 (0)