From 56bb017df6c34d8c1a2542b5d2ca1116226ecfb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20G=C3=A4=C3=9Fler?= Date: Tue, 30 May 2017 02:10:13 +0200 Subject: [PATCH] Implemented SBR recipes, Added method for LCM recipes, adjusted polymerization Polymerization now requires Titaniumtetrachloride instead of Titanium Dust; Can only be performed in a LCM. Adjusted the visual representation of LCM recipes in NEI --- .../java/gregtech/api/enums/Materials.java | 4 +- .../interfaces/internal/IGT_RecipeAdder.java | 16 +++++- .../java/gregtech/api/util/GT_Recipe.java | 24 +++++++-- .../java/gregtech/common/GT_RecipeAdder.java | 50 ++++++++++++++++--- .../postload/GT_MachineRecipeLoader.java | 12 +++-- 5 files changed, 87 insertions(+), 19 deletions(-) diff --git a/src/main/java/gregtech/api/enums/Materials.java b/src/main/java/gregtech/api/enums/Materials.java index ebf24db8..2146e031 100644 --- a/src/main/java/gregtech/api/enums/Materials.java +++ b/src/main/java/gregtech/api/enums/Materials.java @@ -537,8 +537,8 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { public static Materials HeavyFuel = new Materials(741, TextureSet.SET_FLUID, 1.0F, 0, 0, 16, 255, 255, 0, 0, "HeavyFuel", "Heavy Fuel", 3, 192, -1, 0, false, false, 1, 1, 1, Dyes.dyeBlack).setCanBeCracked(true); public static Materials LPG = new Materials(742, TextureSet.SET_FLUID, 1.0F, 0, 0, 16, 255, 255, 0, 0, "LPG", "LPG", 1, 256, -1, 0, false, false, 1, 1, 1, Dyes.dyeYellow); - public static Materials Polystyrene = new MaterialBuilder(636, TextureSet.SET_DULL, "Polystyrene").addDustItems().addMetalItems().addToolHeadItems().addGearItems().setToolSpeed(3.0f).setDurability(32).setToolQuality(1).setRGB(162, 150, 138).setColor(Dyes.dyeLightGray).setMaterialList(new MaterialStack(Carbon, 8), new MaterialStack(Hydrogen, 8)).constructMaterial(); - public static Materials Styrene = new MaterialBuilder(637, TextureSet.SET_FLUID, "Styrene").addCell().addFluid().setRGB(180, 168, 154).setColor(Dyes.dyeBlack).setMaterialList(new MaterialStack(Carbon, 8), new MaterialStack(Hydrogen, 8)).addElectrolyzerRecipe().constructMaterial(); + public static Materials Polystyrene = new MaterialBuilder(636, TextureSet.SET_DULL, "Polystyrene").addDustItems().addMetalItems().addToolHeadItems().addGearItems().setToolSpeed(3.0f).setDurability(32).setToolQuality(1).setRGB(190, 180, 170).setColor(Dyes.dyeLightGray).setMaterialList(new MaterialStack(Carbon, 8), new MaterialStack(Hydrogen, 8)).constructMaterial(); + public static Materials Styrene = new MaterialBuilder(637, TextureSet.SET_FLUID, "Styrene").addCell().addFluid().setRGB(210, 200, 190).setColor(Dyes.dyeBlack).setMaterialList(new MaterialStack(Carbon, 8), new MaterialStack(Hydrogen, 8)).addElectrolyzerRecipe().constructMaterial(); public static Materials Isoprene = new MaterialBuilder(638, TextureSet.SET_FLUID, "Isoprene").addCell().addFluid().setRGB(20, 20, 20).setColor(Dyes.dyeBlack).setMaterialList(new MaterialStack(Carbon, 5), new MaterialStack(Hydrogen, 8)).addElectrolyzerRecipe().constructMaterial(); public static Materials Tetranitromethane = new MaterialBuilder(639, TextureSet.SET_FLUID, "Tetranitromethane").addCell().addFluid().setRGB(20, 20, 70).setColor(Dyes.dyeBlack).setMaterialList(new MaterialStack(Carbon, 2), new MaterialStack(Hydrogen, 2), new MaterialStack(Oxygen, 1)).addElectrolyzerRecipe().constructMaterial(); public static Materials Ethenone = new MaterialBuilder(641, TextureSet.SET_FLUID, "Ethenone").addCell().addGas().setRGB(20, 20, 70).setColor(Dyes.dyeBlack).setMaterialList(new MaterialStack(Carbon, 2), new MaterialStack(Hydrogen, 2), new MaterialStack(Oxygen, 1)).addElectrolyzerRecipe().constructMaterial(); diff --git a/src/main/java/gregtech/api/interfaces/internal/IGT_RecipeAdder.java b/src/main/java/gregtech/api/interfaces/internal/IGT_RecipeAdder.java index c15eda80..1a36b7a8 100644 --- a/src/main/java/gregtech/api/interfaces/internal/IGT_RecipeAdder.java +++ b/src/main/java/gregtech/api/interfaces/internal/IGT_RecipeAdder.java @@ -1,5 +1,6 @@ package gregtech.api.interfaces.internal; +import gregtech.api.util.GT_Recipe; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; @@ -148,7 +149,20 @@ public interface IGT_RecipeAdder { */ public boolean addChemicalRecipe(ItemStack aInput1, ItemStack aInput2, FluidStack aFluidInput, FluidStack aFluidOutput, ItemStack aOutput, ItemStack aOutput2, int aDuration, int aEUtick); - + /** + * Adds a Chemical Recipe that only exists in the Large Chemical Reactor + * + * @param aInputs item inputs + * @param aFluidInputs fluid inputs + * @param aFluidOutputs fluid outputs + * @param aOutputs item outputs + * @param aDuration must be > 0 + * @param aEUtick must be > 0 + * aInputs and aFluidInputs must contain at least one valid input. + * aOutputs and aFluidOutputs must contain at least one valid output. + */ + public boolean addMultiblockChemicalRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, ItemStack[] aOutputs, int aDuration, int aEUtick); + /** * Adds a Blast Furnace Recipe * diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 9973946d..2ccc5df2 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -1458,8 +1458,8 @@ public class GT_Recipe implements Comparable { public static class GT_Recipe_Map_LargeChemicalReactor extends GT_Recipe_Map{ private static int INPUT_COUNT = 2; private static int OUTPUT_COUNT = 2; - private static int FLUID_INPUT_COUNT = 3; - private static int FLUID_OUTPUT_COUNT = 3; + private static int FLUID_INPUT_COUNT = 4; + private static int FLUID_OUTPUT_COUNT = 4; public GT_Recipe_Map_LargeChemicalReactor() { super(new HashSet(200), "gt.recipe.largechemicalreactor", "Large Chemical Reactor", null, RES_PATH_GUI + "basicmachines/Default", INPUT_COUNT, OUTPUT_COUNT, 0, 0, 1, E, 1, E, true, true); @@ -1467,12 +1467,14 @@ public class GT_Recipe implements Comparable { @Override public GT_Recipe addRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - aOptimize = false; ArrayList adjustedInputs = new ArrayList(); ArrayList adjustedOutputs = new ArrayList(); ArrayList adjustedFluidInputs = new ArrayList(); ArrayList adjustedFluidOutputs = new ArrayList(); + if (aInputs == null) { + aInputs = new ItemStack[0]; + } for (ItemStack input : aInputs) { FluidStack inputFluidContent = FluidContainerRegistry.getFluidForFilledItem(input); if (inputFluidContent != null) { @@ -1499,12 +1501,18 @@ public class GT_Recipe implements Comparable { } } } + if (aFluidInputs == null) { + aFluidInputs = new FluidStack[0]; + } for (FluidStack fluidInput : aFluidInputs) { adjustedFluidInputs.add(fluidInput); } aInputs = adjustedInputs.toArray(new ItemStack[adjustedInputs.size()]); aFluidInputs = adjustedFluidInputs.toArray(new FluidStack[adjustedFluidInputs.size()]); + if (aOutputs == null) { + aOutputs = new ItemStack[0]; + } for (ItemStack output : aOutputs) { FluidStack outputFluidContent = FluidContainerRegistry.getFluidForFilledItem(output); if (outputFluidContent != null) { @@ -1522,6 +1530,10 @@ public class GT_Recipe implements Comparable { } } } + + if (aFluidOutputs == null) { + aFluidOutputs = new FluidStack[0]; + } for (FluidStack fluidOutput : aFluidOutputs) { adjustedFluidOutputs.add(fluidOutput); } @@ -1548,7 +1560,11 @@ public class GT_Recipe implements Comparable { } for (int i = 0; i < fluidLimit; i++) { - inputStacks.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(this.mFluidInputs[i], true), 48 - i * 18, 23)); + if (i < 3) { + inputStacks.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(this.mFluidInputs[i], true), 48 - i * 18, 23)); + } else { + inputStacks.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(this.mFluidInputs[i], true), 12, 5)); + } } return inputStacks; diff --git a/src/main/java/gregtech/common/GT_RecipeAdder.java b/src/main/java/gregtech/common/GT_RecipeAdder.java index 628cfa91..092850bf 100644 --- a/src/main/java/gregtech/common/GT_RecipeAdder.java +++ b/src/main/java/gregtech/common/GT_RecipeAdder.java @@ -114,18 +114,32 @@ public class GT_RecipeAdder return false; } GT_Recipe.GT_Recipe_Map.sChemicalRecipes.addRecipe(true, new ItemStack[]{aInput1, aInput2}, new ItemStack[]{aOutput, aOutput2}, null, null, new FluidStack[]{aFluidInput}, new FluidStack[]{aFluidOutput}, aDuration, aEUtick, 0); - GT_Recipe.GT_Recipe_Map.sMultiblockChemicalRecipes.addRecipe(true, new ItemStack[]{aInput1, aInput2}, new ItemStack[]{aOutput, aOutput2}, null, null, new FluidStack[]{aFluidInput}, new FluidStack[]{aFluidOutput}, aDuration, aEUtick, 0); + GT_Recipe.GT_Recipe_Map.sMultiblockChemicalRecipes.addRecipe(false, new ItemStack[]{aInput1, aInput2}, new ItemStack[]{aOutput, aOutput2}, null, null, new FluidStack[]{aFluidInput}, new FluidStack[]{aFluidOutput}, aDuration, aEUtick, 0); return true; } + + public boolean addMultiblockChemicalRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, ItemStack[] aOutputs, int aDuration, int aEUtick){ + if (areItemsAndFluidsBothNull(aInputs, aFluidInputs) || areItemsAndFluidsBothNull(aOutputs, aFluidOutputs)) { + return false; + } + if (aEUtick <= 0) { + return false; + } + GT_Recipe.GT_Recipe_Map.sMultiblockChemicalRecipes.addRecipe(false, aInputs, aOutputs, null, null, aFluidInputs, aFluidOutputs, aDuration, aEUtick, 0); + return true; + } @Override public void addDefaultPolymerizationRecipes(Fluid aBasicMaterial, Fluid aPolymer){ - //Oxygen/Titanium -> +50% Output each - GT_Values.RA.addChemicalRecipe(ItemList.Cell_Air.get(2, new Object[0]), GT_Utility.getIntegratedCircuit(1), new GT_FluidStack(aBasicMaterial, 144), new GT_FluidStack(aPolymer, 144), Materials.Empty.getCells(2), 160); - GT_Values.RA.addChemicalRecipe(Materials.Oxygen.getCells(2), GT_Utility.getIntegratedCircuit(1), new GT_FluidStack(aBasicMaterial, 144), new GT_FluidStack(aPolymer, 216), Materials.Empty.getCells(2), 160); - GT_Values.RA.addChemicalRecipe(ItemList.Cell_Air.get(12, new Object[0]),Materials.Titanium.getDustTiny(1), new GT_FluidStack(aBasicMaterial, 1728), new GT_FluidStack(aPolymer, 2592), Materials.Empty.getCells(12), 640); - GT_Values.RA.addChemicalRecipe(Materials.Oxygen.getCells(12), Materials.Titanium.getDustTiny(1), new GT_FluidStack(aBasicMaterial, 1728), new GT_FluidStack(aPolymer, 3456), Materials.Empty.getCells(12), 640); - + //Oxygen/Titaniumtetrafluoride -> +50% Output each + addChemicalRecipe(ItemList.Cell_Air.get(2, new Object[0]), GT_Utility.getIntegratedCircuit(1), new GT_FluidStack(aBasicMaterial, 144), new GT_FluidStack(aPolymer, 144), Materials.Empty.getCells(2), 160); + addChemicalRecipe(Materials.Oxygen.getCells(2), GT_Utility.getIntegratedCircuit(1), new GT_FluidStack(aBasicMaterial, 144), new GT_FluidStack(aPolymer, 216), Materials.Empty.getCells(2), 160); + addMultiblockChemicalRecipe(new ItemStack[]{GT_Utility.getIntegratedCircuit(2)}, + new FluidStack[]{new GT_FluidStack(aBasicMaterial, 2160), Materials.Air.getGas(15000), Materials.Titaniumtetrachloride.getFluid(100)}, + new FluidStack[]{new GT_FluidStack(aPolymer, 3240)}, null, 800, 30); + addMultiblockChemicalRecipe(new ItemStack[]{GT_Utility.getIntegratedCircuit(2)}, + new FluidStack[]{new GT_FluidStack(aBasicMaterial, 2160), Materials.Oxygen.getGas(15000), Materials.Titaniumtetrachloride.getFluid(100)}, + new FluidStack[]{new GT_FluidStack(aPolymer, 4320)}, null, 800, 30); } public boolean addBlastRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput1, ItemStack aOutput2, int aDuration, int aEUt, int aLevel) { @@ -886,7 +900,27 @@ public class GT_RecipeAdder return true; } + private boolean areItemsAndFluidsBothNull(ItemStack[] items, FluidStack[] fluids){ + boolean itemsNull = true; + if (items != null) { + for (ItemStack itemStack : items) { + if (itemStack != null) { + itemsNull = false; + break; + } + } + } + boolean fluidsNull = true; + if (fluids != null) { + for (FluidStack fluidStack : fluids) { + if (fluidStack != null) { + fluidsNull = false; + break; + } + } + } + return itemsNull && fluidsNull; - + } } diff --git a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java index be6a4115..71587024 100644 --- a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java +++ b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java @@ -2638,7 +2638,7 @@ if(Loader.isModLoaded("Railcraft")){ GT_Values.RA.addChemicalRecipe(Materials.Sulfur.getDust(1), GT_Values.NI, Materials.Hydrogen.getGas(2000), Materials.HydricSulfide.getGas(1000), GT_Values.NI, 60, 8); - GT_Values.RA.addChemicalRecipe(Materials.Sulfur.getDust(1), GT_Values.NI, Materials.Oxygen.getGas(2000), Materials.SulfurDioxide.getGas(1000), GT_Values.NI, 60, 8); + GT_Values.RA.addChemicalRecipe(Materials.Sulfur.getDust(1), GT_Utility.getIntegratedCircuit(2), Materials.Oxygen.getGas(2000), Materials.SulfurDioxide.getGas(1000), GT_Values.NI, 60, 8); GT_Values.RA.addChemicalRecipe(Materials.HydricSulfide.getCells(1), GT_Values.NI, Materials.Oxygen.getGas(3000), Materials.SulfurDioxide.getGas(1000), Materials.Water.getCells(1), 120); GT_Values.RA.addChemicalRecipe(Materials.Oxygen.getCells(3), GT_Values.NI, Materials.HydricSulfide.getGas(1000), Materials.Water.getFluid(1000), Materials.SulfurDioxide.getCells(1), 120); @@ -2682,14 +2682,18 @@ if(Loader.isModLoaded("Railcraft")){ GT_Values.RA.addChemicalRecipe(ItemList.Cell_Air.get(2, new Object[0]), GT_Utility.getIntegratedCircuit(1), Materials.Isoprene.getFluid(144), null, Materials.RawRubber.getDust(1), Materials.Empty.getCells(2), 160); GT_Values.RA.addChemicalRecipe(Materials.Oxygen.getCells(4), GT_Utility.getIntegratedCircuit(1), Materials.Isoprene.getFluid(288), null, Materials.RawRubber.getDust(3), Materials.Empty.getCells(4), 320); - GT_Values.RA.addChemicalRecipe(ItemList.Cell_Air.get(12, new Object[0]),Materials.Titanium.getDustTiny(1), Materials.Isoprene.getFluid(1728), null, Materials.RawRubber.getDust(18), Materials.Empty.getCells(12), 640); - GT_Values.RA.addChemicalRecipe(Materials.Oxygen.getCells(12), Materials.Titanium.getDustTiny(1), Materials.Isoprene.getFluid(1728), null, Materials.RawRubber.getDust(24), Materials.Empty.getCells(12), 640); + GT_Values.RA.addMultiblockChemicalRecipe(new ItemStack[]{GT_Utility.getIntegratedCircuit(2)}, new FluidStack[]{Materials.Isoprene.getFluid(1728), Materials.Air.getGas(12000), Materials.Titaniumtetrachloride.getFluid(80)}, null, new ItemStack[]{Materials.RawRubber.getDust(18)}, 640, 30); + GT_Values.RA.addMultiblockChemicalRecipe(new ItemStack[]{GT_Utility.getIntegratedCircuit(2)}, new FluidStack[]{Materials.Isoprene.getFluid(1728), Materials.Oxygen.getGas(12000), Materials.Titaniumtetrachloride.getFluid(80)}, null, new ItemStack[]{Materials.RawRubber.getDust(24)}, 640, 30); GT_Values.RA.addChemicalRecipe(Materials.Benzene.getCells(1), null, Materials.Ethylene.getGas(1000), Materials.Hydrogen.getGas(2000), Materials.Styrene.getCells(1), 120); - GT_Values.RA.addChemicalRecipe(Materials.Ethylene.getCells(1), Materials.Empty.getCells(1), Materials.Benzene.getGas(1000), Materials.Styrene.getFluid(1000), Materials.Hydrogen.getCells(2), 120); + GT_Values.RA.addChemicalRecipe(Materials.Ethylene.getCells(1), Materials.Empty.getCells(1), Materials.Benzene.getFluid(1000), Materials.Styrene.getFluid(1000), Materials.Hydrogen.getCells(2), 120); GT_Values.RA.addDefaultPolymerizationRecipes(Materials.Styrene.mFluid, Materials.Polystyrene.mStandardMoltenFluid); + GT_Values.RA.addMultiblockChemicalRecipe(new ItemStack[]{GT_Utility.getIntegratedCircuit(3), Materials.Sulfur.getDust(1)}, new FluidStack[]{Materials.Styrene.getFluid(324), Materials.Butadiene.getGas(972), Materials.Air.getGas(18000)}, new FluidStack[]{Materials.StyreneButadieneRubber.getMolten(1296)}, null, 160, 240); + GT_Values.RA.addMultiblockChemicalRecipe(new ItemStack[]{GT_Utility.getIntegratedCircuit(3), Materials.Sulfur.getDust(1)}, new FluidStack[]{Materials.Styrene.getFluid(324), Materials.Butadiene.getGas(972), Materials.Oxygen.getGas(18000)}, new FluidStack[]{Materials.StyreneButadieneRubber.getMolten(1944)}, null, 160, 240); + GT_Values.RA.addMultiblockChemicalRecipe(new ItemStack[]{GT_Utility.getIntegratedCircuit(4),Materials.Sulfur.getDust(3)}, new FluidStack[]{Materials.Styrene.getFluid(540), Materials.Butadiene.getGas(1620), Materials.Titaniumtetrachloride.getFluid(100), Materials.Air.getGas(15000)}, new FluidStack[]{Materials.StyreneButadieneRubber.getMolten(3240)}, null, 640, 240); + GT_Values.RA.addMultiblockChemicalRecipe(new ItemStack[]{GT_Utility.getIntegratedCircuit(4),Materials.Sulfur.getDust(3)}, new FluidStack[]{Materials.Styrene.getFluid(540), Materials.Butadiene.getGas(1620), Materials.Titaniumtetrachloride.getFluid(100), Materials.Oxygen.getGas(15000)}, new FluidStack[]{Materials.StyreneButadieneRubber.getMolten(4320)}, null, 640, 240); } private void addSimplifiedChemicalRecipes() {