diff options
author | Draknyte1 <Draknyte1@hotmail.com> | 2016-10-23 20:32:22 +1000 |
---|---|---|
committer | Draknyte1 <Draknyte1@hotmail.com> | 2016-10-23 20:32:22 +1000 |
commit | 4e22125d6ddc878853cc3cadcec272a1a92e5135 (patch) | |
tree | bfab2239a40f54937ab7443e4f8ed896b37516da /src/Java/gtPlusPlus | |
parent | 6754387bca14ef3c2bdc5e69d0f4920ca7568553 (diff) | |
download | GT5-Unofficial-4e22125d6ddc878853cc3cadcec272a1a92e5135.tar.gz GT5-Unofficial-4e22125d6ddc878853cc3cadcec272a1a92e5135.tar.bz2 GT5-Unofficial-4e22125d6ddc878853cc3cadcec272a1a92e5135.zip |
- Disabled generation of Deci/Centi dusts for now.
+ Added a check for Growthcraft versioning, newer versions past 2.3.1 will not have extra support loaded.
+ Improved Chemical Compound tooltip generation on dusts.
Diffstat (limited to 'src/Java/gtPlusPlus')
9 files changed, 162 insertions, 82 deletions
diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index 74ea3ed4d3..1a407e1fc6 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -279,8 +279,8 @@ public final class ModItems { for (Materials m : rm){ MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, m); MS_GTMATERIAL = UtilsItems.generateMultiShovel(gtStyleTools, m); - itemBaseDecidust = UtilsItems.generateDecidust(m); - itemBaseCentidust = UtilsItems.generateCentidust(m); + /*itemBaseDecidust = UtilsItems.generateDecidust(m); + itemBaseCentidust = UtilsItems.generateCentidust(m);*/ } //EnderIO Resources diff --git a/src/Java/gtPlusPlus/core/lib/LoadedMods.java b/src/Java/gtPlusPlus/core/lib/LoadedMods.java index ad7ab7b2c9..1585fe06b3 100644 --- a/src/Java/gtPlusPlus/core/lib/LoadedMods.java +++ b/src/Java/gtPlusPlus/core/lib/LoadedMods.java @@ -119,9 +119,17 @@ public class LoadedMods { totalMods++; } if (Loader.isModLoaded("Growthcraft") == true){ - Growthcraft = true; - Utils.LOG_INFO("Components enabled for: Growthcraft"); - totalMods++; + Utils.LOG_INFO("Growthcraft Version: "+getModVersion("Growthcraft")); + if (getModVersion("Growthcraft").equals("1.7.10-2.3.1")){ + //Load Growthcraft Compat + Growthcraft = true; + Utils.LOG_INFO("Components enabled for: Growthcraft"); + totalMods++; + } + else { + Growthcraft = false; + Utils.LOG_INFO("Growthcraft found, but the version was too new. I will update GC support eventually."); + } } if (Loader.isModLoaded("CoFHCore") == true){ CoFHCore = true; diff --git a/src/Java/gtPlusPlus/core/material/ELEMENT.java b/src/Java/gtPlusPlus/core/material/ELEMENT.java index 9c05e53165..f4eb12ec46 100644 --- a/src/Java/gtPlusPlus/core/material/ELEMENT.java +++ b/src/Java/gtPlusPlus/core/material/ELEMENT.java @@ -79,7 +79,7 @@ public final class ELEMENT { public static final Material THORIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Thorium); public static final Material URANIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Uranium); public static final Material PLUTONIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Plutonium); - public static final Material URANIUM233 = new Material("Uranium-233", new short[]{73, 220, 83, 0}, 1132, 4131, 92, 141, false, null, MaterialUtils.superscript("233U"), 0);//Not a GT Inherited Material + public static final Material URANIUM233 = new Material("Uranium-233", new short[]{73, 220, 83, 0}, 1132, 4131, 92, 141, false, null, MaterialUtils.superscript("233U"), 2);//Not a GT Inherited Material } diff --git a/src/Java/gtPlusPlus/core/material/Material.java b/src/Java/gtPlusPlus/core/material/Material.java index 27a9f53ced..db83799039 100644 --- a/src/Java/gtPlusPlus/core/material/Material.java +++ b/src/Java/gtPlusPlus/core/material/Material.java @@ -1,18 +1,25 @@ package gtPlusPlus.core.material; +import static gregtech.api.enums.GT_Values.M; +import gregtech.api.enums.OrePrefixes; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.item.UtilsItems; import gtPlusPlus.core.util.math.MathUtils; + +import java.util.ArrayList; +import java.util.List; + import net.minecraft.item.ItemStack; public class Material { final String unlocalizedName; final String localizedName; - + protected Object dataVar; private MaterialStack[] materialInput = new MaterialStack[4]; + final List<MaterialStack> mMaterialList = new ArrayList<MaterialStack>(); final short[] RGBA; @@ -30,16 +37,17 @@ public class Material { public final int vTier; public final int vVoltageMultiplier; public final String vChemicalFormula; + public final String vChemicalSymbol; public Material(String materialName, short[] rgba, int meltingPoint, int boilingPoint, long protons, long neutrons, boolean blastFurnace, MaterialStack[] inputs){ this(materialName, rgba, meltingPoint, boilingPoint, protons, neutrons, blastFurnace, inputs, "", 0); } - + public Material(String materialName, short[] rgba, int meltingPoint, int boilingPoint, long protons, long neutrons, boolean blastFurnace, MaterialStack[] inputs, int radiationLevel){ this(materialName, rgba, meltingPoint, boilingPoint, protons, neutrons, blastFurnace, inputs, "", radiationLevel); } - public Material(String materialName, short[] rgba, int meltingPoint, int boilingPoint, long protons, long neutrons, boolean blastFurnace, MaterialStack[] inputs, String chemicalFormula, int radiationLevel){ + public Material(String materialName, short[] rgba, int meltingPoint, int boilingPoint, long protons, long neutrons, boolean blastFurnace, MaterialStack[] inputs, String chemicalSymbol, int radiationLevel){ this.unlocalizedName = Utils.sanitizeString(materialName); this.localizedName = materialName; @@ -54,13 +62,19 @@ public class Material { this.vProtons = protons; this.vNeutrons = neutrons; this.vMass = getMass(); - if (chemicalFormula.equals("")){ - this.vChemicalFormula = getChemicalFormula(inputs); - } - else{ - this.vChemicalFormula = chemicalFormula; + + //List<MaterialStack> inputArray = Arrays.asList(inputs); + if (inputs != null){ + if (inputs.length != 0){ + for (int x=0;x<inputs.length;x++) + this.mMaterialList.add(inputs[x]); + } } - + + + this.vChemicalSymbol = chemicalSymbol; + this.vChemicalFormula = getToolTip(chemicalSymbol, OrePrefixes.dust.mMaterialAmount / M, true); + if (radiationLevel != 0){ this.isRadioactive = true; this.vRadioationLevel = (byte) radiationLevel; @@ -119,10 +133,11 @@ public class Material { } } } - + dataVar = MathUtils.generateSingularRandomHexValue(); - + Utils.LOG_INFO("Creating a Material instance for "+materialName); + Utils.LOG_INFO("Formula: "+vChemicalFormula); Utils.LOG_INFO("Protons: "+vProtons); Utils.LOG_INFO("Neutrons: "+vNeutrons); Utils.LOG_INFO("Mass: "+vMass+"/units"); @@ -143,7 +158,7 @@ public class Material { } public int getRgbAsHex(){ - + int returnValue = Utils.rgbtoHexValue(RGBA[0], RGBA[1], RGBA[2]); if (returnValue == 0){ return (int) dataVar; @@ -218,27 +233,27 @@ public class Material { public ItemStack getRod(int stacksize){ return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("stick"+unlocalizedName, stacksize); } - + public ItemStack getLongRod(int stacksize){ return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("stickLong"+unlocalizedName, stacksize); } - + public ItemStack getBolt(int stacksize){ return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("bolt"+unlocalizedName, stacksize); } - + public ItemStack getScrew(int stacksize){ return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("screw"+unlocalizedName, stacksize); } - + public ItemStack getRing(int stacksize){ return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("ring"+unlocalizedName, stacksize); } - + public ItemStack getRotor(int stacksize){ return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("rotor"+unlocalizedName, stacksize); } - + public ItemStack getFrameBox(int stacksize){ return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("frameGt"+unlocalizedName, stacksize); } @@ -284,19 +299,19 @@ public class Material { -private int getInputMaterialCount(MaterialStack[] materialInput){ - int i = 0; - for (int r=0;r<4;r++){ - try { - if (!materialInput[r].equals(null)){ - i++; + private int getInputMaterialCount(MaterialStack[] materialInput){ + int i = 0; + for (int r=0;r<4;r++){ + try { + if (!materialInput[r].equals(null)){ + i++; + } + } catch(Throwable x){ + return i; } - } catch(Throwable x){ - return i; } + return i; } - return i; -} public String getChemicalFormula(MaterialStack[] materialInput){ @@ -306,8 +321,8 @@ private int getInputMaterialCount(MaterialStack[] materialInput){ for (int i=0;i<f;i++){ try { if (materialInput[i] != null){ - formulaComponents[i] = materialInput[i].stackMaterial.vChemicalFormula; - Utils.LOG_INFO("LOOK AT ME IN THE LOG - " + formulaComponents[i]); + formulaComponents[i] = materialInput[i].stackMaterial.vChemicalFormula; + Utils.LOG_INFO("LOOK AT ME IN THE LOG - " + formulaComponents[i]); } else{ Utils.LOG_INFO("LOOK AT ME IN THE LOG - materialInput[i] was null"); @@ -332,6 +347,36 @@ private int getInputMaterialCount(MaterialStack[] materialInput){ } + public String getToolTip(String chemSymbol, long aMultiplier, boolean aShowQuestionMarks) { + if (!aShowQuestionMarks && (vChemicalFormula.equals("?")||vChemicalFormula.equals("??"))) return ""; + + Utils.LOG_INFO("===============| Calculating Atomic Formula for "+this.localizedName+" |==============="); + Utils.LOG_INFO("aMultiplier: "+aMultiplier); + Utils.LOG_INFO("aMultiplier >= M * 2: "+aMultiplier+" >= "+M * 2); + Utils.LOG_INFO("aMultiplier >= M * 2: "+(aMultiplier >= M * 2)); + Utils.LOG_INFO("!mMaterialList.isEmpty(): "+!mMaterialList.isEmpty()); + Utils.LOG_INFO("mMaterialList.size(): "+mMaterialList.size()); + Utils.LOG_INFO("mMaterialList.size() < 2: "+(mMaterialList.size() < 2)); + if (mMaterialList.size() != 0) + Utils.LOG_INFO("mMaterialList.get(0).vAmount: "+mMaterialList.get(0).vAmount); + if (mMaterialList.size() != 0) + Utils.LOG_INFO("mMaterialList.get(0).vAmount == 1: "+(mMaterialList.get(0).vAmount==1)); + Utils.LOG_INFO("===============| Finished Calculating data for "+this.localizedName+" |==============="); + Utils.LOG_INFO(""); + + if (aMultiplier >= M * 2 && !mMaterialList.isEmpty()) { + if(((chemSymbol != null && !chemSymbol.equals("")) || (mMaterialList.size() < 2 && mMaterialList.get(0).vAmount == 1))){ + return vChemicalFormula + aMultiplier; + } + return "(" + vChemicalFormula + ")" + aMultiplier; + } + if (!chemSymbol.equals("")) + return chemSymbol; + return "??"; + + } + + diff --git a/src/Java/gtPlusPlus/core/material/MaterialStack.java b/src/Java/gtPlusPlus/core/material/MaterialStack.java index 3682b73cfe..5e076e6e70 100644 --- a/src/Java/gtPlusPlus/core/material/MaterialStack.java +++ b/src/Java/gtPlusPlus/core/material/MaterialStack.java @@ -5,6 +5,7 @@ import net.minecraft.item.ItemStack; public class MaterialStack { + final int vAmount; final Material stackMaterial; final double percentageToUse; @@ -12,6 +13,7 @@ public class MaterialStack { this.stackMaterial = inputs; this.percentageToUse = percentage; + this.vAmount = getDustCount(); } @@ -60,6 +62,26 @@ public class MaterialStack { } + public int getDustCount(){ + int amount = 0; + if (percentageToUse >= 0 && percentageToUse <= 0.99){ + amount = (int) (1/percentageToUse); + } + else if (percentageToUse >= 1 && percentageToUse <= 9.99){ + amount = (int) (percentageToUse); + } + else if (percentageToUse >= 10 && percentageToUse <= 99.99){ + amount = (int) (percentageToUse/10); + } + else if (percentageToUse == 100){ + amount = 10; + } + else { + amount = 0; + } + return amount; + } + public ItemStack[] getValidItemStacks(){ return UtilsItems.validItemsForOreDict(stackMaterial.unlocalizedName); } diff --git a/src/Java/gtPlusPlus/core/util/materials/MaterialUtils.java b/src/Java/gtPlusPlus/core/util/materials/MaterialUtils.java index 61171e3688..52e925df0e 100644 --- a/src/Java/gtPlusPlus/core/util/materials/MaterialUtils.java +++ b/src/Java/gtPlusPlus/core/util/materials/MaterialUtils.java @@ -60,6 +60,8 @@ public class MaterialUtils { radioactivity = 1; } if (hasValidRGBA(rgba)){ + //ModItems.itemBaseDecidust = UtilsItems.generateDecidust(material); + //ModItems.itemBaseCentidust = UtilsItems.generateCentidust(material); return new Material(name, rgba, melting, boiling, protons, neutrons, blastFurnace, null, chemicalFormula, radioactivity); } return null; diff --git a/src/Java/gtPlusPlus/core/util/recipe/UtilsRecipe.java b/src/Java/gtPlusPlus/core/util/recipe/UtilsRecipe.java index 624bde2ead..ee582c0646 100644 --- a/src/Java/gtPlusPlus/core/util/recipe/UtilsRecipe.java +++ b/src/Java/gtPlusPlus/core/util/recipe/UtilsRecipe.java @@ -23,7 +23,7 @@ import cpw.mods.fml.common.registry.GameRegistry; public class UtilsRecipe { - public static void recipeBuilder(Object slot_1, Object slot_2, Object slot_3, Object slot_4, Object slot_5, Object slot_6, Object slot_7, Object slot_8, Object slot_9, ItemStack resultItem){ + public static boolean recipeBuilder(Object slot_1, Object slot_2, Object slot_3, Object slot_4, Object slot_5, Object slot_6, Object slot_7, Object slot_8, Object slot_9, ItemStack resultItem){ ArrayList<Object> validSlots = new ArrayList<Object>(); @@ -108,6 +108,7 @@ public class UtilsRecipe { else { LateRegistrationHandler.recipesSuccess++; } + return true; } catch(NullPointerException | ClassCastException k){ k.getMessage(); @@ -120,7 +121,8 @@ public class UtilsRecipe { } else { LateRegistrationHandler.recipesFailed++; - } + } + return false; } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Plates.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Plates.java index 40895b8c86..b125122cb3 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Plates.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Plates.java @@ -3,7 +3,6 @@ package gtPlusPlus.xmod.gregtech.loaders; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; -import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.Utils; @@ -80,41 +79,7 @@ public class RecipeGen_Plates { } else { Utils.LOG_INFO("Bender Recipe: "+material.getLocalizedName()+" - Failed"); - } - - - Utils.LOG_INFO("Adding crafting recipes for "+material.getLocalizedName()+" Plates - Single & Double"); - - //Single Plate Shaped/Shapeless - GT_ModHandler.addCraftingRecipe( - plate_Single, - gregtech.api.util.GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | gregtech.api.util.GT_ModHandler.RecipeBits.BUFFERED, - new Object[]{"h", "B", "I", - Character.valueOf('I'), - ingotStackOne, - Character.valueOf('B'), - ingotStackOne}); - - GT_ModHandler.addShapelessCraftingRecipe( - plate_Single, - new Object[]{gregtech.api.enums.ToolDictNames.craftingToolForgeHammer, - ingotStackOne, - ingotStackOne}); - - //Double Plate Shaped/Shapeless - GT_ModHandler.addCraftingRecipe( - plate_Double, - gregtech.api.util.GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | gregtech.api.util.GT_ModHandler.RecipeBits.BUFFERED, - new Object[]{"I", "B", "h", - Character.valueOf('I'), - plate_Single, - Character.valueOf('B'), - plate_Single}); - GT_ModHandler.addShapelessCraftingRecipe( - plate_Double, - new Object[]{gregtech.api.enums.ToolDictNames.craftingToolForgeHammer, - plate_Single, - plate_Single}); + } } public static boolean addBenderRecipe(ItemStack aInput1, ItemStack aOutput1, int aDuration, int aEUt) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_ShapedCrafting.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_ShapedCrafting.java index 4f749005d5..65eb280c2f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_ShapedCrafting.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_ShapedCrafting.java @@ -1,5 +1,6 @@ package gtPlusPlus.xmod.gregtech.loaders; +import gregtech.api.util.GT_ModHandler; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.recipe.UtilsRecipe; @@ -9,9 +10,44 @@ public class RecipeGen_ShapedCrafting { public static void generateRecipes(Material material){ Utils.LOG_INFO("Generating Shaped Crafting recipes for "+material.getLocalizedName()); //TODO + + //Plates + + //Single Plate Shaped/Shapeless + GT_ModHandler.addCraftingRecipe( + material.getPlate(1), + gregtech.api.util.GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | gregtech.api.util.GT_ModHandler.RecipeBits.BUFFERED, + new Object[]{"h", "B", "I", + Character.valueOf('I'), + material.getIngot(1), + Character.valueOf('B'), + material.getIngot(1)}); + + GT_ModHandler.addShapelessCraftingRecipe( + material.getPlate(1), + new Object[]{gregtech.api.enums.ToolDictNames.craftingToolForgeHammer, + material.getIngot(1), + material.getIngot(1)}); + + //Double Plate Shaped/Shapeless + GT_ModHandler.addCraftingRecipe( + material.getPlateDouble(1), + gregtech.api.util.GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | gregtech.api.util.GT_ModHandler.RecipeBits.BUFFERED, + new Object[]{"I", "B", "h", + Character.valueOf('I'), + material.getPlate(1), + Character.valueOf('B'), + material.getPlate(1)}); + + GT_ModHandler.addShapelessCraftingRecipe( + material.getPlateDouble(1), + new Object[]{gregtech.api.enums.ToolDictNames.craftingToolForgeHammer, + material.getPlate(1), + material.getPlate(1)}); + //Ring Recipe if (!material.isRadioactive){ - if (UtilsRecipe.addShapedGregtechRecipe( + if (UtilsRecipe.recipeBuilder( "craftingToolWrench", null, null, null, material.getRod(1), null, null, null, null, @@ -26,7 +62,7 @@ public class RecipeGen_ShapedCrafting { //Framebox Recipe if (!material.isRadioactive){ ItemStack stackStick = material.getRod(1); - if (UtilsRecipe.addShapedGregtechRecipe( + if (UtilsRecipe.recipeBuilder( stackStick, stackStick, stackStick, stackStick, "craftingToolWrench", stackStick, stackStick, stackStick, stackStick, @@ -40,7 +76,7 @@ public class RecipeGen_ShapedCrafting { //Shaped Recipe - Bolts if (!material.isRadioactive){ - if (UtilsRecipe.addShapedGregtechRecipe( + if (UtilsRecipe.recipeBuilder( "craftingToolSaw", null, null, null, material.getRod(1), null, null, null, null, @@ -54,7 +90,7 @@ public class RecipeGen_ShapedCrafting { //Shaped Recipe - Ingot to Rod - if (UtilsRecipe.addShapedGregtechRecipe( + if (UtilsRecipe.recipeBuilder( "craftingToolFile", null, null, null, material.getIngot(1), null, null, null, null, @@ -67,7 +103,7 @@ public class RecipeGen_ShapedCrafting { //Shaped Recipe - Long Rod to two smalls - if (UtilsRecipe.addShapedGregtechRecipe( + if (UtilsRecipe.recipeBuilder( "craftingToolSaw", null, null, material.getLongRod(1), null, null, null, null, null, @@ -79,7 +115,7 @@ public class RecipeGen_ShapedCrafting { } //Two small to long rod - if (UtilsRecipe.addShapedGregtechRecipe( + if (UtilsRecipe.recipeBuilder( material.getRod(1), "craftingToolHardHammer", material.getRod(1), null, null, null, null, null, null, @@ -92,7 +128,7 @@ public class RecipeGen_ShapedCrafting { //Rotor Recipe if (!material.isRadioactive){ - if (UtilsRecipe.addShapedGregtechRecipe( + if (UtilsRecipe.recipeBuilder( material.getPlate(1), "craftingToolHardHammer", material.getPlate(1), material.getScrew(1), material.getRing(1), "craftingToolFile", material.getPlate(1), "craftingToolScrewdriver", material.getPlate(1), @@ -106,7 +142,7 @@ public class RecipeGen_ShapedCrafting { //Screws if (!material.isRadioactive){ - if (UtilsRecipe.addShapedGregtechRecipe( + if (UtilsRecipe.recipeBuilder( "craftingToolFile", material.getBolt(1), null, material.getBolt(1), null, null, null, null, null, |