aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSKYCATV587 <41377439+SKYCATV587@users.noreply.github.com>2022-02-09 19:41:01 +0800
committerGitHub <noreply@github.com>2022-02-09 12:41:01 +0100
commit7eb8cdfe577a9d5846c37957d2c3771d4ae62df4 (patch)
tree2a6fddd4f477629f5627ee82d9ea807f22d44391 /src
parent3399a21e6f9befb80de63be5822bd750830c545d (diff)
downloadGT5-Unofficial-7eb8cdfe577a9d5846c37957d2c3771d4ae62df4.tar.gz
GT5-Unofficial-7eb8cdfe577a9d5846c37957d2c3771d4ae62df4.tar.bz2
GT5-Unofficial-7eb8cdfe577a9d5846c37957d2c3771d4ae62df4.zip
add MegaChemicalReactor and MegaOilCracker (#86)
* add MegaChemicalReactor * add MegaOilCracker * glass tire limit energyhatches tire * fix the minor issues * fix the minor issues Former-commit-id: 0df67deb157be99b494f6996be258321f5b75a22
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java7
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java3
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaChemicalReactor.java305
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaOilCracker.java455
4 files changed, 769 insertions, 1 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java
index 7666983319..561674bd75 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java
@@ -42,6 +42,8 @@ import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEnti
import com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega.GT_TileEntity_MegaBlastFurnace;
import com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega.GT_TileEntity_MegaDistillTower;
import com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega.GT_TileEntity_MegaVacuumFreezer;
+import com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega.GT_TileEntity_MegaChemicalReactor;
+import com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega.GT_TileEntity_MegaOilCracker;
import com.github.bartimaeusnek.bartworks.common.tileentities.tiered.*;
import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader;
import com.github.bartimaeusnek.crossmod.galacticgreg.GT_TileEntity_VoidMiners;
@@ -142,7 +144,7 @@ public class ItemRegistry {
public static ItemStack[] energyDistributor = new ItemStack[GT_Values.VN.length];
public static ItemStack[] acidGens = new ItemStack[3];
public static ItemStack acidGensLV;
- public static ItemStack[] megaMachines = new ItemStack[3];
+ public static ItemStack[] megaMachines = new ItemStack[5];
public static ItemStack dehp;
public static ItemStack[] voidminer = new ItemStack[3];
public static ItemStack THTR;
@@ -215,6 +217,9 @@ public class ItemRegistry {
ItemRegistry.compressedHatch = new GT_MetaTileEntity_CompressedFluidHatch(ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 8, "CompressedFluidHatch", "Liquid Air Fluid Hatch").getStackForm(1L);
ItemRegistry.giantOutputHatch = new GT_MetaTileEntity_GiantOutputHatch(ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 9, "GiantOutputHatch", "Giant Output Hatch").getStackForm(1L);
ItemRegistry.megaMachines[2] = new GT_TileEntity_MegaDistillTower(ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 10, "MegaDistillationTower", "Mega Distillation Tower").getStackForm(1L);
+ ItemRegistry.megaMachines[3] = new GT_TileEntity_MegaChemicalReactor(ConfigHandler.IDOffset+GT_Values.VN.length * 8 + 638, "MegaChemicalReactor", "Mega Chemical Reactor").getStackForm(1L);
+ ItemRegistry.megaMachines[4] = new GT_TileEntity_MegaOilCracker(ConfigHandler.IDOffset+GT_Values.VN.length * 8 + 639, "MegaOilCracker", "Mega Oil Cracker").getStackForm(1L);
+
if (LoaderReference.galacticgreg && WerkstoffLoader.gtnhGT) {
ItemRegistry.voidminer[2] = new GT_TileEntity_VoidMiners.VMUV(ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 11, "VoidMiner3", "Void Miner III").getStackForm(1L);
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java
index 7f7d57d330..cf31a88cd1 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java
@@ -257,6 +257,9 @@ public class RecipeLoader {
GT_Values.RA.addAssemblerRecipe(GT_ModHandler.getModItem("gregtech", "gt.blockmachines", 64, 1000), GT_Utility.getIntegratedCircuit(17), Materials.SolderingAlloy.getMolten(9216), ItemRegistry.megaMachines[0], 72000, BW_Util.getMachineVoltageFromTier(3));
GT_Values.RA.addAssemblerRecipe(GT_ModHandler.getModItem("gregtech", "gt.blockmachines", 64, 1002), GT_Utility.getIntegratedCircuit(17), Materials.SolderingAlloy.getMolten(9216), ItemRegistry.megaMachines[1], 72000, BW_Util.getMachineVoltageFromTier(3));
GT_Values.RA.addAssemblerRecipe(GT_ModHandler.getModItem("gregtech", "gt.blockmachines", 64, 1126), GT_Utility.getIntegratedCircuit(17), Materials.SolderingAlloy.getMolten(9216), ItemRegistry.megaMachines[2], 72000, BW_Util.getMachineVoltageFromTier(3));
+ GT_Values.RA.addAssemblerRecipe(GT_ModHandler.getModItem("gregtech", "gt.blockmachines", 64, 1169), GT_Utility.getIntegratedCircuit(17), Materials.SolderingAlloy.getMolten(9216), ItemRegistry.megaMachines[3], 72000, BW_Util.getMachineVoltageFromTier(3));
+ GT_Values.RA.addAssemblerRecipe(GT_ModHandler.getModItem("gregtech", "gt.blockmachines", 64, 1160), GT_Utility.getIntegratedCircuit(17), Materials.SolderingAlloy.getMolten(9216), ItemRegistry.megaMachines[4], 72000, BW_Util.getMachineVoltageFromTier(3));
+
GT_Values.RA.addFluidSolidifierRecipe(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0), Materials.Nickel.getMolten(5184), new ItemStack(ItemRegistry.bw_glasses[0], 1, 1), 800, BW_Util.getMachineVoltageFromTier(3));
GT_Values.RA.addFluidSolidifierRecipe(new ItemStack(ItemRegistry.bw_glasses[0], 1, 1), Materials.Tungsten.getMolten(1296), new ItemStack(ItemRegistry.bw_glasses[0], 1, 2), 800, BW_Util.getMachineVoltageFromTier(4));
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaChemicalReactor.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaChemicalReactor.java
new file mode 100644
index 0000000000..ba6afeb0c4
--- /dev/null
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaChemicalReactor.java
@@ -0,0 +1,305 @@
+/*
+ * Copyright (c) 2018-2020 bartimaeusnek
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega;
+
+import com.github.bartimaeusnek.bartworks.API.LoaderReference;
+import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler;
+import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry;
+import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference;
+import com.github.bartimaeusnek.bartworks.util.BW_Util;
+import com.github.bartimaeusnek.bartworks.util.MegaUtils;
+import com.github.bartimaeusnek.bartworks.util.Pair;
+import com.github.bartimaeusnek.crossmod.tectech.TecTechEnabledMulti;
+import com.github.bartimaeusnek.crossmod.tectech.helper.TecTechUtils;
+import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
+import com.gtnewhorizon.structurelib.structure.StructureDefinition;
+import com.gtnewhorizon.structurelib.structure.StructureUtility;
+import cpw.mods.fml.common.Optional;
+import gregtech.api.GregTech_API;
+import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output;
+import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
+import gregtech.api.util.GT_Recipe;
+import gregtech.api.util.GT_Utility;
+import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_LargeChemicalReactor;
+import net.minecraft.block.Block;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.fluids.FluidStack;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static com.github.bartimaeusnek.bartworks.util.RecipeFinderForParallel.getMultiOutput;
+import static com.github.bartimaeusnek.bartworks.util.RecipeFinderForParallel.handleParallelRecipe;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.*;
+import static gregtech.api.enums.GT_Values.V;
+import static gregtech.api.util.GT_StructureUtility.*;
+import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional;
+
+@Optional.Interface(iface = "com.github.bartimaeusnek.crossmod.tectech.TecTechEnabledMulti", modid = "tectech", striprefs = true)
+public class GT_TileEntity_MegaChemicalReactor extends GT_MetaTileEntity_LargeChemicalReactor implements TecTechEnabledMulti {
+
+ public GT_TileEntity_MegaChemicalReactor(int aID, String aName, String aNameRegional) {
+ super(aID, aName, aNameRegional);
+ }
+
+ public GT_TileEntity_MegaChemicalReactor(String aName) {
+ super(aName);
+ }
+
+ @Override
+ public GT_Multiblock_Tooltip_Builder createTooltip() {
+ final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
+ tt.addMachineType("Chemical Reactor")
+ .addInfo("Controller block for the Chemical Reactor")
+ .addInfo("What molecule do you want to synthesize")
+ .addInfo("Or you want to replace something in this molecule")
+ .addInfo("The structure is too complex!")
+ .addInfo("Follow the Structure Lib hologram projector to build the main structure.")
+ .addSeparator()
+ .beginStructureBlock(5, 5, 9, false)
+ .addController("Front bottom")
+ .addStructureInfo("The glass tier limits the Energy Input tier")
+ .addEnergyHatch("Hint block ", 3)
+ .addMaintenanceHatch("Hint block ",2)
+ .addInputHatch("Hint block ",1)
+ .addInputBus("Hint block ",1)
+ .addOutputBus("Hint block ",1)
+ .addOutputHatch("Hint block ",1)
+ .toolTipFinisher(BW_Tooltip_Reference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get());
+ return tt;
+ }
+
+ @Override
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new GT_TileEntity_MegaChemicalReactor(this.mName);
+ }
+
+ @SuppressWarnings("rawtypes")
+ public ArrayList TTTunnels = new ArrayList<>();
+ @SuppressWarnings("rawtypes")
+ public ArrayList TTMultiAmp = new ArrayList<>();
+
+ @Override
+ public boolean addEnergyInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
+ if (LoaderReference.tectech) {
+ return TecTechUtils.addEnergyInputToMachineList(this, aTileEntity, aBaseCasingIndex);
+ }
+ return super.addEnergyInputToMachineList(aTileEntity, aBaseCasingIndex);
+ }
+
+ @Override
+ public boolean drainEnergyInput(long aEU) {
+ if (LoaderReference.tectech) {
+ return TecTechUtils.drainEnergyMEBFTecTech(this, aEU);
+ }
+ return MegaUtils.drainEnergyMegaVanilla(this, aEU);
+ }
+
+ @Override
+ public long getMaxInputVoltage() {
+ if (LoaderReference.tectech) {
+ return TecTechUtils.getMaxInputVoltage(this);
+ }
+ return super.getMaxInputVoltage();
+ }
+
+ @Override
+ public boolean checkRecipe(ItemStack itemStack) {
+ ItemStack[] tInputs = this.getStoredInputs().toArray(new ItemStack[0]);
+ FluidStack[] tInputFluids = this.getStoredFluids().toArray(new FluidStack[0]);
+ ArrayList<ItemStack> outputItems = new ArrayList<>();
+ ArrayList<FluidStack> outputFluids = new ArrayList<>();
+
+ long nominalV = LoaderReference.tectech ? TecTechUtils.getnominalVoltageTT(this) : BW_Util.getnominalVoltage(this);
+
+ byte tTier = (byte) Math.max(1, Math.min(GT_Utility.getTier(nominalV), V.length - 1));
+
+ GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sMultiblockChemicalRecipes.findRecipe(this.getBaseMetaTileEntity(), false, V[tTier], tInputFluids, tInputs);
+ boolean found_Recipe = false;
+ int processed = 0;
+
+ if (tRecipe != null) {
+ found_Recipe = true;
+ long tMaxPara = Math.min(ConfigHandler.megaMachinesMax, nominalV / tRecipe.mEUt);
+ int tCurrentPara = handleParallelRecipe(tRecipe, tInputFluids, tInputs, (int) tMaxPara);
+ if (tCurrentPara <= 0) {
+ return false;
+ }
+ processed = tCurrentPara;
+ Pair<ArrayList<FluidStack>, ArrayList<ItemStack>> Outputs = getMultiOutput(tRecipe, tCurrentPara);
+ outputFluids = Outputs.getKey();
+ outputItems = Outputs.getValue();
+ }
+
+ if (found_Recipe) {
+ this.mEfficiency = (10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000);
+ this.mEfficiencyIncrease = 10000;
+ long actualEUT = (long) (tRecipe.mEUt) * processed;
+ if (actualEUT > Integer.MAX_VALUE) {
+ byte divider = 0;
+ while (actualEUT > Integer.MAX_VALUE) {
+ actualEUT = actualEUT / 2;
+ divider++;
+ }
+ calculatePerfectOverclockedNessMulti((int) actualEUT, tRecipe.mDuration * (divider * 2), 1, nominalV);
+ } else {
+ calculatePerfectOverclockedNessMulti((int) actualEUT, tRecipe.mDuration, 1, nominalV);
+ }
+ //In case recipe is too OP for that machine
+ if (this.mMaxProgresstime == Integer.MAX_VALUE - 1 && this.mEUt == Integer.MAX_VALUE - 1) {
+ return false;
+ }
+ if (this.mEUt > 0) {
+ this.mEUt = (-this.mEUt);
+ }
+ this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
+ this.mOutputItems = new ItemStack[outputItems.size()];
+ this.mOutputItems = outputItems.toArray(this.mOutputItems);
+ this.mOutputFluids = new FluidStack[outputFluids.size()];
+ this.mOutputFluids = outputFluids.toArray(this.mOutputFluids);
+ this.updateSlots();
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void construct(ItemStack aStack, boolean aHintsOnly) {
+ buildPiece(STRUCTURE_PIECE_MAIN,aStack,aHintsOnly,2,2,0);
+ }
+
+ // -------------- TEC TECH COMPAT ----------------
+
+ @Override
+ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
+ glasTier = 0;
+ if (LoaderReference.tectech) {
+ this.getTecTechEnergyMultis().clear();
+ this.getTecTechEnergyTunnels().clear();
+ }
+
+ if(checkPiece(STRUCTURE_PIECE_MAIN,2,2,0)&&(mMaintenanceHatches.size()==1)){
+ return false;
+ }
+
+ if (this.glasTier != 8 && !this.mEnergyHatches.isEmpty()) {
+ for (GT_MetaTileEntity_Hatch_Energy hatchEnergy : this.mEnergyHatches) {
+ if (this.glasTier < hatchEnergy.mTier) {
+ return false;
+ }
+ }
+ }
+
+
+ return true;
+ }
+
+ private static final int CASING_INDEX = 176;
+ private static final String STRUCTURE_PIECE_MAIN = "main";
+ private static final IStructureDefinition<GT_TileEntity_MegaChemicalReactor> STRUCTURE_DEFINITION = StructureDefinition.<GT_TileEntity_MegaChemicalReactor>builder()
+ .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{
+ {"ttttt", "dptpd", "dptpd", "dptpd", "dptpd", "dptpd", "dptpd", "dptpd","ttttt"},
+ {"tgggt", " ggg ", " ggg ", " ggg ", " ggg ", " ggg ", " ggg ", " ggg ", "teeet"},
+ {"tg~gt", " gcg ", " gcg ", " gcg ", " gcg ", " gcg ", " gcg ", " gcg ", "teret"},
+ {"tgggt", " ggg ", " ggg ", " ggg ", " ggg ", " ggg ", " ggg ", " ggg ", "teeet"},
+ {"ttttt", "dptpd", "dptpd", "dptpd", "dptpd", "dptpd", "dptpd", "dptpd","ttttt"},
+ }))
+ .addElement('p', ofBlock(GregTech_API.sBlockCasings8, 1))
+ .addElement('t', ofBlock(GregTech_API.sBlockCasings8, 0))
+ .addElement('d', ofChain(
+ ofHatchAdder(GT_TileEntity_MegaChemicalReactor::addInputToMachineList, CASING_INDEX, 1),
+ ofHatchAdder(GT_TileEntity_MegaChemicalReactor::addOutputToMachineList, CASING_INDEX, 1),
+ onElementPass(GT_TileEntity_MegaChemicalReactor::onCasingAdded, ofBlock(GregTech_API.sBlockCasings8, 0))
+ ))
+ .addElement('r', ofChain(
+ ofHatchAdder(GT_TileEntity_MegaChemicalReactor::addMaintenanceToMachineList, CASING_INDEX, 2)
+ ))
+ .addElement('e', ofChain(
+ ofHatchAdder(GT_TileEntity_MegaChemicalReactor::addEnergyInputToMachineList, CASING_INDEX, 3),
+ onElementPass(GT_TileEntity_MegaChemicalReactor::onCasingAdded, ofBlock(GregTech_API.sBlockCasings8, 0))
+ ))
+ .addElement('c', ofChain(
+ ofBlock(GregTech_API.sBlockCasings4, 7)
+ ))
+ .addElement('g', ofChain(
+ ofBlockAdder(GT_TileEntity_MegaChemicalReactor::addGlas, ItemRegistry.bw_glasses[0], 1)
+ ))
+ .build();
+
+ private int mCasingAmount;
+
+
+
+ @Override
+ public IStructureDefinition<GT_MetaTileEntity_LargeChemicalReactor> getStructureDefinition() {
+ return (IStructureDefinition) STRUCTURE_DEFINITION;
+ }
+
+ private void onCasingAdded() {
+ mCasingAmount++;
+ }
+
+ private byte glasTier;
+
+ private boolean addGlas(Block block, int meta) {
+ if (block != ItemRegistry.bw_glasses[0]) {
+ return false;
+ }
+ byte tier = BW_Util.getTierFromGlasMeta(meta);
+ if (glasTier > 0) {
+ return tier == glasTier;
+ }
+ glasTier = tier;
+ return true;
+ }
+
+ @Override
+ public String[] getInfoData() {
+ return LoaderReference.tectech ? this.getInfoDataArray(this) : super.getInfoData();
+ }
+
+ @Override
+ @Optional.Method(modid = "tectech")
+ public List<GT_MetaTileEntity_Hatch_Energy> getVanillaEnergyHatches() {
+ return this.mEnergyHatches;
+ }
+
+ @Override
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ @Optional.Method(modid = "tectech")
+ public List getTecTechEnergyTunnels() {
+ return TTTunnels;
+ }
+
+ @Override
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ @Optional.Method(modid = "tectech")
+ public List getTecTechEnergyMultis() {
+ return TTMultiAmp;
+ }
+}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaOilCracker.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaOilCracker.java
new file mode 100644
index 0000000000..4aef8d7c93
--- /dev/null
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaOilCracker.java
@@ -0,0 +1,455 @@
+/*
+ * Copyright (c) 2022 SKYCATV587
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega;
+
+import com.github.bartimaeusnek.bartworks.API.LoaderReference;
+import com.github.bartimaeusnek.bartworks.API.SideReference;
+import com.github.bartimaeusnek.bartworks.client.textures.PrefixTextureLinker;
+import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler;
+import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry;
+import com.github.bartimaeusnek.bartworks.system.material.*;
+import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference;
+import com.github.bartimaeusnek.bartworks.util.BW_Util;
+import com.github.bartimaeusnek.bartworks.util.MegaUtils;
+import com.github.bartimaeusnek.bartworks.util.Pair;
+import com.github.bartimaeusnek.crossmod.tectech.TecTechEnabledMulti;
+import com.github.bartimaeusnek.crossmod.tectech.helper.TecTechUtils;
+import com.gtnewhorizon.structurelib.StructureLibAPI;
+import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
+import com.gtnewhorizon.structurelib.structure.IStructureElement;
+import com.gtnewhorizon.structurelib.structure.StructureDefinition;
+import cpw.mods.fml.common.Optional;
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.HeatingCoilLevel;
+import gregtech.api.enums.Materials;
+import gregtech.api.enums.OrePrefixes;
+import gregtech.api.enums.TextureSet;
+import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output;
+import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
+import gregtech.api.util.GT_Recipe;
+import gregtech.api.util.GT_Utility;
+import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_OilCracker;
+import net.minecraft.block.Block;
+import net.minecraft.item.ItemBlock;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.IIcon;
+import net.minecraft.world.World;
+import net.minecraftforge.fluids.FluidStack;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import static com.github.bartimaeusnek.bartworks.util.RecipeFinderForParallel.getMultiOutput;
+import static com.github.bartimaeusnek.bartworks.util.RecipeFinderForParallel.handleParallelRecipe;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.*;
+import static gregtech.api.enums.GT_Values.V;
+import static gregtech.api.util.GT_StructureUtility.*;
+
+@Optional.Interface(iface = "com.github.bartimaeusnek.crossmod.tectech.TecTechEnabledMulti", modid = "tectech", striprefs = true)
+public class GT_TileEntity_MegaOilCracker extends GT_MetaTileEntity_OilCracker implements TecTechEnabledMulti {
+
+ public GT_TileEntity_MegaOilCracker(int aID, String aName, String aNameRegional) {
+ super(aID, aName, aNameRegional);
+ }
+
+ public GT_TileEntity_MegaOilCracker(String aName) {
+ super(aName);
+ }
+
+ @Override
+ public GT_Multiblock_Tooltip_Builder createTooltip() {
+ final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
+ tt.addMachineType("Oil Cracking Unit")
+ .addInfo("Controller block for the Mega Oil Cracking")
+ .addInfo("Thermally cracks heavy hydrocarbons into lighter fractions")
+ .addInfo("More efficient than the Chemical Reactor")
+ .addInfo("Gives different benefits whether it hydro or steam-cracks:")
+ .addInfo("Hydro - Consumes 20% less Hydrogen and outputs 25% more cracked fluid")
+ .addInfo("Steam - Outputs 50% more cracked fluid")
+ .addInfo("(Values compared to cracking in the Chemical Reactor)")
+ .addInfo("Place the appropriate circuit in the controller")
+ .addSeparator()
+ .beginStructureBlock(13, 7, 9, true)
+ .addController("Front bottom")
+ .addStructureInfo("The glass tier limits the Energy Input tier")
+ .addInfo("Gets 10% EU/t reduction per coil tier, up to a maximum of 50%")
+ .addEnergyHatch("Hint block",1)
+ .addMaintenanceHatch("Hint block",1)
+ .addInputHatch("Hint block",2,3)
+ .addOutputHatch("Hint block",2,3)
+ .addInputHatch("Steam/Hydrogen ONLY, Hint block",4)
+ .toolTipFinisher(BW_Tooltip_Reference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get());
+ return tt;
+ }
+
+ @Override
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new GT_TileEntity_MegaOilCracker(this.mName);
+ }
+
+ @SuppressWarnings("rawtypes")
+ public ArrayList TTTunnels = new ArrayList<>();
+ @SuppressWarnings("rawtypes")
+ public ArrayList TTMultiAmp = new ArrayList<>();
+
+ @Override
+ public boolean addEnergyInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
+ if (LoaderReference.tectech) {
+ return TecTechUtils.addEnergyInputToMachineList(this, aTileEntity, aBaseCasingIndex);
+ }
+ return super.addEnergyInputToMachineList(aTileEntity, aBaseCasingIndex);
+ }
+
+ @Override
+ public boolean drainEnergyInput(long aEU) {
+ if (LoaderReference.tectech) {
+ return TecTechUtils.drainEnergyMEBFTecTech(this, aEU);
+ }
+ return MegaUtils.drainEnergyMegaVanilla(this, aEU);
+ }
+
+ @Override
+ public long getMaxInputVoltage() {
+ if (LoaderReference.tectech) {
+ return TecTechUtils.getMaxInputVoltage(this);
+ }
+ return super.getMaxInputVoltage();
+ }
+
+ @Override
+ public GT_Recipe.GT_Recipe_Map getRecipeMap() {
+ return GT_Recipe.GT_Recipe_Map.sCrackingRecipes;
+ }
+
+ @Override
+ public boolean checkRecipe(ItemStack itemStack) {
+ ItemStack[] tInputs = this.getStoredInputs().toArray(new ItemStack[0]);
+ FluidStack[] tInputFluids = this.getStoredFluids().toArray(new FluidStack[0]);
+ ArrayList<ItemStack> outputItems = new ArrayList<>();
+ ArrayList<FluidStack> outputFluids = new ArrayList<>();
+
+ long nominalV = LoaderReference.tectech ? TecTechUtils.getnominalVoltageTT(this) : BW_Util.getnominalVoltage(this);
+
+ byte tTier = (byte) Math.max(1, Math.min(GT_Utility.getTier(nominalV), V.length - 1));
+
+ GT_Recipe tRecipe = getRecipeMap().findRecipe(
+ getBaseMetaTileEntity(),
+ false,
+ gregtech.api.enums.GT_Values.V[tTier],
+ tInputFluids,
+ mInventory[1]
+ );
+
+ boolean found_Recipe = false;
+ int processed = 0;
+
+ if (tRecipe != null) {
+ found_Recipe = true;
+ long tMaxPara = Math.min(ConfigHandler.megaMachinesMax, nominalV / tRecipe.mEUt);
+ int tCurrentPara = handleParallelRecipe(tRecipe, tInputFluids, tInputs, (int) tMaxPara);
+ if (tCurrentPara <= 0) {
+ return false;
+ }
+ processed = tCurrentPara;
+ Pair<ArrayList<FluidStack>, ArrayList<ItemStack>> Outputs = getMultiOutput(tRecipe, tCurrentPara);
+ outputFluids = Outputs.getKey();
+ outputItems = Outputs.getValue();
+ }
+
+ if (found_Recipe) {
+ this.mEfficiency = (10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000);
+ this.mEfficiencyIncrease = 10000;
+ long actualEUT = (long) (tRecipe.mEUt) * processed;
+ if (actualEUT > Integer.MAX_VALUE) {
+ byte divider = 0;
+ while (actualEUT > Integer.MAX_VALUE) {
+ actualEUT = actualEUT / 2;
+ divider++;
+ }
+ calculatePerfectOverclockedNessMulti((int) actualEUT, tRecipe.mDuration * (divider * 2), 1, nominalV);
+ } else {
+ calculatePerfectOverclockedNessMulti((int) actualEUT, tRecipe.mDuration, 1, nominalV);
+ }
+ //In case recipe is too OP for that machine
+ if (this.mMaxProgresstime == Integer.MAX_VALUE - 1 && this.mEUt == Integer.MAX_VALUE - 1) {
+ return false;
+ }
+
+ if (this.heatLevel.getTier() < 5) {
+ this.mEUt *= 1 - (0.1D * (this.heatLevel.getTier() + 1));
+ }
+ else {
+ this.mEUt *= 0.5;
+ }
+
+ if (this.mEUt > 0) {
+ this.mEUt = (-this.mEUt);
+ }
+ this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
+ this.mOutputItems = new ItemStack[outputItems.size()];
+ this.mOutputItems = outputItems.toArray(this.mOutputItems);
+ this.mOutputFluids = new FluidStack[outputFluids.size()];
+ this.mOutputFluids = outputFluids.toArray(this.mOutputFluids);
+ this.updateSlots();
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void construct(ItemStack aStack, boolean aHintsOnly) {
+ buildPiece(STRUCTURE_PIECE_MAIN,aStack,aHintsOnly,6,6,0);
+ }
+
+ // -------------- TEC TECH COMPAT ----------------
+
+ @Override
+ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
+ glasTier = 0;
+
+ if (LoaderReference.tectech) {
+ this.getTecTechEnergyMultis().clear();
+ this.getTecTechEnergyTunnels().clear();
+ }
+
+ if(checkPiece(STRUCTURE_PIECE_MAIN,6,6,0)&&(mMaintenanceHatches.size()==1)&&(mEnergyHatches.size()<=2)){
+ return false;
+ }
+
+
+ if (this.glasTier != 8 && !this.mEnergyHatches.isEmpty()) {
+ for (GT_MetaTileEntity_Hatch_Energy hatchEnergy : this.mEnergyHatches) {
+ if (this.glasTier < hatchEnergy.mTier) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ private static final int CASING_INDEX = 49;
+ private static final String STRUCTURE_PIECE_MAIN = "main";
+ private static final IStructureDefinition<GT_TileEntity_MegaOilCracker> STRUCTURE_DEFINITION = StructureDefinition.<GT_TileEntity_MegaOilCracker>builder()
+ .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{
+ {" p p ", "ppgggggggggpp", " pgggggggggp ", " pgggpppgggp ", " pgggpMpgggp ", " pgggpppgggp ", " pgggggggggp ", "ppgggggggggpp", " p p "},
+ {" p p ", "pgggggggggggp", " g c c c c g ", " g c c c c g ", " g c c c c g ", " g c c c c g ", " g c c c c g ", "pgggggggggggp", " p p "},
+ {" p p ", "pgggggggggggp", " g c c c c g ", " p c c p ", " p c c c c p ", " p c c p ", " g c c c c g ", "pgggggggggggp", " p p "},
+ {" p p ", "pgggggggggggp", " g c c c c g ", " p c c c c p ", " l c c c c r ", " p c c c c p ", " g c c c c g ", "pgggggggggggp", " p p "},
+ {" p p ", "pgggggggggggp", " g c c c c g ", " p c c p ", " p c c c c p ", " p c c p ", " g c c c c g ", "pgggggggggggp", " p p "},
+ {" p p ", "pgggggggggggp", " g c c c c g ", " g c c c c g ", " g c c c c g ", " g c c c c g ", " g c c c c g ", "pgggggggggggp", " p p "},
+ {"ppmmmm~mmmmpp", "ppppppppppppp", "ppppppppppppp", "ppppppppppppp", "ppppppppppppp", "ppppppppppppp", "ppppppppppppp", "ppppppppppppp", "ppmmmmmmmmmpp"},
+
+ }))
+ .addElement('c', ofCoil(GT_TileEntity_MegaOilCracker::setCoilLevel, GT_TileEntity_MegaOilCracker::getCoilLevel))
+ .addElement('p', ofBlock(GregTech_API.sBlockCasings4, 1))
+// .addElement('s', addTileCasing(BW_GT_MaterialReference.StainlessSteel))
+ .addElement('l', ofChain(
+ ofHatchAdder(GT_TileEntity_MegaOilCracker::addLeftHatchToMachineList, CASING_INDEX, 2)
+ ))
+ .addElement('r', ofChain(
+ ofHatchAdder(GT_TileEntity_MegaOilCracker::addRightHatchToMachineList, CASING_INDEX, 3)
+ ))
+ .addElement('m', ofChain(
+ ofHatchAdder(GT_TileEntity_MegaOilCracker::addEnergyInputToMachineList, CASING_INDEX, 1),
+ ofHatchAdder(GT_TileEntity_MegaOilCracker::addMaintenanceToMachineList, CASING_INDEX, 1),
+ onElementPass(GT_TileEntity_MegaOilCracker::onCasingAdded, ofBlock(GregTech_API.sBlockCasings4, 1))
+ ))
+ .addElement('M', ofChain(
+ ofHatchAdder(GT_TileEntity_MegaOilCracker::addMiddleInputToMachineList, CASING_INDEX, 4)
+ ))
+ .addElement('g', ofChain(
+ ofBlockAdder(GT_TileEntity_MegaOilCracker::addGlas, ItemRegistry.bw_glasses[0], 1)
+ ))
+ .build();
+
+ private HeatingCoilLevel heatLevel;
+
+ private int mCoilAmount;
+
+ private boolean addLeftHatchToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
+ if (aTileEntity == null) {
+ return false;
+ }
+ IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
+ if (aMetaTileEntity == null) {
+ return false;
+ }
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) {
+ if (mInputOnSide == 1){
+ return false;
+ }
+ mInputOnSide = 0;
+ mOutputOnSide = 1;
+ GT_MetaTileEntity_Hatch_Input tHatch = (GT_MetaTileEntity_Hatch_Input) aMetaTileEntity;
+ tHatch.updateTexture(aBaseCasingIndex);
+ tHatch.mRecipeMap = getRecipeMap();
+ return mInputHatches.add(tHatch);
+ }
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) {
+ if (mOutputOnSide == 1){
+ return false;
+ }
+ mInputOnSide = 1;
+ mOutputOnSide = 0;
+ GT_MetaTileEntity_Hatch_Output tHatch = (GT_MetaTileEntity_Hatch_Output) aMetaTileEntity;
+ tHatch.updateTexture(aBaseCasingIndex);
+ return mOutputHatches.add(tHatch);
+ }
+ return false;
+ }
+
+ private boolean addRightHatchToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
+ if (aTileEntity == null) {
+ return false;
+ }
+ IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
+ if (aMetaTileEntity == null) {
+ return false;
+ }
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) {
+ if (mInputOnSide == 0){
+ return false;
+ }
+ mInputOnSide = 1;
+ mOutputOnSide = 0;
+ GT_MetaTileEntity_Hatch_Input tHatch = (GT_MetaTileEntity_Hatch_Input) aMetaTileEntity;
+ tHatch.updateTexture(aBaseCasingIndex);
+ tHatch.mRecipeMap = getRecipeMap();
+ return mInputHatches.add(tHatch);
+ }
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) {
+ if (mOutputOnSide == 0){
+ return false;
+ }
+ mInputOnSide = 0;
+ mOutputOnSide = 1;
+ GT_MetaTileEntity_Hatch_Output tHatch = (GT_MetaTileEntity_Hatch_Output) aMetaTileEntity;
+ tHatch.updateTexture(aBaseCasingIndex);
+ return mOutputHatches.add(tHatch);
+ }
+ return false;
+ }
+
+ private boolean addMiddleInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
+ if (aTileEntity == null) {
+ return false;
+ }
+ IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
+ if (aMetaTileEntity == null) {
+ return false;
+ }
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) {
+ GT_MetaTileEntity_Hatch_Input tHatch = (GT_MetaTileEntity_Hatch_Input) aMetaTileEntity;
+ tHatch.updateTexture(aBaseCasingIndex);
+ tHatch.mRecipeMap = getRecipeMap();
+ return mMiddleInputHatches.add(tHatch);
+ }
+ return false;
+ }
+
+ @Override
+ public ArrayList<FluidStack> getStoredFluids() {
+ ArrayList<FluidStack> rList = new ArrayList<>();
+ for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) {
+ tHatch.mRecipeMap = getRecipeMap();
+ if (isValidMetaTileEntity(tHatch) && tHatch.getFillableStack() != null) {
+ if (!GT_Recipe.GT_Recipe_Map.sCrackingRecipes.isValidCatalystFluid(tHatch.getFillableStack())) {
+ rList.add(tHatch.getFillableStack());
+ }
+ }
+ }
+ for (GT_MetaTileEntity_Hatch_Input tHatch : mMiddleInputHatches) {
+ tHatch.mRecipeMap = getRecipeMap();
+ if (isValidMetaTileEntity(tHatch) && tHatch.getFillableStack() != null) {
+ FluidStack tStack = tHatch.getFillableStack();
+ if (GT_Recipe.GT_Recipe_Map.sCrackingRecipes.isValidCatalystFluid(tStack)) {
+ rList.add(tStack);
+ }
+ }
+ }
+ return rList;
+ }
+
+ @Override
+ public IStructureDefinition<GT_MetaTileEntity_OilCracker> getStructureDefinition() {
+ return (IStructureDefinition) STRUCTURE_DEFINITION;
+ }
+
+ private void onCasingAdded() {
+ mCasingAmount++;
+ }
+
+ private byte glasTier;
+
+ private boolean addGlas(Block block, int meta) {
+ if (block != ItemRegistry.bw_glasses[0]) {
+ return false;
+ }
+ byte tier = BW_Util.getTierFromGlasMeta(meta);
+ if (glasTier > 0) {
+ return tier == glasTier;
+ }
+ glasTier = tier;
+ return true;
+ }
+
+ private void onCoilAdded() {
+ mCoilAmount++;
+ }
+
+
+
+ @Override
+ public String[] getInfoData() {
+ return LoaderReference.tectech ? this.getInfoDataArray(this) : super.getInfoData();
+ }
+
+ @Override
+ @Optional.Method(modid = "tectech")
+ public List<GT_MetaTileEntity_Hatch_Energy> getVanillaEnergyHatches() {
+ return this.mEnergyHatches;
+ }
+
+ @Override
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ @Optional.Method(modid = "tectech")
+ public List getTecTechEnergyTunnels() {
+ return TTTunnels;
+ }
+
+ @Override
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ @Optional.Method(modid = "tectech")
+ public List getTecTechEnergyMultis() {
+ return TTMultiAmp;
+ }
+
+
+}