diff options
author | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2018-09-13 13:27:29 +1000 |
---|---|---|
committer | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2018-09-13 13:27:29 +1000 |
commit | 84cce1bba9a1091f2428ebee464cbfdf57491def (patch) | |
tree | 5ca4ad0dcee8538c29aab947ef9d0f964d24a6ba /src/Java/gtPlusPlus | |
parent | 7fd2ec38b8d09ef465affb78c5e1c8a32ca7ba3b (diff) | |
download | GT5-Unofficial-84cce1bba9a1091f2428ebee464cbfdf57491def.tar.gz GT5-Unofficial-84cce1bba9a1091f2428ebee464cbfdf57491def.tar.bz2 GT5-Unofficial-84cce1bba9a1091f2428ebee464cbfdf57491def.zip |
+ Added some Average functions to MathUtils.java.
+ Added a Proxy Grabber function to Meta_GT_Proxy.java.
% Tweaked fuel values for Coal Gas & Coal Tar.
$ Fixed issue with Semifluid Fuel generation where none were excluded.
- Removed Logging from material Generation.
Diffstat (limited to 'src/Java/gtPlusPlus')
4 files changed, 123 insertions, 67 deletions
diff --git a/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java b/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java index 80f1828be3..1fb629976a 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java @@ -23,21 +23,21 @@ import net.minecraftforge.fluids.FluidStack; public class CoalTar { - private static Fluid Coal_Gas; - private static Fluid Ethylene; - private static Fluid Benzene; - private static Fluid Ethylbenzene; - private static Fluid Anthracene; - private static Fluid Toluene; - private static Fluid Coal_Tar; - private static Fluid Coal_Tar_Oil; - private static Fluid Sulfuric_Coal_Tar_Oil; - private static Fluid Naphthalene; - private static Fluid Phthalic_Acid; - private static Fluid Ethylanthraquinone2; - private static Fluid Ethylanthrahydroquinone2; - private static Fluid Hydrogen_Peroxide; - private static Fluid Lithium_Peroxide; + public static Fluid Coal_Gas; + public static Fluid Ethylene; + public static Fluid Benzene; + public static Fluid Ethylbenzene; + public static Fluid Anthracene; + public static Fluid Toluene; + public static Fluid Coal_Tar; + public static Fluid Coal_Tar_Oil; + public static Fluid Sulfuric_Coal_Tar_Oil; + public static Fluid Naphthalene; + public static Fluid Phthalic_Acid; + public static Fluid Ethylanthraquinone2; + public static Fluid Ethylanthrahydroquinone2; + public static Fluid Hydrogen_Peroxide; + public static Fluid Lithium_Peroxide; public static void run(){ @@ -105,10 +105,10 @@ public class CoalTar { Lithium_Peroxide = FluidUtils.generateFluidNonMolten("LithiumPeroxide", "Lithium Peroxide", 446, new short[]{135, 135, 135, 100}, null, null); //Burn the coal gas! - GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalGas", 1), null, 64, 1); + GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalGas", 1), null, 96, 1); GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellSulfuricCoalTarOil", 1), null, 32, 3); GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTarOil", 1), null, 64, 3); - GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTar", 1), null, 192, 3); + GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTar", 1), null, 128, 3); createRecipes(); diff --git a/src/Java/gtPlusPlus/core/material/Material.java b/src/Java/gtPlusPlus/core/material/Material.java index cf8ded80e9..7d251c8682 100644 --- a/src/Java/gtPlusPlus/core/material/Material.java +++ b/src/Java/gtPlusPlus/core/material/Material.java @@ -288,11 +288,11 @@ public class Material { this.vChemicalFormula = this.getToolTip(chemicalSymbol, OrePrefixes.dust.mMaterialAmount / M, true); } else if (!this.vChemicalSymbol.equals("")){ - Logger.INFO("materialInput is null, using a valid chemical symbol."); + Logger.WARNING("materialInput is null, using a valid chemical symbol."); this.vChemicalFormula = this.vChemicalSymbol; } else{ - Logger.INFO("MaterialInput == null && chemicalSymbol probably equals nothing"); + Logger.WARNING("MaterialInput == null && chemicalSymbol probably equals nothing"); this.vChemicalFormula = "??"; } @@ -335,13 +335,13 @@ public class Material { } } - Logger.INFO("Creating a Material instance for "+materialName); - Logger.INFO("Formula: "+this.vChemicalFormula + " Smallest Stack: "+this.smallestStackSizeWhenProcessing+" Smallest Ratio:"+ratio); - Logger.INFO("Protons: "+this.vProtons); - Logger.INFO("Neutrons: "+this.vNeutrons); - Logger.INFO("Mass: "+this.vMass+"/units"); - Logger.INFO("Melting Point: "+this.meltingPointC+"C."); - Logger.INFO("Boiling Point: "+this.boilingPointC+"C."); + Logger.WARNING("Creating a Material instance for "+materialName); + Logger.WARNING("Formula: "+this.vChemicalFormula + " Smallest Stack: "+this.smallestStackSizeWhenProcessing+" Smallest Ratio:"+ratio); + Logger.WARNING("Protons: "+this.vProtons); + Logger.WARNING("Neutrons: "+this.vNeutrons); + Logger.WARNING("Mass: "+this.vMass+"/units"); + Logger.WARNING("Melting Point: "+this.meltingPointC+"C."); + Logger.WARNING("Boiling Point: "+this.boilingPointC+"C."); } catch (Throwable t){ t.printStackTrace(); @@ -595,21 +595,21 @@ public class Material { if (this.vMaterialInput != null && !this.vMaterialInput.isEmpty()){ final ItemStack[] temp = new ItemStack[this.vMaterialInput.size()]; for (int i=0;i<this.vMaterialInput.size();i++){ - //Utils.LOG_INFO("i:"+i); + //Utils.LOG_WARNING("i:"+i); ItemStack testNull = null; try { testNull = this.vMaterialInput.get(i).getValidStack(); } catch (final Throwable r){ - Logger.INFO("Failed gathering material stack for "+this.localizedName+"."); - Logger.INFO("What Failed: Length:"+this.vMaterialInput.size()+" current:"+i); + Logger.WARNING("Failed gathering material stack for "+this.localizedName+"."); + Logger.WARNING("What Failed: Length:"+this.vMaterialInput.size()+" current:"+i); } try { if (testNull != null){ - //Utils.LOG_INFO("not null"); + //Utils.LOG_WARNING("not null"); temp[i] = this.vMaterialInput.get(i).getValidStack(); } } catch (final Throwable r){ - Logger.INFO("Failed setting slot "+i+", using "+this.localizedName); + Logger.WARNING("Failed setting slot "+i+", using "+this.localizedName); } } return temp; @@ -659,9 +659,9 @@ public class Material { public final long[] getSmallestRatio(final ArrayList<MaterialStack> tempInput){ if (tempInput != null){ if (!tempInput.isEmpty()){ - Logger.INFO("length: "+tempInput.size()); - Logger.INFO("(inputs != null): "+(tempInput != null)); - //Utils.LOG_INFO("length: "+inputs.length); + Logger.WARNING("length: "+tempInput.size()); + Logger.WARNING("(inputs != null): "+(tempInput != null)); + //Utils.LOG_WARNING("length: "+inputs.length); final long[] tempRatio = new long[tempInput.size()]; for (int x=0;x<tempInput.size();x++){ //tempPercentage = tempPercentage+inputs[x].percentageToUse; @@ -678,7 +678,7 @@ public class Material { for (int r=0;r<tempRatio.length;r++){ tempRatioStringThing1 = tempRatioStringThing1 + tempRatio[r] +" : "; } - Logger.INFO("Default Ratio: "+tempRatioStringThing1); + Logger.WARNING("Default Ratio: "+tempRatioStringThing1); String tempRatioStringThing = ""; int tempSmallestCraftingUseSize = 0; @@ -687,7 +687,7 @@ public class Material { tempSmallestCraftingUseSize = (int) (tempSmallestCraftingUseSize + smallestRatio[r]); } //this.smallestStackSizeWhenProcessing = tempSmallestCraftingUseSize; - Logger.INFO("Smallest Ratio: "+tempRatioStringThing); + Logger.WARNING("Smallest Ratio: "+tempRatioStringThing); return smallestRatio; } } @@ -699,7 +699,7 @@ public class Material { if (!aShowQuestionMarks && (this.vChemicalFormula.equals("?")||this.vChemicalFormula.equals("??"))) { return ""; } - Logger.INFO("===============| Calculating Atomic Formula for "+this.localizedName+" |==============="); + Logger.WARNING("===============| Calculating Atomic Formula for "+this.localizedName+" |==============="); if (!chemSymbol.equals("")) { return chemSymbol; } @@ -742,13 +742,13 @@ public class Material { return StringUtils.subscript(dummyFormula); //return dummyFormula; } - Logger.INFO("dummyFormulaArray <= 0"); + Logger.WARNING("dummyFormulaArray <= 0"); } - Logger.INFO("dummyFormulaArray == null"); + Logger.WARNING("dummyFormulaArray == null"); } - Logger.INFO("tempInput.length <= 0"); + Logger.WARNING("tempInput.length <= 0"); } - Logger.INFO("tempInput == null"); + Logger.WARNING("tempInput == null"); return "??"; } @@ -778,33 +778,33 @@ public class Material { if (isValid != Materials._NULL){ for (Materials m : invalidMaterials.values()){ if (isValid == m){ - Logger.INFO("Trying to generate a fluid for blacklisted material: "+m.mDefaultLocalName); + Logger.WARNING("Trying to generate a fluid for blacklisted material: "+m.mDefaultLocalName); FluidStack a1 = m.getFluid(1); FluidStack a2 = m.getGas(1); FluidStack a3 = m.getMolten(1); FluidStack a4 = m.getSolid(1); FluidStack a5 = m.getPlasma(1); if (a1 != null){ - Logger.INFO("Using a pre-defined Fluid from GT. Fluid."); + Logger.WARNING("Using a pre-defined Fluid from GT. Fluid."); return a1.getFluid(); } if (a2 != null){ - Logger.INFO("Using a pre-defined Fluid from GT. Gas."); + Logger.WARNING("Using a pre-defined Fluid from GT. Gas."); return a2.getFluid(); } if (a3 != null){ - Logger.INFO("Using a pre-defined Fluid from GT. Molten."); + Logger.WARNING("Using a pre-defined Fluid from GT. Molten."); return a3.getFluid(); } if (a4 != null){ - Logger.INFO("Using a pre-defined Fluid from GT. Solid."); + Logger.WARNING("Using a pre-defined Fluid from GT. Solid."); return a4.getFluid(); } if (a5 != null){ - Logger.INFO("Using a pre-defined Fluid from GT. Plasma."); + Logger.WARNING("Using a pre-defined Fluid from GT. Plasma."); return a5.getFluid(); } - Logger.INFO("Using null."); + Logger.WARNING("Using null."); return null; } } @@ -812,31 +812,31 @@ public class Material { if (this.materialState == MaterialState.SOLID){ if (isValid.mFluid != null){ - Logger.INFO("Using a pre-defined Fluid from GT. mFluid."); + Logger.WARNING("Using a pre-defined Fluid from GT. mFluid."); return isValid.mFluid; } else if (isValid.mStandardMoltenFluid != null){ - Logger.INFO("Using a pre-defined Fluid from GT. mStandardMoltenFluid."); + Logger.WARNING("Using a pre-defined Fluid from GT. mStandardMoltenFluid."); return isValid.mStandardMoltenFluid; } } else if (this.materialState == MaterialState.GAS){ if (isValid.mGas != null){ - Logger.INFO("Using a pre-defined Fluid from GT. mGas."); + Logger.WARNING("Using a pre-defined Fluid from GT. mGas."); return isValid.mGas; } } else if (this.materialState == MaterialState.LIQUID || this.materialState == MaterialState.PURE_LIQUID){ if (isValid.mFluid != null){ - Logger.INFO("Using a pre-defined Fluid from GT. mFluid."); + Logger.WARNING("Using a pre-defined Fluid from GT. mFluid."); return isValid.mFluid; } else if (isValid.mGas != null){ - Logger.INFO("Using a pre-defined Fluid from GT. mGas."); + Logger.WARNING("Using a pre-defined Fluid from GT. mGas."); return isValid.mGas; } else if (isValid.mStandardMoltenFluid != null){ - Logger.INFO("Using a pre-defined Fluid from GT. mStandardMoltenFluid."); + Logger.WARNING("Using a pre-defined Fluid from GT. mStandardMoltenFluid."); return isValid.mStandardMoltenFluid; } } @@ -846,28 +846,28 @@ public class Material { FluidStack aTest3 = FluidUtils.getFluidStack(Utils.sanitizeString(this.getLocalizedName()), 1); if (aTest1 != null) { - Logger.INFO("Found FluidRegistry entry for "+"molten."+Utils.sanitizeString(this.getLocalizedName())); + Logger.WARNING("Found FluidRegistry entry for "+"molten."+Utils.sanitizeString(this.getLocalizedName())); return aTest1.getFluid(); } if (aTest2 != null) { - Logger.INFO("Found FluidRegistry entry for "+"fluid."+Utils.sanitizeString(this.getLocalizedName())); + Logger.WARNING("Found FluidRegistry entry for "+"fluid."+Utils.sanitizeString(this.getLocalizedName())); return aTest2.getFluid(); } if (aTest3 != null) { - Logger.INFO("Found FluidRegistry entry for "+Utils.sanitizeString(this.getLocalizedName())); + Logger.WARNING("Found FluidRegistry entry for "+Utils.sanitizeString(this.getLocalizedName())); return aTest3.getFluid(); } - Logger.INFO("Generating our own fluid."); + Logger.WARNING("Generating our own fluid."); //Generate a Cell if we need to if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+this.getUnlocalizedName(), 1) == null){ if (this.vGenerateCells){ new BaseItemCell(this); - Logger.INFO("Generated a cell for "+this.getUnlocalizedName()); + Logger.WARNING("Generated a cell for "+this.getUnlocalizedName()); } else { - Logger.INFO("Did not generate a cell for "+this.getUnlocalizedName()); + Logger.WARNING("Did not generate a cell for "+this.getUnlocalizedName()); } } @@ -924,11 +924,11 @@ public class Material { } } if (isValid.mPlasma != null){ - Logger.INFO("Using a pre-defined Plasma from GT."); + Logger.WARNING("Using a pre-defined Plasma from GT."); return isValid.mPlasma; } - Logger.INFO("Generating our own Plasma."); + Logger.WARNING("Generating our own Plasma."); return FluidUtils.addGTPlasma(this); } @@ -950,14 +950,14 @@ public class Material { if (part != null){ int incrementor = part.getStackMaterial().getMeltingPointC(); meltingPoint += incrementor; - Logger.INFO("Melting Point for "+this.getLocalizedName()+" increased by "+ incrementor); + Logger.WARNING("Melting Point for "+this.getLocalizedName()+" increased by "+ incrementor); } else { Logger.MATERIALS(this.getLocalizedName()+" has a really invalid composition."); } } int divisor = (this.vMaterialInput.size()>0 ? this.vMaterialInput.size() : 1); - Logger.INFO("Dividing "+meltingPoint+" / "+divisor+" to get average melting point."); + Logger.WARNING("Dividing "+meltingPoint+" / "+divisor+" to get average melting point."); meltingPoint = (meltingPoint/divisor); return meltingPoint; } @@ -972,7 +972,7 @@ public class Material { for (MaterialStack part : this.vMaterialInput){ if (part != null){ boilingPoint += part.getStackMaterial().getBoilingPointC(); - Logger.INFO("Boiling Point for "+this.getLocalizedName()+" increased by "+ part.getStackMaterial().getBoilingPointC()); + Logger.WARNING("Boiling Point for "+this.getLocalizedName()+" increased by "+ part.getStackMaterial().getBoilingPointC()); } else { Logger.MATERIALS(this.getLocalizedName()+" has a really invalid composition."); diff --git a/src/Java/gtPlusPlus/core/util/math/MathUtils.java b/src/Java/gtPlusPlus/core/util/math/MathUtils.java index cda463ff10..7ec898ce3a 100644 --- a/src/Java/gtPlusPlus/core/util/math/MathUtils.java +++ b/src/Java/gtPlusPlus/core/util/math/MathUtils.java @@ -6,6 +6,7 @@ import java.util.Random; import gregtech.api.enums.GT_Values; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; @@ -374,5 +375,23 @@ public class MathUtils { return mLargeChanceArray[randInt(0, mLargeChanceArray.length-1)]; } + + public static long getAverage(AutoMap aDataSet) { + long[] aNewSet = new long[aDataSet.size()]; + for (int u=0;u<aDataSet.size();u++) { + aNewSet[u] = (long) aDataSet.get(u); + } + return getAverage(aNewSet); + } + + public static long getAverage(long[] aDataSet) { + int divisor = aDataSet.length; + long total = 0; + for (long i : aDataSet) { + total += i; + } + long result = (total/divisor); + return result; + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java index 4c9e6c129c..6881c900b5 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java @@ -2,6 +2,7 @@ package gtPlusPlus.xmod.gregtech.common; import static gtPlusPlus.xmod.gregtech.common.covers.GTPP_Cover_Overflow.mOverflowCache; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -12,11 +13,13 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; - +import gregtech.GT_Mod; import gregtech.api.GregTech_API; - +import gregtech.common.GT_Proxy; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.ObjMap; +import gtPlusPlus.core.util.reflect.ProxyFinder; +import gtPlusPlus.core.util.reflect.ReflectionUtils; public class Meta_GT_Proxy { @@ -82,5 +85,39 @@ public class Meta_GT_Proxy { } return aRemoved; } + + + private static GT_Proxy[] mProxies = new GT_Proxy[2]; + + public static Object getFieldFromGregtechProxy(boolean client, String fieldName) { + Object proxyGT; + + if (mProxies[0] != null && client) { + proxyGT = mProxies[0]; + } else if (mProxies[1] != null && !client) { + proxyGT = mProxies[1]; + } else { + try { + proxyGT = (client ? ProxyFinder.getClientProxy(GT_Mod.instance) + : ProxyFinder.getServerProxy(GT_Mod.instance)); + } catch (final ReflectiveOperationException e1) { + proxyGT = null; + Logger.INFO("Failed to obtain instance of GT " + (client ? "Client" : "Server") + " proxy."); + } + if (mProxies[0] == null && client) { + mProxies[0] = (GT_Proxy) proxyGT; + } else if (mProxies[1] == null && !client) { + mProxies[1] = (GT_Proxy) proxyGT; + } + } + + if (proxyGT != null && proxyGT instanceof GT_Proxy) { + try { + return ReflectionUtils.getField(proxyGT.getClass(), fieldName).get(proxyGT); + } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + } + } + return null; + } } |