diff options
author | NotAPenguin <michiel.vandeginste@gmail.com> | 2024-09-02 23:17:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-02 23:17:17 +0200 |
commit | 1b820de08a05070909a267e17f033fcf58ac8710 (patch) | |
tree | 02831a025986a06b20f87e5bcc69d1e0c639a342 /src/main/java/ggfab/items | |
parent | afd3fd92b6a6ab9ab0d0dc3214e6bc8ff7a86c9b (diff) | |
download | GT5-Unofficial-1b820de08a05070909a267e17f033fcf58ac8710.tar.gz GT5-Unofficial-1b820de08a05070909a267e17f033fcf58ac8710.tar.bz2 GT5-Unofficial-1b820de08a05070909a267e17f033fcf58ac8710.zip |
The Great Renaming (#3014)
* move kekztech to a single root dir
* move detrav to a single root dir
* move gtnh-lanthanides to a single root dir
* move tectech and delete some gross reflection in gt++
* remove more reflection inside gt5u
* delete more reflection in gt++
* fix imports
* move bartworks and bwcrossmod
* fix proxies
* move galactigreg and ggfab
* move gtneioreplugin
* try to fix gt++ bee loader
* apply the rename rules to BW
* apply rename rules to bwcrossmod
* apply rename rules to detrav scanner mod
* apply rename rules to galacticgreg
* apply rename rules to ggfab
* apply rename rules to goodgenerator
* apply rename rules to gtnh-lanthanides
* apply rename rules to gt++
* apply rename rules to kekztech
* apply rename rules to kubatech
* apply rename rules to tectech
* apply rename rules to gt
apply the rename rules to gt
* fix tt import
* fix mui hopefully
* fix coremod except intergalactic
* rename assline recipe class
* fix a class name i stumbled on
* rename StructureUtility to GTStructureUtility to prevent conflict with structurelib
* temporary rename of GTTooltipDataCache to old name
* fix gt client/server proxy names
Diffstat (limited to 'src/main/java/ggfab/items')
-rw-r--r-- | src/main/java/ggfab/items/GGMetaItemDumbItems.java | 153 |
1 files changed, 153 insertions, 0 deletions
diff --git a/src/main/java/ggfab/items/GGMetaItemDumbItems.java b/src/main/java/ggfab/items/GGMetaItemDumbItems.java new file mode 100644 index 0000000000..479cc160ba --- /dev/null +++ b/src/main/java/ggfab/items/GGMetaItemDumbItems.java @@ -0,0 +1,153 @@ +package ggfab.items; + +import static gregtech.api.enums.GTValues.D1; + +import java.util.ArrayList; +import java.util.BitSet; +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ggfab.GGConstants; +import gnu.trove.map.TIntObjectMap; +import gnu.trove.map.hash.TIntObjectHashMap; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.SubTag; +import gregtech.api.enums.TCAspects; +import gregtech.api.interfaces.IItemBehaviour; +import gregtech.api.interfaces.IItemContainer; +import gregtech.api.items.MetaBaseItem; +import gregtech.api.objects.ItemData; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTUtility; + +// mostly stolen from gt5 itself. +public class GGMetaItemDumbItems extends MetaBaseItem { + + public static final int MAX_ID = 32766; + private final BitSet mEnabledItems = new BitSet(); + private final BitSet mVisibleItems = new BitSet(); + private final ArrayList<IIcon> mIconList = new ArrayList<>(); + private final TIntObjectMap<IItemContainer> mIconOverride = new TIntObjectHashMap<>(); + + public GGMetaItemDumbItems(String aUnlocalized) { + super(aUnlocalized); + } + + /** + * This adds a Custom Item to the ending Range. + * + * @param aID The Id of the assigned Item [0 - mItemAmount] (The MetaData gets auto-shifted by +mOffset) + * @param aEnglish The Default Localized Name of the created Item + * @param aToolTip The Default ToolTip of the created Item, you can also insert null for having no ToolTip + * @param aRandomData The OreDict Names you want to give the Item. Also used for TC Aspects and some other things. + * @return An ItemStack containing the newly created Item. + */ + public final ItemStack addItem(int aID, String aEnglish, String aToolTip, Object... aRandomData) { + if (aID < 0 || aID > MAX_ID) return null; + + if (aToolTip == null) aToolTip = ""; + ItemStack rStack = new ItemStack(this, 1, aID); + mEnabledItems.set(aID); + mVisibleItems.set(aID); + GTLanguageManager.addStringLocalization(getUnlocalizedName(rStack) + ".name", aEnglish); + GTLanguageManager.addStringLocalization(getUnlocalizedName(rStack) + ".tooltip", aToolTip); + List<TCAspects.TC_AspectStack> tAspects = new ArrayList<>(); + // Important Stuff to do first + for (Object tRandomData : aRandomData) if (tRandomData instanceof SubTag) { + if (tRandomData == SubTag.INVISIBLE) { + mVisibleItems.set(aID, false); + continue; + } + if (tRandomData == SubTag.NO_UNIFICATION) { + GTOreDictUnificator.addToBlacklist(rStack); + } + } + // now check for the rest + for (Object tRandomData : aRandomData) if (tRandomData != null) { + boolean tUseOreDict = true; + if (tRandomData instanceof IItemBehaviour) { + @SuppressWarnings("unchecked") + IItemBehaviour<MetaBaseItem> behavior = (IItemBehaviour<MetaBaseItem>) tRandomData; + addItemBehavior(aID, behavior); + tUseOreDict = false; + } + if (tRandomData instanceof IItemContainer) { + ((IItemContainer) tRandomData).set(rStack); + tUseOreDict = false; + } + if (tRandomData instanceof SubTag) { + continue; + } + if (tRandomData instanceof IItemContainer) { + mIconOverride.put(aID, (IItemContainer) tRandomData); + } else if (tRandomData instanceof TCAspects.TC_AspectStack) { + ((TCAspects.TC_AspectStack) tRandomData).addToAspectList(tAspects); + } else if (tRandomData instanceof ItemData) { + if (GTUtility.isStringValid(tRandomData)) { + GTOreDictUnificator.registerOre(tRandomData, rStack); + } else { + GTOreDictUnificator.addItemData(rStack, (ItemData) tRandomData); + } + } else if (tUseOreDict) { + GTOreDictUnificator.registerOre(tRandomData, rStack); + } + } + if (GregTechAPI.sThaumcraftCompat != null) + GregTechAPI.sThaumcraftCompat.registerThaumcraftAspectsToItem(rStack, tAspects, false); + return rStack; + } + + @Override + @SideOnly(Side.CLIENT) + public final void registerIcons(IIconRegister aIconRegister) { + short j = (short) mEnabledItems.length(); + mIconList.clear(); + mIconList.ensureCapacity(j); + for (short i = 0; i < j; i++) { + if (mEnabledItems.get(i)) { + mIconList.add(aIconRegister.registerIcon(GGConstants.RES_PATH_ITEM + getUnlocalizedName() + "/" + i)); + } else { + mIconList.add(null); + } + } + } + + @Override + public IIcon getIconFromDamage(int aMetaData) { + if (aMetaData < 0 || aMetaData >= mIconList.size() || mIconList.get(aMetaData) == null) + return super.getIconFromDamage(aMetaData); + return mIconList.get(aMetaData); + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item aItem, CreativeTabs aCreativeTab, List aList) { + int j = mEnabledItems.length(); + for (int i = 0; i < j; i++) { + if (mVisibleItems.get(i) || (D1 && mEnabledItems.get(i))) { + ItemStack tStack = new ItemStack(this, 1, i); + isItemStackUsable(tStack); + aList.add(tStack); + } + } + } + + @Override + public Long[] getElectricStats(ItemStack aStack) { + return null; + } + + @Override + public Long[] getFluidContainerStats(ItemStack aStack) { + return null; + } +} |