Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move creative tabs out of GregTechAPI #2317

Merged
merged 3 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,6 +1,6 @@
package gregtech.api.block;

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

import net.minecraft.block.Block;
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
16 changes: 13 additions & 3 deletions src/main/java/gregtech/api/block/machines/BlockMachine.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import gregtech.api.block.UnlistedStringProperty;
import gregtech.api.cover.Cover;
import gregtech.api.cover.IFacadeCover;
import gregtech.common.creativetab.GTCreativeTabs;
import gregtech.api.items.toolitem.ToolClasses;
import gregtech.api.items.toolitem.ToolHelper;
import gregtech.api.metatileentity.MetaTileEntity;
Expand Down Expand Up @@ -40,7 +41,11 @@
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
Expand All @@ -63,7 +68,12 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.Set;

import static gregtech.api.util.GTUtility.getMetaTileEntity;

Expand All @@ -83,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 @@ -2,6 +2,7 @@

import gregtech.api.GTValues;
import gregtech.api.GregTechAPI;
import gregtech.common.creativetab.GTCreativeTabs;
import gregtech.api.metatileentity.ITieredMetaTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.pipenet.block.BlockPipe;
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,6 +1,6 @@
package gregtech.api.items.armor;

import gregtech.api.GregTechAPI;
import gregtech.common.creativetab.GTCreativeTabs;
import gregtech.api.items.metaitem.MetaItem;
import gregtech.api.items.metaitem.stats.IEnchantabilityHelper;
import gregtech.api.items.metaitem.stats.IItemComponent;
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,7 @@
package gregtech.api.items.materialitem;

import gregtech.api.GTValues;
import gregtech.api.GregTechAPI;
import gregtech.common.creativetab.GTCreativeTabs;
import gregtech.api.damagesources.DamageSources;
import gregtech.api.items.armor.ArmorMetaItem;
import gregtech.api.items.metaitem.StandardMetaItem;
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,18 +1,29 @@
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;
import gregtech.api.capability.IPropertyFluidFilter;
import gregtech.api.capability.impl.CombinedCapabilityProvider;
import gregtech.api.capability.impl.ElectricItem;
import gregtech.common.creativetab.GTCreativeTabs;
import gregtech.api.gui.ModularUI;
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 Down Expand Up @@ -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,6 +1,6 @@
package gregtech.api.items.toolitem;

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

import net.minecraft.block.state.IBlockState;
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,6 +1,6 @@
package gregtech.api.items.toolitem;

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

import net.minecraft.block.state.IBlockState;
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,6 +1,6 @@
package gregtech.api.items.toolitem;

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

import net.minecraft.block.state.IBlockState;
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
Loading
Loading