From 84cce1bba9a1091f2428ebee464cbfdf57491def Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 13 Sep 2018 13:27:29 +1000 Subject: + 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. --- .../gregtech/api/util/SemiFluidFuelHandler.java | 60 ++++++++++++-- .../gtPlusPlus/core/item/chemistry/CoalTar.java | 34 ++++---- src/Java/gtPlusPlus/core/material/Material.java | 96 +++++++++++----------- src/Java/gtPlusPlus/core/util/math/MathUtils.java | 19 +++++ .../xmod/gregtech/common/Meta_GT_Proxy.java | 41 ++++++++- 5 files changed, 174 insertions(+), 76 deletions(-) (limited to 'src') diff --git a/src/Java/gregtech/api/util/SemiFluidFuelHandler.java b/src/Java/gregtech/api/util/SemiFluidFuelHandler.java index c7e73478e8..f1c56c4e95 100644 --- a/src/Java/gregtech/api/util/SemiFluidFuelHandler.java +++ b/src/Java/gregtech/api/util/SemiFluidFuelHandler.java @@ -1,28 +1,70 @@ package gregtech.api.util; -import gregtech.api.util.Recipe_GT.*; +import static gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map.sSemiFluidLiquidFuels; + +import java.util.HashMap; + import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.util.minecraft.FluidUtils; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; public class SemiFluidFuelHandler { public static boolean generateFuels() { final FluidStack aCreosote = FluidUtils.getFluidStack("creosote", 1000); + final FluidStack aHeavyFuel = FluidUtils.getFluidStack("liquid_heavy_fuel", 1000); + final HashMap> aFoundFluidsFromItems = new HashMap>(); + // Find Fluids From items for (GT_Recipe g : gregtech.api.util.GT_Recipe.GT_Recipe_Map.sDenseLiquidFuels.mRecipeList) { - if (g != null && g.mEnabled && g.mFluidInputs[0] != null) { + if (g != null && g.mEnabled && g.mInputs.length > 0 && g.mInputs[0] != null) { + for (ItemStack i : g.mInputs) { + FluidStack f = FluidContainerRegistry.getFluidForFilledItem(i); + if (f != null) { + Pair aData = new Pair(f, g.mSpecialValue); + aFoundFluidsFromItems.put(aData.hashCode(), aData); + } + } + } else if (g != null && g.mEnabled && g.mFluidInputs.length > 0 && g.mFluidInputs[0] != null) { boolean aContainsCreosote = false; for (FluidStack f : g.mFluidInputs) { if (f.isFluidEqual(aCreosote)) { aContainsCreosote = true; } - } - g.mSpecialValue *= aContainsCreosote ? 8 : 4; - Logger.INFO("Added "+g.mFluidInputs[0]+" to the Semi-Fluid Generator fuel map."); - Gregtech_Recipe_Map.sSemiFluidLiquidFuels.add(g); + } + g.mSpecialValue *= aContainsCreosote ? 8 : 4; + Logger.INFO("Added " + g.mFluidInputs[0].getLocalizedName() + " to the Semi-Fluid Generator fuel map. Fuel Produces "+g.mSpecialValue+"EU per 1000L."); + sSemiFluidLiquidFuels.add(g); } - } - return Gregtech_Recipe_Map.sSemiFluidLiquidFuels.mRecipeList.size() > 0; + } + for (Pair p : aFoundFluidsFromItems.values()) { + if (p != null) { + int aFuelValue = p.getValue(); + if (p.getKey().isFluidEqual(aCreosote)) { + aFuelValue *= 8; + } + else if (p.getKey().isFluidEqual(aHeavyFuel)){ + aFuelValue *= 1.5; + } + else { + aFuelValue *= 2; + } + + if (aFuelValue <= (128*3)) { + GT_Recipe aRecipe = new Recipe_GT(true, new ItemStack[] {}, new ItemStack[] {}, null, new int[] {}, + new FluidStack[] { p.getKey() }, null, 0, 0, aFuelValue); + if (aRecipe.mSpecialValue > 0) { + Logger.INFO("Added " + aRecipe.mFluidInputs[0].getLocalizedName() + " to the Semi-Fluid Generator fuel map. Fuel Produces "+(aRecipe.mSpecialValue*1000)+"EU per 1000L."); + sSemiFluidLiquidFuels.add(aRecipe); + } + } else { + Logger.INFO("Boosted Fuel value for " + p.getKey().getLocalizedName() + " exceeds 512k, ignoring."); + } + } + } + return sSemiFluidLiquidFuels.mRecipeList.size() > 0; } - + } 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 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;x0 ? 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