package gtPlusPlus.core.material; import static gregtech.api.enums.GT_Values.M; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gtPlusPlus.core.item.base.cell.BaseItemCell; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.materials.MaterialUtils; import gtPlusPlus.core.util.math.MathUtils; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; public class Material { final String unlocalizedName; final String localizedName; final Fluid vMoltenFluid; protected Object dataVar; private MaterialStack[] vMaterialInput = new MaterialStack[9]; public final long[] vSmallestRatio; final short[] RGBA; final boolean usesBlastFurnace; public final boolean isRadioactive; public final byte vRadioationLevel; final int meltingPointK; final int boilingPointK; final int meltingPointC; final int boilingPointC; final long vProtons; final long vNeutrons; final long vMass; public final int smallestStackSizeWhenProcessing; //Add a check for <=0 || > 64 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 chemicalSymbol, int radiationLevel){ this.unlocalizedName = Utils.sanitizeString(materialName); this.localizedName = materialName; this.RGBA = rgba; this.meltingPointC = meltingPoint; if (boilingPoint == 0){ boilingPoint = meltingPoint*4; } this.boilingPointC = boilingPoint; this.meltingPointK = (int) MathUtils.celsiusToKelvin(meltingPointC); this.boilingPointK = (int) MathUtils.celsiusToKelvin(boilingPointC); this.vProtons = protons; this.vNeutrons = neutrons; this.vMass = getMass(); /*//List inputArray = Arrays.asList(inputs); int tempSmallestSize = getSmallestStackForCrafting(inputs); if (tempSmallestSize <= 64 && tempSmallestSize >= 1){ this.smallestStackSizeWhenProcessing = tempSmallestSize; //Valid stacksizes } else { this.smallestStackSizeWhenProcessing = 50; //Can divide my math by 1/2 and round it~ }*/ //Sets the Rad level if (radiationLevel != 0){ this.isRadioactive = true; this.vRadioationLevel = (byte) radiationLevel; } else { this.isRadioactive = false; this.vRadioationLevel = (byte) radiationLevel; } //Sets the materials 'tier'. Will probably replace this logic. if (getMeltingPoint_K() >= 0 && getMeltingPoint_K() <= 750){ this.vTier = 1; } else if(getMeltingPoint_K() >= 751 && getMeltingPoint_K() <= 1250){ this.vTier = 2; } else if(getMeltingPoint_K() >= 1251 && getMeltingPoint_K() <= 1750){ this.vTier = 3; } else if(getMeltingPoint_K() >= 1751 && getMeltingPoint_K() <= 2250){ this.vTier = 4; } else if(getMeltingPoint_K() >= 2251 && getMeltingPoint_K() <= 2750){ this.vTier = 5; } else if(getMeltingPoint_K() >= 2751 && getMeltingPoint_K() <= 3250){ this.vTier = 6; } else if(getMeltingPoint_K() >= 3251 && getMeltingPoint_K() <= 3750){ this.vTier = 7; } else if(getMeltingPoint_K() >= 3751 && getMeltingPoint_K() <= 4250){ this.vTier = 8; } else if(getMeltingPoint_K() >= 4251 && getMeltingPoint_K() <= 4750){ this.vTier = 9; } else if(getMeltingPoint_K() >= 4751 && getMeltingPoint_K() <= 9999){ this.vTier = 10; } else { this.vTier = 0; } this.usesBlastFurnace = blastFurnace; this.vVoltageMultiplier = this.getMeltingPoint_K() >= 2800 ? 64 : 16; if (inputs == null){ this.vMaterialInput = null; } else { if (inputs.length != 0){ for (int i=0; i < inputs.length; i++){ if (inputs[i] != null){ this.vMaterialInput[i] = inputs[i]; } } } } this.vSmallestRatio = getSmallestRatio(vMaterialInput); int tempSmallestSize = 0; if (vSmallestRatio != null){ for (int v=0;v= 1){ ItemStack[] temp = new ItemStack[vMaterialInput.length]; for (int i=0;i= 1){ int[] temp = new int[vMaterialInput.length]; for (int i=0;i= 1){ int f = getInputMaterialCount(materialInput); String[] formulaComponents = new String[f]; for (int i=0;i 0){ Utils.LOG_WARNING("length: "+inputs.length); Utils.LOG_WARNING("(inputs != null): "+(inputs != null)); //Utils.LOG_WARNING("length: "+inputs.length); double tempPercentage=0; long[] tempRatio = new long[inputs.length]; for (int x=0;x= 101){ Utils.LOG_WARNING("The compound for "+localizedName+" doesn't equal 98-100%, this isn't good."); }*/ long[] smallestRatio = MathUtils.simplifyNumbersToSmallestForm(tempRatio); if (smallestRatio.length > 0){ String tempRatioStringThing1 = ""; for (int r=0;r 0){ int tempSmallestCraftingUseSize = 0; for (int r=0;r= 1){ String dummyFormula = ""; long[] dummyFormulaArray = getSmallestRatio(tempInput); if (dummyFormulaArray != null){ if (dummyFormulaArray.length >= 1){ for (int e=0;e 1){ if (tempInput[e].stackMaterial.vChemicalFormula.length() > 3){ dummyFormula = dummyFormula + "(" + tempInput[e].stackMaterial.vChemicalFormula + ")" + dummyFormulaArray[e]; } else { dummyFormula = dummyFormula + tempInput[e].stackMaterial.vChemicalFormula + dummyFormulaArray[e]; } } else if (dummyFormulaArray[e] == 1){ if (tempInput[e].stackMaterial.vChemicalFormula.length() > 3){ dummyFormula = dummyFormula + "(" +tempInput[e].stackMaterial.vChemicalFormula + ")"; } else { dummyFormula = dummyFormula + "" +tempInput[e].stackMaterial.vChemicalFormula + ""; } } else if (dummyFormulaArray[e] <= 0){ dummyFormula = dummyFormula+""; } } else dummyFormula = dummyFormula + "??"; } else dummyFormula = dummyFormula + "▓▓"; } else { dummyFormula = dummyFormula+""; } } return MaterialUtils.subscript(dummyFormula); //return dummyFormula; } Utils.LOG_WARNING("dummyFormulaArray <= 0"); } Utils.LOG_WARNING("dummyFormulaArray == null"); } Utils.LOG_WARNING("tempInput.length <= 0"); } Utils.LOG_WARNING("tempInput == null"); return "??"; } Fluid generateFluid(){ if (Materials.get(localizedName).mFluid == null){ Utils.LOG_WARNING("Generating our own fluid."); //Generate a Cell if we need to if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+getUnlocalizedName(), 1) == null){ Item temp = new BaseItemCell(this); } return FluidUtils.addGTFluid( this.getUnlocalizedName(), "Molten "+this.getLocalizedName(), this.RGBA, 4, this.getMeltingPoint_K(), ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+getUnlocalizedName(), 1), ItemList.Cell_Empty.get(1L, new Object[0]), 1000); } Utils.LOG_WARNING("Getting the fluid from a GT material instead."); return Materials.get(localizedName).mFluid; } public FluidStack getFluid(int fluidAmount) { Utils.LOG_WARNING("Attempting to get "+fluidAmount+"L of "+this.vMoltenFluid.getName()); FluidStack moltenFluid = new FluidStack(this.vMoltenFluid, fluidAmount); Utils.LOG_WARNING("Info: "+moltenFluid.getFluid().getName()+" Info: "+moltenFluid.amount+" Info: "+moltenFluid.getFluidID()); //FluidStack moltenFluid = FluidUtils.getFluidStack(this.vMoltenFluid.getName(), fluidAmount); /*boolean isNull = (moltenFluid == null); if (isNull) Utils.LOG_WARNING("Did not obtain fluid."); else Utils.LOG_WARNING("Found fluid."); if (isNull){ return null; }*/ return moltenFluid; } }