aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common
diff options
context:
space:
mode:
authorbartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com>2020-12-28 15:02:27 +0100
committerbartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com>2020-12-28 15:02:27 +0100
commit4e04bf5e76ad92e1cc1b2b2eeaa0bc141975e73a (patch)
treeaae503654a69a45f50e7266c9b2069f288aa848f /src/main/java/gregtech/common
parentfae05f1aa4959c5b165400ed41398685c90a047a (diff)
downloadGT5-Unofficial-4e04bf5e76ad92e1cc1b2b2eeaa0bc141975e73a.tar.gz
GT5-Unofficial-4e04bf5e76ad92e1cc1b2b2eeaa0bc141975e73a.tar.bz2
GT5-Unofficial-4e04bf5e76ad92e1cc1b2b2eeaa0bc141975e73a.zip
More Refactor
Diffstat (limited to 'src/main/java/gregtech/common')
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java42
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java219
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java337
3 files changed, 293 insertions, 305 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java
index d4643ab4c8..33d071dc6f 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java
@@ -26,8 +26,6 @@ import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.input.Keyboard;
-import java.util.ArrayList;
-
import static gregtech.api.enums.GT_Values.V;
import static gregtech.api.enums.GT_Values.VN;
@@ -108,44 +106,10 @@ public class GT_MetaTileEntity_ElectricBlastFurnace
}
public boolean checkRecipe(ItemStack aStack) {
- ArrayList<ItemStack> tInputList = getStoredInputs();
- int tInputList_sS = tInputList.size();
- for (int i = 0; i < tInputList_sS - 1; i++) {
- for (int j = i + 1; j < tInputList_sS; j++) {
- if (!GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j)))
- continue;
-
- if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) {
- tInputList.remove(j--);
- tInputList_sS = tInputList.size();
- } else {
- tInputList.remove(i--);
- tInputList_sS = tInputList.size();
- break;
- }
- }
- }
- ItemStack[] tInputs = tInputList.toArray(new ItemStack[0]);
+ ItemStack[] tInputs = getCompactedInputs();
+ FluidStack[] tFluids = getCompactedFluids();
- ArrayList<FluidStack> tFluidList = getStoredFluids();
- int tFluidList_sS = tFluidList.size();
- for (int i = 0; i < tFluidList_sS - 1; i++) {
- for (int j = i + 1; j < tFluidList_sS; j++) {
- if (!GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j)))
- continue;
-
- if (tFluidList.get(i).amount >= tFluidList.get(j).amount) {
- tFluidList.remove(j--);
- tFluidList_sS = tFluidList.size();
- } else {
- tFluidList.remove(i--);
- tFluidList_sS = tFluidList.size();
- break;
- }
- }
- }
- FluidStack[] tFluids = tFluidList.toArray(new FluidStack[0]);
- if (tInputList.size() <= 0)
+ if (tInputs.length <= 0)
return false;
long tVoltage = getMaxInputVoltage();
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java
index 5738703aef..67d696438d 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java
@@ -21,10 +21,11 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
+import org.apache.commons.lang3.mutable.MutableInt;
+import org.lwjgl.input.Keyboard;
import java.util.ArrayList;
-
-import org.lwjgl.input.Keyboard;
+import java.util.BitSet;
public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBase {
private ForgeDirection orientation;
@@ -136,130 +137,120 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa
@Override
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
- heatLevel = HeatingCoilLevel.None;
+ this.heatLevel = HeatingCoilLevel.None;
this.orientation = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing());
this.controllerX = aBaseMetaTileEntity.getXCoord();
this.controllerZ = aBaseMetaTileEntity.getZCoord();
int xDir = this.orientation.offsetX;
int zDir = this.orientation.offsetZ;
- int amount = 0;
+ MutableInt amount = new MutableInt(0);
replaceDeprecatedCoils(aBaseMetaTileEntity);
- boolean negSideInput = false, negSideOutput = false, posSideInput = false, posSideOutput = false;
- // zDirection
- // height
- // xDirection
- // height
- if (xDir != 0) {
- for (int i = -1; i < 2; i++)
- for (int j = -1; j < 2; j++)
- for (int h = -2; h < 3; h++) {
- if (j == 0 && i == 0 && (h == -1 || h == 0 || h == 1))
- continue;
- if (h == 1 || h == -1) {
- if (coilsNotPresent(aBaseMetaTileEntity, xDir + h, j, i + zDir))
- return false;
- }
- if (h == 2 || h == -2) {
- IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, j, h + zDir);
- if (addInputToMachineList(tTileEntity, CASING_INDEX))
- if (h == -2)
- negSideInput = true;
- else
- posSideInput = true;
- else if (addOutputToMachineList(tTileEntity, CASING_INDEX))
- if (h == -2)
- negSideOutput = true;
- else
- posSideOutput = true;
- else if (!addEnergyInputToMachineList(tTileEntity, CASING_INDEX))
- if (!addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) {
- if (aBaseMetaTileEntity.getBlockOffset(xDir + i, j, h + zDir) != GregTech_API.sBlockCasings4)
- return false;
- if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, j, h + zDir) != 1)
- return false;
- amount++;
- }
- }
- if (h == 0) {
- IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, j, h + zDir);
- if (addMaintenanceToMachineList(tTileEntity, CASING_INDEX))
- continue;
- if (addInputToMachineList(tTileEntity, CASING_INDEX))
- continue;
- if (addEnergyInputToMachineList(tTileEntity, CASING_INDEX))
- continue;
- if ((xDir + i) == 0 && j == 0 && (h + zDir) == 0)
- continue;
- if (aBaseMetaTileEntity.getBlockOffset(xDir + i, j, h + zDir) != GregTech_API.sBlockCasings4)
- return false;
- if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, j, h + zDir) != 1)
- return false;
- amount++;
- }
-
- }
- } else
- for (int i = -1; i < 2; i++)
- for (int j = -1; j < 2; j++)
- for (int h = -2; h < 3; h++) {
- if (j == 0 && i == 0 && (h == -1 || h == 0 || h == 1))
- continue;
- if (h == 1 || h == -1) {
- if (coilsNotPresent(aBaseMetaTileEntity, xDir + h, j, i + zDir))
- return false;
- } else {
- IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + h, j, i + zDir);
- if (h == 2 || h == -2) {
- if (addInputToMachineList(tTileEntity, CASING_INDEX))
- if (h == -2)
- negSideInput = true;
- else
- posSideInput = true;
- else if (addOutputToMachineList(tTileEntity, CASING_INDEX)) {
- if (h == -2)
- negSideOutput = true;
- else
- posSideOutput = true;
- } else {
- if (addEnergyInputToMachineList(tTileEntity, CASING_INDEX))
- continue;
- if (addMaintenanceToMachineList(tTileEntity, CASING_INDEX))
- continue;
- if (aBaseMetaTileEntity.getBlockOffset(xDir + h, j, i + zDir) != GregTech_API.sBlockCasings4)
- return false;
- if (aBaseMetaTileEntity.getMetaIDOffset(xDir + h, j, i + zDir) != 1)
- return false;
- amount++;
- }
- } else {
- if (addMaintenanceToMachineList(tTileEntity, CASING_INDEX))
- continue;
- if (addInputToMachineList(tTileEntity, CASING_INDEX))
- continue;
- if (addEnergyInputToMachineList(tTileEntity, CASING_INDEX))
- continue;
-
- if (j == 0 && i + zDir == 0)
- continue;
- if (aBaseMetaTileEntity.getBlockOffset(0, j, i + zDir) != GregTech_API.sBlockCasings4)
- return false;
- if (aBaseMetaTileEntity.getMetaIDOffset(0, j, i + zDir) != 1)
- return false;
- amount++;
- }
- }
+ BitSet flags = new BitSet(4);
+
+ for (int depth = -1; depth < 2; depth++)
+ for (int height = -1; height < 2; height++)
+ for (int slice = -2; slice < 3; slice++)
+ if (xDir != 0) {
+ if (isStructureBroken(xDir, zDir, depth, height, slice, aBaseMetaTileEntity, amount, flags))
+ return false;
+ } else {
+ if (isStructureBroken(xDir, zDir, slice, height, depth, aBaseMetaTileEntity, amount, flags))
+ return false;
}
- if (negSideInput && negSideOutput)
+ if(checkInputOutputBroken(flags))
return false;
- if (posSideInput && posSideOutput)
+
+ return amount.intValue() >= 18;
+ }
+
+ private boolean checkInputOutputBroken(BitSet flags){
+ if (flags.get(0) && flags.get(2)) //input and output on side 1
+ return true;
+ if (flags.get(1) && flags.get(3)) //input and output on side 2
+ return true;
+ if (flags.get(1) && flags.get(2)) //input on both sides
+ return true;
+ return flags.get(2) && flags.get(3); //output on both sides
+ }
+
+ private boolean isStructureBroken(
+ int xDir,
+ int zDir,
+ int a,
+ int b,
+ int c,
+ IGregTechTileEntity aBaseMetaTileEntity,
+ MutableInt amount,
+ BitSet flags) {
+ if (b == 0 && c == 0 && (a == -1 || a == 0 || a == 1))
return false;
- if (negSideInput && posSideInput)
+ if (a == 1 || a == -1) {
+ return coilsNotPresent(aBaseMetaTileEntity, xDir + a, b, c + zDir);
+ }
+ else if (a == 2 || a == -2) {
+ return checkEndsBroken(xDir, zDir, a, b, c, aBaseMetaTileEntity, amount, flags);
+ }
+ else if (a == 0)
+ return checkMiddleBroken(xDir, zDir, a, b, c, aBaseMetaTileEntity, amount);
+
+ return false;
+ }
+
+ private boolean checkEndsBroken(
+ int xDir,
+ int zDir,
+ int a,
+ int b,
+ int c,
+ IGregTechTileEntity aBaseMetaTileEntity,
+ MutableInt amount,
+ BitSet flags
+ ){
+ IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + c, b, a + zDir);
+ if (addInputToMachineList(tTileEntity, CASING_INDEX))
+ if (a == -2)
+ flags.set(0); //input on side 1
+ else
+ flags.set(1); //input on side 2
+ else if (addOutputToMachineList(tTileEntity, CASING_INDEX))
+ if (a == -2)
+ flags.set(2); //output on side 1
+ else
+ flags.set(3); //output on side 2
+ else if (!addEnergyInputToMachineList(tTileEntity, CASING_INDEX))
+ if (!addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) {
+ if (aBaseMetaTileEntity.getBlockOffset(xDir + c, b, a + zDir) != GregTech_API.sBlockCasings4)
+ return true;
+ if (aBaseMetaTileEntity.getMetaIDOffset(xDir + c, b, a + zDir) != 1)
+ return true;
+ amount.increment();
+ }
+ return false;
+ }
+
+ private boolean checkMiddleBroken( int xDir,
+ int zDir,
+ int a,
+ int b,
+ int c,
+ IGregTechTileEntity aBaseMetaTileEntity,
+ MutableInt amount){
+ IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + c, b, a + zDir);
+ if (addMaintenanceToMachineList(tTileEntity, CASING_INDEX))
return false;
- if (negSideOutput && posSideOutput)
+ if (addInputToMachineList(tTileEntity, CASING_INDEX))
return false;
-
- return amount >= 18;
+ if (addEnergyInputToMachineList(tTileEntity, CASING_INDEX))
+ return false;
+ if ((xDir + c) == 0 && b == 0 && (a + zDir) == 0)
+ return false;
+ if (aBaseMetaTileEntity.getBlockOffset(xDir + c, b, a + zDir) != GregTech_API.sBlockCasings4)
+ return true;
+ if (aBaseMetaTileEntity.getMetaIDOffset(xDir + c, b, a + zDir) != 1)
+ return true;
+ amount.increment();
+ return false;
}
@Override
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java
index b4e657295e..96c661e283 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java
@@ -22,16 +22,14 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
+import org.apache.commons.lang3.mutable.MutableBoolean;
import org.lwjgl.input.Keyboard;
-import java.util.ArrayList;
-import java.util.Arrays;
-
public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlockBase {
-
- private HeatingCoilLevel coilHeat;
- //public static GT_CopiedBlockTexture mTextureULV = new GT_CopiedBlockTexture(Block.getBlockFromItem(ItemList.Casing_ULV.get(1).getItem()), 6, 0, Dyes.MACHINE_METAL.mRGBa);
- private static final int CASING_INDEX = 1090;
+
+ private HeatingCoilLevel coilHeat;
+ //public static GT_CopiedBlockTexture mTextureULV = new GT_CopiedBlockTexture(Block.getBlockFromItem(ItemList.Casing_ULV.get(1).getItem()), 6, 0, Dyes.MACHINE_METAL.mRGBa);
+ private static final int CASING_INDEX = 1090;
public GT_MetaTileEntity_PyrolyseOven(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
@@ -42,32 +40,32 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock
}
public String[] getDescription() {
- final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
- tt.addMachineType("Coke Oven")
- .addInfo("Controller block for the Pyrolyse Oven")
- .addInfo("Industrial Charcoal producer")
- .addInfo("Processing speed scales linearly with Coil tier:")
- .addInfo("CuNi: 50%, FeAlCr: 100%, Ni4Cr: 150%, Fe50CW: 200%, etc.")
- .addInfo("EU/t is not affected by Coil tier")
- .addPollutionAmount(20 * getPollutionPerTick(null))
- .addSeparator()
- .beginStructureBlock(5, 4, 5, true)
- .addController("Front center")
- .addCasingInfo("Pyrolyse Oven Casing", 60)
- .addOtherStructurePart("Heating Coils", "Center 3x1x3 of the bottom layer")
- .addEnergyHatch("Any bottom layer casing")
- .addMaintenanceHatch("Any bottom layer casing")
- .addMufflerHatch("Center 3x1x3 area in top layer")
- .addInputBus("Center 3x1x3 area in top layer")
- .addInputHatch("Center 3x1x3 area in top layer")
- .addOutputBus("Any bottom layer casing")
- .addOutputHatch("Any bottom layer casing")
- .toolTipFinisher("Gregtech");
- if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
- return tt.getInformation();
- } else {
- return tt.getStructureInformation();
- }
+ final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
+ tt.addMachineType("Coke Oven")
+ .addInfo("Controller block for the Pyrolyse Oven")
+ .addInfo("Industrial Charcoal producer")
+ .addInfo("Processing speed scales linearly with Coil tier:")
+ .addInfo("CuNi: 50%, FeAlCr: 100%, Ni4Cr: 150%, Fe50CW: 200%, etc.")
+ .addInfo("EU/t is not affected by Coil tier")
+ .addPollutionAmount(20 * getPollutionPerTick(null))
+ .addSeparator()
+ .beginStructureBlock(5, 4, 5, true)
+ .addController("Front center")
+ .addCasingInfo("Pyrolyse Oven Casing", 60)
+ .addOtherStructurePart("Heating Coils", "Center 3x1x3 of the bottom layer")
+ .addEnergyHatch("Any bottom layer casing")
+ .addMaintenanceHatch("Any bottom layer casing")
+ .addMufflerHatch("Center 3x1x3 area in top layer")
+ .addInputBus("Center 3x1x3 area in top layer")
+ .addInputHatch("Center 3x1x3 area in top layer")
+ .addOutputBus("Any bottom layer casing")
+ .addOutputHatch("Any bottom layer casing")
+ .toolTipFinisher("Gregtech");
+ if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
+ return tt.getInformation();
+ } else {
+ return tt.getStructureInformation();
+ }
}
public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
@@ -83,42 +81,10 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock
@Override
public boolean checkRecipe(ItemStack aStack) {
- ArrayList<ItemStack> tInputList = getStoredInputs();
- int tInputList_sS=tInputList.size();
- for (int i = 0; i < tInputList_sS - 1; i++) {
- for (int j = i + 1; j < tInputList_sS; j++) {
- if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) {
- if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) {
- tInputList.remove(j--);
- tInputList_sS=tInputList.size();
- } else {
- tInputList.remove(i--);
- tInputList_sS=tInputList.size();
- break;
- }
- }
- }
- }
- ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[0]), 0, 2);
-
- ArrayList<FluidStack> tFluidList = getStoredFluids();
- int tFluidList_sS=tFluidList.size();
- for (int i = 0; i < tFluidList_sS - 1; i++) {
- for (int j = i + 1; j < tFluidList_sS; j++) {
- if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) {
- if (tFluidList.get(i).amount >= tFluidList.get(j).amount) {
- tFluidList.remove(j--);
- tFluidList_sS=tFluidList.size();
- } else {
- tFluidList.remove(i--);
- tFluidList_sS=tFluidList.size();
- break;
- }
- }
- }
- }
- FluidStack[] tFluids = Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1);
- if (tInputList.size() <= 0)
+ ItemStack[] tInputs = getCompactedInputs();
+ FluidStack[] tFluids = getCompactedFluids();
+
+ if (tInputs.length <= 0)
return false;
long tVoltage = getMaxInputVoltage();
@@ -126,19 +92,8 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock
GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sPyrolyseRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs);
//Dynamic recipe adding for newly found logWoods - wont be visible in nei most probably
- if(tRecipe == null)
- if (tInputs.length > 1 || (tInputs[0] != null && tInputs[0].getItem() != GT_Utility.getIntegratedCircuit(0).getItem())) {
- int oreId = OreDictionary.getOreID("logWood");
- outer : for(ItemStack is : tInputs) {
- for (int id : OreDictionary.getOreIDs(is)) {
- if (oreId == id) {
- ProcessingLog.addPyrolyeOvenRecipes(is);
- tRecipe = GT_Recipe.GT_Recipe_Map.sPyrolyseRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs);
- break outer;
- }
- }
- }
- }
+ if (tRecipe == null)
+ tRecipe = addRecipesDynamically(tInputs, tFluids, tTier);
if (tRecipe == null || !tRecipe.isRecipeInputEqual(true, tFluids, tInputs))
return false;
@@ -153,96 +108,69 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock
if (this.mEUt > 0)
this.mEUt = (-this.mEUt);
this.mMaxProgresstime = Math.max(mMaxProgresstime * 2 / (1 + coilHeat.getTier()), 1);
- if (tRecipe.mOutputs.length > 0) this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)};
+ if (tRecipe.mOutputs.length > 0)
+ this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)};
if (tRecipe.mFluidOutputs.length > 0)
this.mOutputFluids = new FluidStack[]{tRecipe.getFluidOutput(0)};
updateSlots();
return true;
}
+ private GT_Recipe addRecipesDynamically(ItemStack[] tInputs, FluidStack[] tFluids, int tTier) {
+ if (tInputs.length > 1 || (tInputs[0] != null && tInputs[0].getItem() != GT_Utility.getIntegratedCircuit(0).getItem())) {
+ int oreId = OreDictionary.getOreID("logWood");
+ for (ItemStack is : tInputs) {
+ for (int id : OreDictionary.getOreIDs(is)) {
+ if (oreId == id) {
+ ProcessingLog.addPyrolyeOvenRecipes(is);
+ return GT_Recipe.GT_Recipe_Map.sPyrolyseRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs);
+ }
+ }
+ }
+ }
+ return null;
+ }
+
@Override
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2;
int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2;
- Block CasingBlock;
- int CasingMeta;
+ Block casingBlock;
+ int casingMeta;
- if (Loader.isModLoaded("dreamcraft")){
- CasingBlock = GameRegistry.findBlock("dreamcraft","gt.blockcasingsNH");
- CasingMeta = 2;
+ if (Loader.isModLoaded("dreamcraft")) {
+ casingBlock = GameRegistry.findBlock("dreamcraft", "gt.blockcasingsNH");
+ casingMeta = 2;
} else {
- CasingBlock = GregTech_API.sBlockCasings1;
- CasingMeta = 0;
+ casingBlock = GregTech_API.sBlockCasings1;
+ casingMeta = 0;
}
replaceDeprecatedCoils(aBaseMetaTileEntity);
- boolean firstCoil = true;
+ MutableBoolean firstCoil = new MutableBoolean(true);
for (int i = -2; i < 3; i++) {
for (int j = -2; j < 3; j++) {
for (int h = 0; h < 4; h++) {
IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j);
if ((i != -2 && i != 2) && (j != -2 && j != 2)) {// inner 3x3 without height
- if (h == 0) {// inner floor (Coils)
-
- Block coil = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j);
-
- if (!(coil instanceof IHeatingCoil))
- return false;
-
- int metaID = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j);
-
- HeatingCoilLevel coilHeat = ((IHeatingCoil)coil).getCoilHeat(metaID);
-
- if (coilHeat == HeatingCoilLevel.None) {
- return false;
- } else {
- if (firstCoil) {
- this.coilHeat = coilHeat;
- firstCoil = false;
- } else if (coilHeat != this.coilHeat) {
- return false;
- }
- }
- } else if (h == 3) {// inner ceiling (ulv casings + input + muffler)
- if ((addInputToMachineList(tTileEntity, CASING_INDEX)) || (addMufflerToMachineList(tTileEntity, CASING_INDEX))) {
- continue;
- }
- if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != CasingBlock) {
- return false;
- }
- if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != CasingMeta) {
- return false;
- }
- } else {// inside air
- if (!aBaseMetaTileEntity.getAirOffset(xDir + i, h, zDir + j)) {
- return false;
- }
- }
- } else {// outer 5x5 without height
- if (h == 0) {// outer floor (controller, output, energy, maintainance, rest ulv casings)
- if (addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) {
- continue;
- }
-
- if (addOutputToMachineList(tTileEntity, CASING_INDEX)) {
- continue;
- }
-
- if (addEnergyInputToMachineList(tTileEntity, CASING_INDEX)) {
- continue;
- }
-
- if ((xDir + i == 0) && (zDir + j == 0)) {
- continue;
- }//no controller
- }
- // outer above floor (ulv casings)
- if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != CasingBlock) {
+ if (checkInnerBroken(
+ xDir, zDir,
+ i, h, j,
+ aBaseMetaTileEntity, tTileEntity,
+ casingBlock, casingMeta,
+ firstCoil
+ )
+ )
return false;
- }
- if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != CasingMeta) {
+ } else {// outer 5x5 without height
+ if (checkOuterBroken(
+ xDir, zDir,
+ i, h, j,
+ aBaseMetaTileEntity, tTileEntity,
+ casingBlock, casingMeta
+ )
+ )
return false;
- }
}
}
}
@@ -250,6 +178,112 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock
return true;
}
+ private boolean checkInnerBroken(int xDir,
+ int zDir,
+ int a,
+ int b,
+ int c,
+ IGregTechTileEntity aBaseMetaTileEntity,
+ IGregTechTileEntity tTileEntity,
+ Block casingBlock,
+ int casingMeta,
+ MutableBoolean firstCoil
+ ) {
+ if (b == 0) {// inner floor (Coils)
+ return areCoilsBroken(xDir, zDir, a, b, c, aBaseMetaTileEntity, firstCoil);
+ } else if (b == 3) {// inner ceiling (ulv casings + input + muffler)
+ return checkInnerCeilingBroken(xDir, zDir, a, b, c, aBaseMetaTileEntity, tTileEntity, casingBlock, casingMeta);
+ } else {// inside air
+ return !aBaseMetaTileEntity.getAirOffset(xDir + a, b, zDir + c);
+ }
+ }
+
+ private boolean checkOuterBroken(int xDir,
+ int zDir,
+ int a,
+ int b,
+ int c,
+ IGregTechTileEntity aBaseMetaTileEntity,
+ IGregTechTileEntity tTileEntity,
+ Block casingBlock,
+ int casingMeta) {
+ if (b == 0) {// outer floor (controller, output, energy, maintainance, rest ulv casings)
+ if (checkOuterFloorLoopControl(xDir, zDir, a, c, tTileEntity))
+ return false;
+ }
+ // outer above floor (ulv casings)
+ if (aBaseMetaTileEntity.getBlockOffset(xDir + a, b, zDir + c) != casingBlock) {
+ return true;
+ }
+ return aBaseMetaTileEntity.getMetaIDOffset(xDir + a, b, zDir + c) != casingMeta;
+ }
+
+ private boolean checkOuterFloorLoopControl(int xDir,
+ int zDir,
+ int a,
+ int c,
+ IGregTechTileEntity tTileEntity
+ ) {
+ if (addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) {
+ return true;
+ }
+ if (addOutputToMachineList(tTileEntity, CASING_INDEX)) {
+ return true;
+ }
+
+ if (addEnergyInputToMachineList(tTileEntity, CASING_INDEX)) {
+ return true;
+ }
+
+ return (xDir + a == 0) && (zDir + c == 0);
+ }
+
+ private boolean checkInnerCeilingBroken(int xDir,
+ int zDir,
+ int a,
+ int b,
+ int c,
+ IGregTechTileEntity aBaseMetaTileEntity,
+ IGregTechTileEntity tTileEntity,
+ Block casingBlock,
+ int casingMeta) {
+ if ((addInputToMachineList(tTileEntity, CASING_INDEX)) || (addMufflerToMachineList(tTileEntity, CASING_INDEX))) {
+ return false;
+ }
+ if (aBaseMetaTileEntity.getBlockOffset(xDir + a, b, zDir + c) != casingBlock) {
+ return true;
+ }
+ return aBaseMetaTileEntity.getMetaIDOffset(xDir + a, b, zDir + c) != casingMeta;
+ }
+
+ private boolean areCoilsBroken(int xDir,
+ int zDir,
+ int a,
+ int b,
+ int c,
+ IGregTechTileEntity aBaseMetaTileEntity,
+ MutableBoolean firstCoil
+ ) {
+ Block coil = aBaseMetaTileEntity.getBlockOffset(xDir + a, b, zDir + c);
+
+ if (!(coil instanceof IHeatingCoil))
+ return true;
+
+ int metaID = aBaseMetaTileEntity.getMetaIDOffset(xDir + a, b, zDir + c);
+
+ HeatingCoilLevel coilHeat = ((IHeatingCoil) coil).getCoilHeat(metaID);
+
+ if (coilHeat == HeatingCoilLevel.None) {
+ return true;
+ } else {
+ if (firstCoil.isTrue()) {
+ this.coilHeat = coilHeat;
+ firstCoil.setFalse();
+ } else return coilHeat != this.coilHeat;
+ }
+ return false;
+ }
+
@Override
public boolean isCorrectMachinePart(ItemStack aStack) {
return true;
@@ -288,8 +322,7 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock
for (int xPos = tX - 1; xPos <= tX + 1; xPos++) {
for (int zPos = tZ - 1; zPos <= tZ + 1; zPos++) {
if (aBaseMetaTileEntity.getBlock(xPos, tY, zPos) == GregTech_API.sBlockCasings1 &&
- aBaseMetaTileEntity.getMetaID(xPos, tY, zPos) == 13)
- {
+ aBaseMetaTileEntity.getMetaID(xPos, tY, zPos) == 13) {
aBaseMetaTileEntity.getWorld().setBlock(xPos, tY, zPos, GregTech_API.sBlockCasings5, 1, 3);
}
}