Skip to content

Commit

Permalink
move creative tabs out of GregTechAPI (GregTechCEu#2317)
Browse files Browse the repository at this point in the history
  • Loading branch information
TechLord22 authored Jan 11, 2024
1 parent 588695e commit 996e6cf
Show file tree
Hide file tree
Showing 36 changed files with 259 additions and 162 deletions.
26 changes: 0 additions & 26 deletions src/main/java/gregtech/api/GregTechAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,14 @@
import gregtech.api.modules.IModuleManager;
import gregtech.api.network.INetworkHandler;
import gregtech.api.sound.ISoundManager;
import gregtech.api.unification.OreDictUnifier;
import gregtech.api.unification.material.Material;
import gregtech.api.unification.material.Materials;
import gregtech.api.unification.material.registry.IMaterialRegistryManager;
import gregtech.api.unification.material.registry.MarkerMaterialRegistry;
import gregtech.api.unification.ore.OrePrefix;
import gregtech.api.unification.ore.StoneType;
import gregtech.api.util.BaseCreativeTab;
import gregtech.api.util.GTControlledRegistry;
import gregtech.api.util.GTLog;
import gregtech.api.util.IBlockOre;
import gregtech.common.ConfigHolder;
import gregtech.common.blocks.BlockWarningSign;
import gregtech.common.blocks.MetaBlocks;
import gregtech.common.items.MetaItems;
import gregtech.common.items.ToolItems;
import gregtech.common.metatileentities.MetaTileEntities;

import net.minecraft.block.state.IBlockState;
import net.minecraft.util.ResourceLocation;
Expand Down Expand Up @@ -78,23 +69,6 @@ public class GregTechAPI {
public static final Object2ObjectMap<IBlockState, IHeatingCoilBlockStats> HEATING_COILS = new Object2ObjectOpenHashMap<>();
public static final Object2ObjectMap<IBlockState, IBatteryData> PSS_BATTERIES = new Object2ObjectOpenHashMap<>();

public static final BaseCreativeTab TAB_GREGTECH = new BaseCreativeTab(GTValues.MODID + ".main",
() -> MetaItems.LOGO.getStackForm(), true);
public static final BaseCreativeTab TAB_GREGTECH_MACHINES = new BaseCreativeTab(GTValues.MODID + ".machines",
() -> MetaTileEntities.ELECTRIC_BLAST_FURNACE.getStackForm(), true);
public static final BaseCreativeTab TAB_GREGTECH_CABLES = new BaseCreativeTab(GTValues.MODID + ".cables",
() -> OreDictUnifier.get(OrePrefix.cableGtDouble, Materials.Aluminium), true);
public static final BaseCreativeTab TAB_GREGTECH_PIPES = new BaseCreativeTab(GTValues.MODID + ".pipes",
() -> OreDictUnifier.get(OrePrefix.pipeNormalFluid, Materials.Aluminium), true);
public static final BaseCreativeTab TAB_GREGTECH_TOOLS = new BaseCreativeTab(GTValues.MODID + ".tools",
() -> ToolItems.HARD_HAMMER.get(Materials.Aluminium), true);
public static final BaseCreativeTab TAB_GREGTECH_MATERIALS = new BaseCreativeTab(GTValues.MODID + ".materials",
() -> OreDictUnifier.get(OrePrefix.ingot, Materials.Aluminium), true);
public static final BaseCreativeTab TAB_GREGTECH_ORES = new BaseCreativeTab(GTValues.MODID + ".ores",
() -> OreDictUnifier.get(OrePrefix.ore, Materials.Aluminium), true);
public static final BaseCreativeTab TAB_GREGTECH_DECORATIONS = new BaseCreativeTab(GTValues.MODID + ".decorations",
() -> MetaBlocks.WARNING_SIGN.getItemVariant(BlockWarningSign.SignType.YELLOW_STRIPES), true);

/** Will be available at the Pre-Initialization stage */
public static boolean isHighTier() {
return highTier;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/gregtech/api/block/VariantBlock.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package gregtech.api.block;

import gregtech.api.GregTechAPI;
import gregtech.api.util.LocalizationUtils;
import gregtech.common.creativetab.GTCreativeTabs;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
Expand Down Expand Up @@ -43,7 +43,7 @@ public VariantBlock(Material materialIn) {
state);
}
}
setCreativeTab(GregTechAPI.TAB_GREGTECH);
setCreativeTab(GTCreativeTabs.TAB_GREGTECH);
setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, VALUES[0]));
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/gregtech/api/block/machines/BlockMachine.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import gregtech.api.pipenet.IBlockAppearance;
import gregtech.api.util.GTUtility;
import gregtech.client.renderer.handler.MetaTileEntityRenderer;
import gregtech.common.creativetab.GTCreativeTabs;
import gregtech.common.items.MetaItems;
import gregtech.integration.ctm.IFacadeWrapper;

Expand Down Expand Up @@ -92,7 +93,7 @@ public class BlockMachine extends BlockCustomParticle implements ITileEntityProv

public BlockMachine() {
super(Material.IRON);
setCreativeTab(GregTechAPI.TAB_GREGTECH_MACHINES);
setCreativeTab(GTCreativeTabs.TAB_GREGTECH_MACHINES);
setSoundType(SoundType.METAL);
setHardness(6.0f);
setResistance(6.0f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import gregtech.api.util.LocalizationUtils;
import gregtech.client.utils.TooltipHelper;
import gregtech.common.ConfigHolder;
import gregtech.common.creativetab.GTCreativeTabs;

import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
Expand Down Expand Up @@ -61,8 +62,8 @@ public class MachineItemBlock extends ItemBlock {
*/
public static void addCreativeTab(CreativeTabs creativeTab) {
Preconditions.checkNotNull(creativeTab, "creativeTab");
if (creativeTab == GregTechAPI.TAB_GREGTECH_MACHINES) {
throw new IllegalArgumentException("Adding " + GregTechAPI.TAB_GREGTECH_MACHINES.tabLabel +
if (creativeTab == GTCreativeTabs.TAB_GREGTECH_MACHINES) {
throw new IllegalArgumentException("Adding " + GTCreativeTabs.TAB_GREGTECH_MACHINES.tabLabel +
" as additional creative tab is redundant.");
} else if (creativeTab == CreativeTabs.SEARCH) {
throw new IllegalArgumentException(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package gregtech.api.util;
package gregtech.api.creativetab;

import gregtech.api.util.GTLog;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
Expand All @@ -13,31 +15,32 @@ public class BaseCreativeTab extends CreativeTabs {
private final boolean hasSearchBar;
private final Supplier<ItemStack> iconSupplier;

public BaseCreativeTab(String TabName, Supplier<ItemStack> iconSupplier, boolean hasSearchBar) {
super(TabName);
public BaseCreativeTab(String tabName, Supplier<ItemStack> iconSupplier, boolean hasSearchBar) {
super(tabName);
this.iconSupplier = iconSupplier;
this.hasSearchBar = hasSearchBar;

if (hasSearchBar)
if (hasSearchBar) {
setBackgroundImageName("item_search.png");
}
}

@NotNull
@Override
public ItemStack createIcon() {
if (iconSupplier == null) {
GTLog.logger.error("Icon supplier was null for CreativeTab " + getTabLabel());
GTLog.logger.error("Icon supplier was null for CreativeTab {}", getTabLabel());
return new ItemStack(Blocks.STONE);
}

ItemStack stack = iconSupplier.get();
if (stack == null) {
GTLog.logger.error("Icon supplier return null for CreativeTab " + getTabLabel());
GTLog.logger.error("Icon supplier return null for CreativeTab {}", getTabLabel());
return new ItemStack(Blocks.STONE);
}

if (stack == ItemStack.EMPTY) {
GTLog.logger.error("Icon built from iconSupplied is EMPTY for CreativeTab " + getTabLabel());
if (stack.isEmpty()) {
GTLog.logger.error("Icon built from iconSupplied is EMPTY for CreativeTab {}", getTabLabel());
return new ItemStack(Blocks.STONE);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/gregtech/api/items/armor/ArmorMetaItem.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package gregtech.api.items.armor;

import gregtech.api.GregTechAPI;
import gregtech.api.items.metaitem.MetaItem;
import gregtech.api.items.metaitem.stats.IEnchantabilityHelper;
import gregtech.api.items.metaitem.stats.IItemComponent;
import gregtech.common.creativetab.GTCreativeTabs;

import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.model.ModelBiped;
Expand Down Expand Up @@ -33,7 +33,7 @@ public class ArmorMetaItem<T extends ArmorMetaItem<?>.ArmorMetaValueItem> extend

public ArmorMetaItem() {
super((short) 0);
setCreativeTab(GregTechAPI.TAB_GREGTECH_TOOLS);
setCreativeTab(GTCreativeTabs.TAB_GREGTECH_TOOLS);
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package gregtech.api.items.materialitem;

import gregtech.api.GTValues;
import gregtech.api.GregTechAPI;
import gregtech.api.damagesources.DamageSources;
import gregtech.api.items.armor.ArmorMetaItem;
import gregtech.api.items.metaitem.StandardMetaItem;
Expand All @@ -15,6 +14,7 @@
import gregtech.api.unification.material.registry.MaterialRegistry;
import gregtech.api.unification.ore.OrePrefix;
import gregtech.api.unification.stack.UnificationEntry;
import gregtech.common.creativetab.GTCreativeTabs;

import net.minecraft.block.BlockCauldron;
import net.minecraft.block.state.IBlockState;
Expand Down Expand Up @@ -58,7 +58,7 @@ public MetaPrefixItem(@NotNull MaterialRegistry registry, @NotNull OrePrefix ore
super();
this.registry = registry;
this.prefix = orePrefix;
this.setCreativeTab(GregTechAPI.TAB_GREGTECH_MATERIALS);
this.setCreativeTab(GTCreativeTabs.TAB_GREGTECH_MATERIALS);
}

@Override
Expand Down
32 changes: 27 additions & 5 deletions src/main/java/gregtech/api/items/metaitem/MetaItem.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package gregtech.api.items.metaitem;

import gregtech.api.GTValues;
import gregtech.api.GregTechAPI;
import gregtech.api.capability.GregtechCapabilities;
import gregtech.api.capability.IElectricItem;
import gregtech.api.capability.IFilteredFluidContainer;
Expand All @@ -12,7 +11,18 @@
import gregtech.api.items.OreDictNames;
import gregtech.api.items.gui.ItemUIFactory;
import gregtech.api.items.gui.PlayerInventoryHolder;
import gregtech.api.items.metaitem.stats.*;
import gregtech.api.items.metaitem.stats.IEnchantabilityHelper;
import gregtech.api.items.metaitem.stats.IFoodBehavior;
import gregtech.api.items.metaitem.stats.IItemBehaviour;
import gregtech.api.items.metaitem.stats.IItemCapabilityProvider;
import gregtech.api.items.metaitem.stats.IItemColorProvider;
import gregtech.api.items.metaitem.stats.IItemComponent;
import gregtech.api.items.metaitem.stats.IItemContainerItemProvider;
import gregtech.api.items.metaitem.stats.IItemDurabilityManager;
import gregtech.api.items.metaitem.stats.IItemMaxStackSizeProvider;
import gregtech.api.items.metaitem.stats.IItemNameProvider;
import gregtech.api.items.metaitem.stats.IItemUseManager;
import gregtech.api.items.metaitem.stats.ISubItemHandler;
import gregtech.api.recipes.ingredients.IntCircuitIngredient;
import gregtech.api.unification.OreDictUnifier;
import gregtech.api.unification.material.Material;
Expand All @@ -22,6 +32,7 @@
import gregtech.api.util.LocalizationUtils;
import gregtech.client.utils.ToolChargeBarRenderer;
import gregtech.common.ConfigHolder;
import gregtech.common.creativetab.GTCreativeTabs;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelBakery;
Expand All @@ -40,7 +51,12 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.*;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
Expand Down Expand Up @@ -72,7 +88,13 @@

import java.time.Duration;
import java.time.Instant;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
* MetaItem is item that can have up to Short.MAX_VALUE items inside one id.
Expand Down Expand Up @@ -107,7 +129,7 @@ public static List<MetaItem<?>> getMetaItems() {

protected final short metaItemOffset;

private CreativeTabs[] defaultCreativeTabs = new CreativeTabs[] { GregTechAPI.TAB_GREGTECH };
private CreativeTabs[] defaultCreativeTabs = new CreativeTabs[] { GTCreativeTabs.TAB_GREGTECH };
private final Set<CreativeTabs> additionalCreativeTabs = new ObjectArraySet<>();

public MetaItem(short metaItemOffset) {
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/gregtech/api/items/toolitem/ItemGTAxe.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package gregtech.api.items.toolitem;

import gregtech.api.GregTechAPI;
import gregtech.api.util.LocalizationUtils;
import gregtech.common.creativetab.GTCreativeTabs;

import net.minecraft.block.state.IBlockState;
import net.minecraft.client.util.ITooltipFlag;
Expand All @@ -14,7 +14,12 @@
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.*;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
Expand Down Expand Up @@ -59,7 +64,7 @@ protected ItemGTAxe(String domain, String id, int tier, IGTToolDefinition toolSt
this.secondaryOreDicts = secondaryOreDicts;
this.markerItem = markerItem;
setMaxStackSize(1);
setCreativeTab(GregTechAPI.TAB_GREGTECH_TOOLS);
setCreativeTab(GTCreativeTabs.TAB_GREGTECH_TOOLS);
setTranslationKey("gt.tool." + id + ".name");
setRegistryName(domain, id);
}
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/gregtech/api/items/toolitem/ItemGTHoe.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package gregtech.api.items.toolitem;

import gregtech.api.GregTechAPI;
import gregtech.api.util.LocalizationUtils;
import gregtech.common.creativetab.GTCreativeTabs;

import net.minecraft.block.state.IBlockState;
import net.minecraft.client.util.ITooltipFlag;
Expand All @@ -14,7 +14,12 @@
import net.minecraft.item.ItemHoe;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.*;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
Expand Down Expand Up @@ -59,7 +64,7 @@ protected ItemGTHoe(String domain, String id, int tier, IGTToolDefinition toolSt
this.secondaryOreDicts = secondaryOreDicts;
this.markerItem = markerItem;
setMaxStackSize(1);
setCreativeTab(GregTechAPI.TAB_GREGTECH_TOOLS);
setCreativeTab(GTCreativeTabs.TAB_GREGTECH_TOOLS);
setTranslationKey("gt.tool." + id + ".name");
setRegistryName(domain, id);
}
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/gregtech/api/items/toolitem/ItemGTSword.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package gregtech.api.items.toolitem;

import gregtech.api.GregTechAPI;
import gregtech.api.util.LocalizationUtils;
import gregtech.common.creativetab.GTCreativeTabs;

import net.minecraft.block.state.IBlockState;
import net.minecraft.client.util.ITooltipFlag;
Expand All @@ -14,7 +14,12 @@
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.*;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
Expand Down Expand Up @@ -61,7 +66,7 @@ protected ItemGTSword(String domain, String id, int tier, IGTToolDefinition tool
this.secondaryOreDicts = secondaryOreDicts;
this.markerItem = markerItem;
setMaxStackSize(1);
setCreativeTab(GregTechAPI.TAB_GREGTECH_TOOLS);
setCreativeTab(GTCreativeTabs.TAB_GREGTECH_TOOLS);
setTranslationKey("gt.tool." + id + ".name");
setRegistryName(domain, id);
}
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/gregtech/api/items/toolitem/ItemGTTool.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package gregtech.api.items.toolitem;

import gregtech.api.GregTechAPI;
import gregtech.api.util.LocalizationUtils;
import gregtech.common.creativetab.GTCreativeTabs;

import net.minecraft.block.state.IBlockState;
import net.minecraft.client.util.ITooltipFlag;
Expand All @@ -14,7 +14,12 @@
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemTool;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.*;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
Expand Down Expand Up @@ -65,7 +70,7 @@ protected ItemGTTool(String domain, String id, int tier, IGTToolDefinition toolS
this.secondaryOreDicts = secondaryOreDicts;
this.markerItem = markerItem;
setMaxStackSize(1);
setCreativeTab(GregTechAPI.TAB_GREGTECH_TOOLS);
setCreativeTab(GTCreativeTabs.TAB_GREGTECH_TOOLS);
setTranslationKey("gt.tool." + id + ".name");
setRegistryName(domain, id);
}
Expand Down
Loading

0 comments on commit 996e6cf

Please sign in to comment.