From 46daf120bb00b03a4889863466a74b00e15468d8 Mon Sep 17 00:00:00 2001 From: Muramasa Date: Fri, 19 Aug 2016 12:15:05 +0100 Subject: [PATCH] initMaterialProperties --- build.gradle | 4 + src/main/java/gregtech/GT_Mod.java | 11 +- .../java/gregtech/api/enums/Materials.java | 154 ++++++++++++------ src/main/java/gregtech/api/enums/SubTag.java | 8 +- src/main/java/gregtech/common/GT_Proxy.java | 2 +- .../gregtech/common/blocks/GT_Block_Ores.java | 2 +- .../common/blocks/GT_Block_Ores_Abstract.java | 4 +- .../common/blocks/GT_Block_Ores_GC.java | 2 +- .../common/blocks/GT_Block_Ores_UB1.java | 2 +- .../common/blocks/GT_Block_Ores_UB2.java | 2 +- .../common/blocks/GT_Block_Ores_UB3.java | 2 +- .../basic/GT_MetaTileEntity_Replicator.java | 2 +- .../postload/GT_MachineRecipeLoader.java | 2 +- .../GT_Loader_Item_Block_And_Fluid.java | 2 +- 14 files changed, 134 insertions(+), 65 deletions(-) diff --git a/build.gradle b/build.gradle index 57760837..c8dd8e61 100644 --- a/build.gradle +++ b/build.gradle @@ -28,6 +28,10 @@ version = "${config.gt.version}" group= "gregtech" archivesBaseName = "gregtech" + +sourceCompatibility = 1.7 +targetCompatibility = 1.7 + minecraft { version = "${config.minecraft.version}-${config.forge.version}" runDir = "eclipse" diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index f020818a..a1c4dc86 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -245,7 +245,7 @@ public class GT_Mod if(gregtechproxy.mChangeHarvestLevels){ gregtechproxy.mGraniteHavestLevel = (int) GregTech_API.sMaterialProperties.get("havestLevel", "graniteHarvestLevel", 3); gregtechproxy.mMaxHarvestLevel=(int) Math.min(15, GregTech_API.sMaterialProperties.get("havestLevel", "maxLevel",7)); - for(Materials tMaterial : Materials.VALUES){ + for(Materials tMaterial : Materials.MATERIALS.values()){ if(tMaterial!=null&&tMaterial.mToolQuality>0&&tMaterial.mMetaItemSubID=0){ gregtechproxy.mHarvestLevel[tMaterial.mMetaItemSubID] = GregTech_API.sMaterialProperties.get("materialHavestLevel", tMaterial.mDefaultLocalName,tMaterial.mToolQuality); } @@ -269,7 +269,11 @@ public class GT_Mod } } //GT_Config.troll = (Calendar.getInstance().get(2) + 1 == 4) && (Calendar.getInstance().get(5) >= 1) && (Calendar.getInstance().get(5) <= 2); + Materials Muranium = new Materials(378, TextureSet.SET_NONE, 1.0F, 0, 2, 1|2|4|8|16|32|64|128, 92, 0, 168, 0, "Muranium", 0, 0, -1, 0, false, false, 3, 1, 1, Dyes._NULL, "takpak"); + //SubTag.METAL.addTo(Muranium); Materials.initCustomMaterials(); + Materials.initMaterialProperties(); + Materials.initGeneratedMaterials(); GT_Log.out.println("GT_Mod: Saving Main Config"); tMainConfig.save(); @@ -387,7 +391,7 @@ public class GT_Mod } new GT_Bees(); - + gregtechproxy.onLoad(); if (gregtechproxy.mSortToTheEnd) { new GT_ItemIterator().run(); @@ -642,7 +646,7 @@ public class GT_Mod GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{ItemList.Tool_DataOrb.getWithName(1L, "Orb to overwrite", new Object[0])}, new ItemStack[]{ItemList.Tool_DataOrb.getWithName(1L, "Copy of the Orb", new Object[0])}, ItemList.Tool_DataOrb.getWithName(0L, "Orb to copy", new Object[0]), null, null, 512, 32, 0); GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Stick to overwrite", new Object[0])}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Copy of the Stick", new Object[0])}, ItemList.Tool_DataStick.getWithName(0L, "Stick to copy", new Object[0]), null, null, 128, 32, 0); GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Raw Prospection Data", new Object[0])}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Analyzed Prospection Data", new Object[0])}, null, null, null, 1000, 32, 0); - for (Materials tMaterial : Materials.VALUES) { + for (Materials tMaterial : Materials.MATERIALS.values()) { if ((tMaterial.mElement != null) && (!tMaterial.mElement.mIsIsotope) && (tMaterial != Materials.Magic) && (tMaterial.getMass() > 0L)) { ItemStack tOutput = ItemList.Tool_DataOrb.get(1L, new Object[0]); Behaviour_DataOrb.setDataTitle(tOutput, "Elemental-Scan"); @@ -680,7 +684,6 @@ public class GT_Mod GregTech_API.mInputRF = false; } } - Materials.initMaterialProperties(); achievements = new GT_Achievements(); Map.Entry tRecipe; GT_Log.out.println("GT_Mod: Loading finished, deallocating temporary Init Variables."); diff --git a/src/main/java/gregtech/api/enums/Materials.java b/src/main/java/gregtech/api/enums/Materials.java index 8a291785..e937a639 100644 --- a/src/main/java/gregtech/api/enums/Materials.java +++ b/src/main/java/gregtech/api/enums/Materials.java @@ -1,5 +1,6 @@ package gregtech.api.enums; +import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.TC_Aspects.TC_AspectStack; import gregtech.api.interfaces.IColorModulationContainer; @@ -17,8 +18,8 @@ import java.util.*; import static gregtech.api.enums.GT_Values.M; public class Materials implements IColorModulationContainer, ISubTagContainer { - public static Collection VALUES = new HashSet(); - public static Collection VALUES_CUSTOM = new HashSet(); + public static Map MATERIALS = new HashMap(); + public static Map MATERIALS_CUSTOM = new HashMap(); /** * This is the Default Material returned in case no Material has been found or a NullPointer has been inserted at a location where it shouldn't happen. @@ -706,19 +707,19 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { public TextureSet mIconSet; public int mMetaItemSubID; public boolean mUnificatable; - public final Materials mMaterialInto; - public final List mMaterialList = new ArrayList(); - public final List mOreByProducts = new ArrayList(), mOreReRegistrations = new ArrayList(); - public final List mAspects = new ArrayList(); - private final ArrayList mMaterialItems = new ArrayList(); - private final Collection mSubTags = new HashSet(); + public Materials mMaterialInto; + public List mMaterialList = new ArrayList(); + public List mOreByProducts = new ArrayList(), mOreReRegistrations = new ArrayList(); + public List mAspects = new ArrayList(); + private ArrayList mMaterialItems = new ArrayList(); + private Collection mSubTags = new HashSet(); public Enchantment mEnchantmentTools = null, mEnchantmentArmors = null; public byte mEnchantmentToolsLevel = 0, mEnchantmentArmorsLevel = 0; public boolean mBlastFurnaceRequired = false, mTransparent = false; public float mToolSpeed = 1.0F, mHeatDamage = 0.0F; public String mChemicalFormula = "?", mName = "null", mDefaultLocalName = "null"; public Dyes mColor = Dyes._NULL; - public short mMeltingPoint = 0, mBlastFurnaceTemp = 0; + public short mMeltingPoint = 0, mBlastFurnaceTemp = 0, mGasTemp = 0; public int mTypes = 0; // 1=?; 2=?; 4=?; 8=OreProcessing; 16=?; 32=?; 64=?; 128=?; 256=?; public int mDurability = 16, mFuelPower = 0, mFuelType = 0, mExtraData = 0, mOreValue = 0, mOreMultiplier = 1, mByProductMultiplier = 1, mSmeltingMultiplier = 1; public int mDensityMultiplier = 1, mDensityDivider = 1; @@ -728,13 +729,14 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { public byte mToolQuality = 0; public boolean mCustomOre = false; public String mCustomID = "null", mConfigSection = "null"; + public boolean mHasPlasma = false, mHasGas = false; public Fluid mSolid = null, mFluid = null, mGas = null, mPlasma = null; /** * This Fluid is used as standard Unit for Molten Materials. 1296 is a Molten Block, that means 144 is one Material Unit worth of fluid. */ public Fluid mStandardMoltenFluid = null; - + static { initSubTags(); Iron .mOreReRegistrations.add(AnyIron ); @@ -1261,26 +1263,16 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { } public static void initCustomMaterials() { - //TODO register fluids int i = 0; - StringBuilder aCustomPath = new StringBuilder(); - StringBuilder aCustomID = new StringBuilder(); for (int j = GregTech_API.sMaterialProperties.get("general", "AmountOfCustomMaterialSlots", 16); i < j; i++) { - aCustomID.append((i < 10 ? "0" : "")).append(i); - aCustomPath.append("materials.custom.").append(aCustomID.toString()); - int aMaterialID = GregTech_API.sMaterialProperties.get(aCustomPath.toString(), "MaterialID", -1); - String aMaterialName = GregTech_API.sMaterialProperties.get(aCustomPath.toString(), "MaterialName", "NullMat"); - if (aMaterialID >= 0 && aMaterialID <= 1000 && !aMaterialName.equalsIgnoreCase("nullmat")) { - new Materials(aMaterialID, TextureSet.SET_METALLIC, 1.0F, 0, 0, 0, 255, 255, 255, 0, aMaterialName, 0, 0, 0, 0, false, false, 1, 1, 1, Dyes._NULL, "custom", true, aCustomID.toString()); - } - aCustomID.setLength(0); - aCustomPath.setLength(0); + String aID = (i < 10 ? "0" : "") + i; + new Materials(-1, TextureSet.SET_METALLIC, 1.0F, 0, 0, 0, 255, 255, 255, 0, "custom" + aID, 0, 0, 0, 0, false, false, 1, 1, 1, Dyes._NULL, "custom", true, aID); } } - public static void initMaterialProperties() { + MATERIALS. StringBuilder aConfigPath = new StringBuilder(); - for (Materials aMaterial : VALUES) { + for (Materials aMaterial : MATERIALS.values()) { if (aMaterial != null && aMaterial != Materials._NULL && aMaterial != Materials.Empty) { aConfigPath.append("materials.").append(aMaterial.mConfigSection).append(".").append(aMaterial.mCustomOre ? aMaterial.mCustomID : aMaterial.mName); aMaterial.mMetaItemSubID = GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "MaterialID", aMaterial.mCustomOre ? -1 : aMaterial.mMetaItemSubID); @@ -1300,44 +1292,122 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { //aMaterial.mIconSet = GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "IconSet", aMaterial.mIconSet); aMaterial.mTransparent = GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "Transparent", aMaterial.mTransparent); aMaterial.mColor = Dyes.get(GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "DyeColor", aMaterial.mColor.mName)); - aMaterial.mRGBa[0] = aMaterial.mMoltenRGBa[0] = (short) GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "MatRed", aMaterial. mRGBa[0]); + aMaterial.mRGBa[0] = aMaterial.mMoltenRGBa[0] = (short) GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "MatRed", aMaterial.mRGBa[0]); aMaterial.mRGBa[1] = aMaterial.mMoltenRGBa[1] = (short) GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "MatGreen", aMaterial.mRGBa[1]); aMaterial.mRGBa[2] = aMaterial.mMoltenRGBa[2] = (short) GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "MatBlue", aMaterial.mRGBa[2]); aMaterial.mRGBa[3] = aMaterial.mMoltenRGBa[3] = (short) GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "MatAlpha", aMaterial.mRGBa[3]); aMaterial.mTypes = GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "MaterialTypes", aMaterial.mCustomOre ? 1|2|4|8|16|32|64|128 : aMaterial.mTypes); aMaterial.mUnificatable = GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "Unificatable", aMaterial.mUnificatable); + aMaterial.mChemicalFormula = GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "ChemicalFormula", aMaterial.mChemicalFormula); + aMaterial.mGasTemp = (short) GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "GasTemp", aMaterial.mGasTemp); + aMaterial.setOreMultiplier(GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "OreMultiplier", aMaterial.mOreMultiplier)); + aMaterial.setSmeltingMultiplier(GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "OreSmeltingMultiplier", aMaterial.mSmeltingMultiplier)); + aMaterial.setByProductMultiplier(GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "OreByProductMultiplier", aMaterial.mByProductMultiplier)); + aMaterial.setHeatDamage((float) GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "HeatDamage", aMaterial.mHeatDamage)); + aMaterial.mSmeltInto = MATERIALS.get(GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "MaterialSmeltInto", aMaterial.mSmeltInto.mName)); + aMaterial.mMacerateInto = MATERIALS.get(GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "MaterialMacerateInto", aMaterial.mMacerateInto.mName)); + aMaterial.mArcSmeltInto = MATERIALS.get(GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "MaterialArcSmeltInto", aMaterial.mArcSmeltInto.mName)); + aMaterial.mDirectSmelting = MATERIALS.get(GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "MaterialDirectSmeltInto", aMaterial.mDirectSmelting.mName)); + if (aMaterial.mHasPlasma = GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "AddPlasma", aMaterial.mHasPlasma)) GT_Mod.gregtechproxy.addAutogeneratedPlasmaFluid(aMaterial); + if (aMaterial.mHasGas = GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "AddGas", aMaterial.mHasGas)) GT_Mod.gregtechproxy.addFluid(aMaterial.mName.toLowerCase(), aMaterial.mDefaultLocalName, aMaterial, 2, aMaterial.mGasTemp); + + //TODO + //mOreReRegistrations - Enchantments + /** + * Converts the pre-defined list of SubTags from out material into a list of SubTag names for setting/getting to/from the config. + * Then converts that List of names into a singular string[] for insertion into the config + * If the config string is different from the default, we then want to clear the Materials SubTags and insert new ones from the config string. + */ + List aSubTags = new ArrayList<>(); + for (SubTag aTag : aMaterial.mSubTags) aSubTags.add(aTag.mName); + String aDefaultTagString = aSubTags.toString().replace(" ", "").replace("[", "").replace("]", ""); + String aConfigTagString = GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "ListSubTags", aDefaultTagString); + if (!aConfigTagString.equals(aDefaultTagString)) { + aMaterial.mSubTags.clear(); + if (aConfigTagString.length() > 0) { + aSubTags = new ArrayList<>(Arrays.asList(aConfigTagString.split(","))); + for (String aTagString : aSubTags) { + SubTag aTag = SubTag.sSubTags.get(aTagString); + if (aTag != null) aMaterial.mSubTags.add(aTag); + } + } + } + /** + * Same principal as SubTags + */ + List aOreByProducts = new ArrayList<>(); + for (Materials aMat : aMaterial.mOreByProducts) aOreByProducts.add(aMat.mName); + String aDefaultMaterialString = aOreByProducts.toString().replace(" ", "").replace("[", "").replace("]", ""); + String aConfigMaterialString = GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "ListMaterialByProducts", aDefaultMaterialString); + if (!aConfigMaterialString.equals(aDefaultMaterialString)) { + aMaterial.mOreByProducts.clear(); + if (aConfigMaterialString.length() > 0) { + aOreByProducts = new ArrayList<>(Arrays.asList(aConfigMaterialString.split(","))); + for (String aMaterialString : aOreByProducts) { + Materials aMat = MATERIALS.get(aMaterialString); + if (aMat != null) aMaterial.mOreByProducts.add(aMat); + } + } + } + /** + * Same principal as SubTags + */ List aAspects = new ArrayList<>(); ArrayList aAspectAmounts = new ArrayList<>(); for (TC_Aspects.TC_AspectStack aAspectStack : aMaterial.mAspects) { aAspects.add(aAspectStack.mAspect.toString()); aAspectAmounts.add(String.valueOf(aAspectStack.mAmount)); } - String aAspectsString = GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "TCAspects", aAspects.toString().replace(" ", "").replace("[", "").replace("]", "")); - String aAspectAmountsString = GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "TCAspectAmounts", aAspectAmounts.toString().replace(" ", "").replace("[", "").replace("]", "")); - - aAspects = new ArrayList<>(Arrays.asList(aAspectsString.split(","))); - aAspectAmounts = new ArrayList<>(Arrays.asList(aAspectAmountsString.split(","))); - - for (int x = 0; x < aAspects.size(); x++) { - String str = aAspects.get(x); - if (!str.isEmpty()) { - TC_AspectStack aAspectStack = new TC_AspectStack(TC_Aspects.valueOf(str), Long.parseLong(aAspectAmounts.get(x))); - if (!aMaterial.mAspects.contains(aAspectStack)) aMaterial.mAspects.add(aAspectStack); + String aDefaultAspectString = aAspects.toString().replace(" ", "").replace("[", "").replace("]", ""); + String aDefaultAspectAmountString = aAspectAmounts.toString().replace(" ", "").replace("[", "").replace("]", ""); + String aConfigAspectString = GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "ListTCAspects", aDefaultAspectString); + String aConfigAspectAmountString = GregTech_API.sMaterialProperties.get(aConfigPath.toString(), "ListTCAspectAmounts", aDefaultAspectAmountString); + if (!aConfigAspectString.equals(aDefaultAspectString) || !aConfigAspectAmountString.equals(aDefaultAspectAmountString)) { + aMaterial.mAspects.clear(); + if (aConfigAspectString.length() > 0) { + aAspects = new ArrayList<>(Arrays.asList(aConfigAspectString.split(","))); + for (int i = 0; i < aAspects.size(); i++) { + String aAspectString = aAspects.get(i); + long aAspectAmount = Long.parseLong(aAspectAmounts.get(i)); + TC_AspectStack aAspectStack = new TC_AspectStack(TC_Aspects.valueOf(aAspectString), aAspectAmount); + if (aAspectStack != null) aMaterial.mAspects.add(aAspectStack); + } } } + //End of updating values from the config } + + //Temp code for testing aConfigPath.setLength(0); + StringBuilder sb = new StringBuilder(); + sb.append("##### - ").append(aMaterial.mName).append(": "); + for (SubTag aTag : aMaterial.mSubTags) { + sb.append(aTag.mName).append(","); + } + System.out.println(sb.toString()); } } + public static void initGeneratedMaterials() { + for (Materials aMaterial : MATERIALS.values()) { + if (aMaterial.mMetaItemSubID >= 0) { + if (aMaterial.mMetaItemSubID < 1000) { + if (GregTech_API.sGeneratedMaterials[aMaterial.mMetaItemSubID] == null) { + GregTech_API.sGeneratedMaterials[aMaterial.mMetaItemSubID] = aMaterial; + } else throw new IllegalArgumentException("The Material Index " + aMaterial.mMetaItemSubID + " is already used!"); + } else throw new IllegalArgumentException("The Material Index " + aMaterial.mMetaItemSubID + " is over the maximum of 1000"); + } + } + } public Materials(int aMetaItemSubID, TextureSet aIconSet, float aToolSpeed, int aDurability, int aToolQuality, boolean aUnificatable) { this(aMetaItemSubID, aIconSet, aToolSpeed, aDurability, aToolQuality, aUnificatable, "ore", false, "null"); } public Materials(int aMetaItemSubID, TextureSet aIconSet, float aToolSpeed, int aDurability, int aToolQuality, boolean aUnificatable, String aConfigSection, boolean aCustomOre, String aCustomID) { - VALUES.add(this); - if (aCustomOre) VALUES_CUSTOM.add(this); + mName = mDefaultLocalName.contains(" ") ? mDefaultLocalName.replaceAll(" ", "") : mDefaultLocalName; + MATERIALS.put(mName, this); + if (aCustomOre) MATERIALS_CUSTOM.put(mName, this); mCustomOre = aCustomOre; mCustomID = aCustomID; mConfigSection = aConfigSection; @@ -1348,13 +1418,6 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { mToolQuality = (byte) aToolQuality; mMaterialInto = this; mIconSet = aIconSet; - if (aMetaItemSubID >= 0) { - if (aMetaItemSubID < 1000) { - if (GregTech_API.sGeneratedMaterials[aMetaItemSubID] == null) { - GregTech_API.sGeneratedMaterials[aMetaItemSubID] = this; - } else throw new IllegalArgumentException("The Material Index " + aMetaItemSubID + " is already used!"); - } else throw new IllegalArgumentException("The Material Index " + aMetaItemSubID + " is over the maximum of 1000"); - } } public Materials(Materials aMaterialInto, boolean aReRegisterIntoThis) { @@ -1378,7 +1441,6 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { public Materials(int aMetaItemSubID, TextureSet aIconSet, float aToolSpeed, int aDurability, int aToolQuality, int aTypes, int aR, int aG, int aB, int aA, String aDefaultLocalName, int aFuelType, int aFuelPower, int aMeltingPoint, int aBlastFurnaceTemp, boolean aBlastFurnaceRequired, boolean aTransparent, int aOreValue, int aDensityMultiplier, int aDensityDivider, Dyes aColor, String aConfigSection, boolean aCustomOre, String aCustomID) { this(aMetaItemSubID, aIconSet, aToolSpeed, aDurability, aToolQuality, true, aConfigSection, aCustomOre, aCustomID); mDefaultLocalName = aDefaultLocalName; - mName = mDefaultLocalName.contains(" ") ? mDefaultLocalName.replaceAll(" ", "") : mDefaultLocalName; mMeltingPoint = (short) aMeltingPoint; mBlastFurnaceRequired = aBlastFurnaceRequired; mBlastFurnaceTemp = (short) aBlastFurnaceTemp; diff --git a/src/main/java/gregtech/api/enums/SubTag.java b/src/main/java/gregtech/api/enums/SubTag.java index 90191bf0..7de2176e 100644 --- a/src/main/java/gregtech/api/enums/SubTag.java +++ b/src/main/java/gregtech/api/enums/SubTag.java @@ -3,8 +3,8 @@ package gregtech.api.enums; import gregtech.api.interfaces.ICondition; import gregtech.api.interfaces.ISubTagContainer; -import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; /** @@ -21,7 +21,7 @@ import java.util.HashSet; * Some SubTags are used for other things than Materials too. It is useful when I need an easy way to declare Stuff in Items. */ public final class SubTag implements ICondition { - public static final ArrayList sSubTags = new ArrayList(); + public static final HashMap sSubTags = new HashMap(); private static long sSubtagID = 0; public final long mSubtagID; public final String mName; @@ -231,11 +231,11 @@ public final class SubTag implements ICondition { private SubTag(String aName) { mSubtagID = sSubtagID++; mName = aName; - sSubTags.add(this); + sSubTags.put(aName, this); } public static SubTag getNewSubTag(String aName) { - for (SubTag tSubTag : sSubTags) if (tSubTag.mName.equals(aName)) return tSubTag; + for (SubTag tSubTag : sSubTags.values()) if (tSubTag.mName.equals(aName)) return tSubTag; return new SubTag(aName); } diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index 0a86c911..0cc723f7 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -492,7 +492,7 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { GT_Log.out.println("GT_Mod: Adding Tool Usage Crafting Recipes for OreDict Items."); long tBits = GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.ONLY_ADD_IF_RESULT_IS_NOT_NULL | GT_ModHandler.RecipeBits.NOT_REMOVABLE; - for (Materials aMaterial : Materials.VALUES) { + for (Materials aMaterial : Materials.MATERIALS.values()) { if ((aMaterial.mUnificatable) && (aMaterial.mMaterialInto == aMaterial)) { if (!aMaterial.contains(SubTag.NO_SMASHING)) { if (GregTech_API.sRecipeFile.get(ConfigCategories.Tools.hammerplating, aMaterial.toString(), true)) { diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Ores.java b/src/main/java/gregtech/common/blocks/GT_Block_Ores.java index 66e2f76d..d852aebd 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Ores.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Ores.java @@ -13,7 +13,7 @@ import net.minecraft.init.Blocks; public class GT_Block_Ores extends GT_Block_Ores_Abstract { public GT_Block_Ores() { - super("gt.blockores", 7, false, Material.rock); + super("gt.blockores", 7, Material.rock); } @Override diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Ores_Abstract.java b/src/main/java/gregtech/common/blocks/GT_Block_Ores_Abstract.java index 82ef4f4f..b1cba7aa 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Ores_Abstract.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Ores_Abstract.java @@ -38,7 +38,7 @@ public abstract class GT_Block_Ores_Abstract extends GT_Generic_Block implements public static boolean tHideOres; public static int tOreMetaCount; - protected GT_Block_Ores_Abstract(String aUnlocalizedName, int aOreMetaCount, boolean aHideFirstMeta, Material aMaterial) { + protected GT_Block_Ores_Abstract(String aUnlocalizedName, int aOreMetaCount, Material aMaterial) { super(GT_Item_Ores.class, aUnlocalizedName, aMaterial); this.isBlockContainer = true; setStepSound(soundTypeStone); @@ -58,7 +58,7 @@ public abstract class GT_Block_Ores_Abstract extends GT_Generic_Block implements if ((GregTech_API.sGeneratedMaterials[i].mTypes & 0x8) != 0) { GT_OreDictUnificator.registerOre(this.getProcessingPrefix()[j] != null ? this.getProcessingPrefix()[j].get(GregTech_API.sGeneratedMaterials[i]) : "", new ItemStack(this, 1, i + (j * 1000))); if (tHideOres) { - codechicken.nei.api.API.hideItem(new ItemStack(this, 1, (j == 0 && aHideFirstMeta) ? i : i + (j * 1000))); + if (!aUnlocalizedName.equals("gt.blockores") && !(i + (j * 1000) < 1000)) codechicken.nei.api.API.hideItem(new ItemStack(this, 1, i + (j * 1000))); codechicken.nei.api.API.hideItem(new ItemStack(this, 1, (i + 16000) + (j * 1000))); } } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Ores_GC.java b/src/main/java/gregtech/common/blocks/GT_Block_Ores_GC.java index 23061baa..eddbbda9 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Ores_GC.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Ores_GC.java @@ -15,7 +15,7 @@ public class GT_Block_Ores_GC extends GT_Block_Ores_Abstract { Block aMarsBlock = GameRegistry.findBlock("GalacticraftMars", "tile.mars"); public GT_Block_Ores_GC() { - super("gt.blockores.gc", 4, true, Material.rock); + super("gt.blockores.gc", 4, Material.rock); if (aMoonBlock == null) aMoonBlock = Blocks.stone; if (aMarsBlock == null) aMarsBlock = Blocks.stone; } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB1.java b/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB1.java index ac17e65b..f1089a52 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB1.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB1.java @@ -14,7 +14,7 @@ public class GT_Block_Ores_UB1 extends GT_Block_Ores_Abstract { Block aUBBlock = GameRegistry.findBlock("UndergroundBiomes", "igneousStone"); public GT_Block_Ores_UB1() { - super("gt.blockores.ub1", 8, true, Material.rock); + super("gt.blockores.ub1", 8, Material.rock); if (aUBBlock == null) aUBBlock = Blocks.stone; } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB2.java b/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB2.java index e4caa95d..5306b964 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB2.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB2.java @@ -14,7 +14,7 @@ public class GT_Block_Ores_UB2 extends GT_Block_Ores_Abstract { Block aUBBlock = GameRegistry.findBlock("UndergroundBiomes", "metamorphicStone"); public GT_Block_Ores_UB2() { - super("gt.blockores.ub2", 8, true, Material.rock); + super("gt.blockores.ub2", 8, Material.rock); if (aUBBlock == null) aUBBlock = Blocks.stone; } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB3.java b/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB3.java index 4cf76dfb..6867de10 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB3.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB3.java @@ -14,7 +14,7 @@ public class GT_Block_Ores_UB3 extends GT_Block_Ores_Abstract { Block aUBBlock = GameRegistry.findBlock("UndergroundBiomes", "sedimentaryStone"); public GT_Block_Ores_UB3() { - super("gt.blockores.ub3", 8, true, Material.rock); + super("gt.blockores.ub3", 8, Material.rock); if (aUBBlock == null) aUBBlock = Blocks.stone; } diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Replicator.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Replicator.java index 6f3818b4..13c25ef9 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Replicator.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Replicator.java @@ -84,7 +84,7 @@ public class GT_MetaTileEntity_Replicator public int getCapacity() { if ((sHeaviestElementMass == 0) && (GregTech_API.sPostloadFinished)) { Materials tMaterial; - for (Iterator i$ = Materials.VALUES.iterator(); i$.hasNext(); sHeaviestElementMass = Math.max(sHeaviestElementMass, (int) tMaterial.getMass())) { + for (Iterator i$ = Materials.MATERIALS.values().iterator(); i$.hasNext(); sHeaviestElementMass = Math.max(sHeaviestElementMass, (int) tMaterial.getMass())) { tMaterial = (Materials) i$.next(); if ((tMaterial.mElement == null) || (tMaterial.mElement.mIsIsotope)) { } diff --git a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java index ed641666..b1526664 100644 --- a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java +++ b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java @@ -410,7 +410,7 @@ if(Loader.isModLoaded("Railcraft")){ GT_Values.RA.addFormingPressRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Lazurite, 1L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Glowstone, 1L), ItemList.Circuit_Parts_Advanced.get(2L, new Object[0]), 32, 64); GT_Values.RA.addFormingPressRecipe(ItemList.Food_Dough_Sugar.get(4L, new Object[0]), ItemList.Shape_Mold_Cylinder.get(0L, new Object[0]), ItemList.Food_Raw_Cake.get(1L, new Object[0]), 384, 4); GT_Values.RA.addFormingPressRecipe(new ItemStack(Blocks.glass, 1, 32767), ItemList.Shape_Mold_Arrow.get(0L, new Object[0]), ItemList.Arrow_Head_Glass_Emtpy.get(1L, new Object[0]), 64, 4); - for (Materials tMat : Materials.VALUES) { + for (Materials tMat : Materials.MATERIALS.values()) { if ((tMat.mStandardMoltenFluid != null) && (tMat.contains(SubTag.SOLDERING_MATERIAL))) { int tMultiplier = tMat.contains(SubTag.SOLDERING_MATERIAL_GOOD) ? 1 : tMat.contains(SubTag.SOLDERING_MATERIAL_BAD) ? 4 : 2; diff --git a/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java b/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java index 75f14136..92b458b4 100644 --- a/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java +++ b/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java @@ -462,7 +462,7 @@ public class GT_Loader_Item_Block_And_Fluid GT_Mod.gregtechproxy.addFluid("molten.redstone", "Molten Redstone", Materials.Redstone, 4, 500); GT_Mod.gregtechproxy.addFluid("molten.blaze", "Molten Blaze", Materials.Blaze, 4, 6400); GT_Mod.gregtechproxy.addFluid("molten.concrete", "Wet Concrete", Materials.Concrete, 4, 300); - for (Materials tMaterial : Materials.VALUES) { + for (Materials tMaterial : Materials.MATERIALS.values()) { if ((tMaterial.mStandardMoltenFluid == null) && (tMaterial.contains(SubTag.SMELTING_TO_FLUID)) && (!tMaterial.contains(SubTag.NO_SMELTING))) { GT_Mod.gregtechproxy.addAutogeneratedMoltenFluid(tMaterial); if ((tMaterial.mSmeltInto != tMaterial) && (tMaterial.mSmeltInto.mStandardMoltenFluid == null)) {