@author Gregorius Techneticies
| 50 | * @author Gregorius Techneticies |
| 51 | */ |
| 52 | public class PrefixItem extends Item implements Runnable, IItemUpdatable, IPrefixItem, IItemGT, IItemNoGTOverride { |
| 53 | public final String mNameInternal; |
| 54 | public final OreDictPrefix mPrefix; |
| 55 | public final OreDictMaterial[] mMaterialList; |
| 56 | |
| 57 | public ItemStack mContainerItem = null; |
| 58 | |
| 59 | /** The Sound played when crafting with this Item */ |
| 60 | public String mCraftingSound = null; |
| 61 | |
| 62 | public PrefixItem(ModData aMod, String aNameInternal, OreDictPrefix aPrefix) { |
| 63 | this(aMod.mID, aMod.mID, aNameInternal, aPrefix, OreDictMaterial.MATERIAL_ARRAY); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * @param aModIDOwner the ID of the owning Mod. DO NOT INSERT ANY GREGTECH MODID!!! |
| 68 | * @param aModIDTextures the ID of the Texture providing Mod (for the "ModID:TextureName" thing) |
| 69 | * @param aNameInternal the internal Name of this Item. DO NOT START YOUR UNLOCALISED NAME WITH "gt."!!! |
| 70 | * @param aPrefix the OreDictPrefix corresponding to this Item. |
| 71 | */ |
| 72 | public PrefixItem(String aModIDOwner, String aModIDTextures, String aNameInternal, OreDictPrefix aPrefix, OreDictMaterial... aMaterialList) { |
| 73 | super(); |
| 74 | mPrefix = aPrefix; |
| 75 | mPrefix.mRegisteredPrefixItems.add(this); |
| 76 | mNameInternal = aNameInternal; |
| 77 | mMaterialList = (aMaterialList.length > 0 ? aMaterialList : OreDictMaterial.MATERIAL_ARRAY); |
| 78 | if (mMaterialList[0] != MT.Empty) throw new IllegalArgumentException("The first element of the custom Material List has to be MT.Empty for technical reasons!"); |
| 79 | |
| 80 | setMaxDamage(0); |
| 81 | setHasSubtypes(T); |
| 82 | GameRegistry.registerItem(this, mNameInternal, aModIDOwner); |
| 83 | |
| 84 | mPrefix.addTextureSet(aModIDTextures, T); |
| 85 | LH.add("oredict." + mPrefix.dat(MT.Empty).toString(), getLocalName(mPrefix, MT.Empty)); |
| 86 | LH.add(mNameInternal+"."+W, "Any Sub-Item of this one"); // Local Name for the WildcardItem Variant. |
| 87 | mPrefix.mRegisteredItems.add(this); // this optimizes some processes by decreasing the size of the Set. |
| 88 | |
| 89 | if (SHOW_HIDDEN_PREFIXES || !mPrefix.contains(TD.Creative.HIDDEN)) { |
| 90 | if (mPrefix.mCreativeTab == null) mPrefix.mCreativeTab = new CreativeTab(mPrefix.mNameInternal, mPrefix.mNameCategory, this, W); |
| 91 | setCreativeTab(mPrefix.mCreativeTab); |
| 92 | } else { |
| 93 | setCreativeTab(CreativeTabs.tabMisc); |
| 94 | } |
| 95 | |
| 96 | // Execute before all the other things. This is to ensure that PrefixItems are created before MultiItems. |
| 97 | GAPI.mBeforeInit.add(0, this); |
| 98 | } |
| 99 | |
| 100 | /** This ensures, that all Materials are registered at the time this Item registers to the OreDictionary. */ |
| 101 | @Override |
| 102 | public void run() { |
| 103 | boolean tUnificationAllowed = (mPrefix.contains(TD.Prefix.UNIFICATABLE) && !mPrefix.contains(TD.Prefix.UNIFICATABLE_RECIPES)); |
| 104 | for (short i = 0; i < mMaterialList.length; i++) if (mPrefix.isGeneratingItem(mMaterialList[i])) { |
| 105 | ItemStack tStack = ST.update_(ST.make(this, 1, i)); |
| 106 | LH.add("oredict." + mPrefix.dat(mMaterialList[i]).toString(), getLocalName(mPrefix, mMaterialList[i])); |
| 107 | if (tUnificationAllowed) OreDictManager.INSTANCE.addTarget_(mPrefix, mMaterialList[i], tStack); else OreDictManager.INSTANCE.registerOre_(mPrefix, mMaterialList[i], tStack); |
| 108 | } |
| 109 | } |
nothing calls this directly
no outgoing calls
no test coverage detected