Skip to content

Commit

Permalink
Fix creative tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
Aizistral committed Sep 7, 2023
1 parent 23e9ccb commit 52bd6f0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
import com.aizistral.enigmaticlegacy.registries.EnigmaticPotions;
import com.aizistral.enigmaticlegacy.registries.EnigmaticRecipes;
import com.aizistral.enigmaticlegacy.registries.EnigmaticSounds;
import com.aizistral.enigmaticlegacy.registries.EnigmaticTabs;
import com.aizistral.enigmaticlegacy.registries.EnigmaticTiles;
import com.aizistral.enigmaticlegacy.triggers.BeheadingTrigger;
import com.aizistral.enigmaticlegacy.triggers.CursedInventoryChangedTrigger;
Expand Down Expand Up @@ -221,6 +222,7 @@ public EnigmaticLegacy() {
this.loadClass(EnigmaticEntities.class);
this.loadClass(EnigmaticEnchantments.class);
this.loadClass(EnigmaticLootModifiers.class);
this.loadClass(EnigmaticTabs.class);

FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientRegistries);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Map;
import java.util.function.Supplier;

import com.aizistral.enigmaticlegacy.EnigmaticLegacy;
import com.aizistral.enigmaticlegacy.blocks.BlockAstralDust;
import com.aizistral.enigmaticlegacy.blocks.BlockBigLamp;
import com.aizistral.enigmaticlegacy.blocks.BlockCosmicCake;
Expand All @@ -14,6 +15,7 @@
import com.aizistral.enigmaticlegacy.items.generic.GenericBlockItem;
import com.aizistral.etherium.blocks.BlockEtherium;

import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -23,24 +25,36 @@
import net.minecraft.world.level.block.Block;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.ObjectHolder;
import net.minecraftforge.registries.RegisterEvent;

public class EnigmaticTabs extends AbstractRegistry<CreativeModeTab> {
private static final EnigmaticTabs INSTANCE = new EnigmaticTabs();

@ObjectHolder(value = MODID + ":tab_main", registryName = "creative_mode_tab")
public static final CreativeModeTab MAIN = null;
// Object holders don't work for creative tabs for some reason

@ObjectHolder(value = MODID + ":tab_potions", registryName = "creative_mode_tab")
public static final CreativeModeTab POTIONS = null;
// @ObjectHolder(value = MODID + ":tab_main", registryName = "creative_mode_tab")
public static final CreativeModeTab MAIN;

// @ObjectHolder(value = MODID + ":tab_potions", registryName = "creative_mode_tab")
public static final CreativeModeTab POTIONS;

static {
MAIN = CreativeModeTab.builder().title(Component.translatable("itemGroup.enigmaticCreativeTab"))
.icon(() -> new ItemStack(EnigmaticItems.ENIGMATIC_ITEM)).build();

POTIONS = CreativeModeTab.builder().title(Component.translatable("itemGroup.enigmaticPotionCreativeTab"))
.icon(() -> new ItemStack(EnigmaticItems.RECALL_POTION)).build();
}

private EnigmaticTabs() {
super(Registries.CREATIVE_MODE_TAB);
this.register("tab_potions", () -> POTIONS);
this.register("tab_main", () -> MAIN);
}

this.register("tab_potions", () -> CreativeModeTab.builder().title(Component.translatable(
"itemGroup.enigmaticPotionCreativeTab")).icon(() -> new ItemStack(EnigmaticItems.RECALL_POTION)).build());

this.register("tab_main", () -> CreativeModeTab.builder().title(Component.translatable(
"itemGroup.enigmaticCreativeTab")).icon(() -> new ItemStack(EnigmaticItems.ENIGMATIC_ITEM)).build());
@Override
protected void onRegister(RegisterEvent event) {
// NO-OP
}

}

0 comments on commit 52bd6f0

Please sign in to comment.