aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/tileentities
diff options
context:
space:
mode:
authorbartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com>2020-12-28 18:15:54 +0100
committerGitHub <noreply@github.com>2020-12-28 18:15:54 +0100
commit748fe043379899876ee079d3d414f50b5dfad9b6 (patch)
tree1c9b3af776c21a0278fcd3b455300d18f5c9d5ad /src/main/java/gregtech/common/tileentities
parent5da080296a9a04aaee27bc88036650c8c26820ce (diff)
parent7fb679c5bec20dc8caa40b3a92b2a6590912f6f9 (diff)
downloadGT5-Unofficial-748fe043379899876ee079d3d414f50b5dfad9b6.tar.gz
GT5-Unofficial-748fe043379899876ee079d3d414f50b5dfad9b6.tar.bz2
GT5-Unofficial-748fe043379899876ee079d3d414f50b5dfad9b6.zip
Merge pull request #380 from GTNewHorizons/CoilsLogicRework
Heating Coil Logic Overhaul
Diffstat (limited to 'src/main/java/gregtech/common/tileentities')
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java98
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java505
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java298
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java351
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java365
5 files changed, 844 insertions, 773 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java
new file mode 100644
index 0000000000..1ac4df6d73
--- /dev/null
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java
@@ -0,0 +1,98 @@
+package gregtech.common.tileentities.machines.multi;
+
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.HeatingCoilLevel;
+import gregtech.api.interfaces.IHeatingCoil;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
+import net.minecraft.block.Block;
+import net.minecraft.item.ItemStack;
+
+public abstract class GT_MetaTileEntity_AbstractMultiFurnace extends GT_MetaTileEntity_MultiBlockBase {
+
+ private static final int CASING_INDEX = 11;
+
+ protected GT_MetaTileEntity_AbstractMultiFurnace(int aID, String aName, String aNameRegional) {
+ super(aID, aName, aNameRegional);
+ }
+
+ protected GT_MetaTileEntity_AbstractMultiFurnace(String aName) {
+ super(aName);
+ }
+
+ @Override
+ public boolean isCorrectMachinePart(ItemStack aStack) {
+ return true;
+ }
+
+ @Override
+ public boolean isFacingValid(byte aFacing) {
+ return aFacing > 1;
+ }
+
+ protected HeatingCoilLevel getInitialHeatLevel(IGregTechTileEntity aBaseMetaTileEntity, int xDir, int zDir) {
+ Block coil = aBaseMetaTileEntity.getBlockOffset(xDir + 1, 1, zDir);
+ if (!(coil instanceof IHeatingCoil))
+ return null;
+ IHeatingCoil heatingCoil = (IHeatingCoil) coil;
+ byte tUsedMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + 1, 1, zDir);
+ return heatingCoil.getCoilHeat(tUsedMeta);
+ }
+
+ protected boolean checkStructure(HeatingCoilLevel heatingCap, int xDir, int zDir, IGregTechTileEntity aBaseMetaTileEntity){
+ for (int i = -1; i < 2; i++) {
+ for (int j = -1; j < 2; j++) {
+ if (!checkTopLayer(i, j, xDir, zDir, aBaseMetaTileEntity))
+ return false;
+
+ if (!checkBottomLayer(i, j, xDir, zDir, aBaseMetaTileEntity))
+ return false;
+
+ if (!checkCoils(heatingCap, i, j, xDir, zDir, aBaseMetaTileEntity))
+ return false;
+ }
+ }
+ return true;
+ }
+
+ protected abstract boolean checkTopLayer(int i, int j, int xDir, int zDir, IGregTechTileEntity aBaseMetaTileEntity);
+ protected abstract boolean checkCoils(HeatingCoilLevel heatingCap, int i, int j, int xDir, int zDir, IGregTechTileEntity aBaseMetaTileEntity);
+
+ protected boolean checkBottomLayer(int i, int j, int xDir, int zDir, IGregTechTileEntity aBaseMetaTileEntity){
+ if ((xDir + i == 0) && (zDir + j == 0))
+ return true;
+ IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 0, zDir + j);
+ if (addMaintenanceToMachineList(tTileEntity, CASING_INDEX))
+ return true;
+ if (addInputToMachineList(tTileEntity, CASING_INDEX))
+ return true;
+ if (addOutputToMachineList(tTileEntity, CASING_INDEX))
+ return true;
+ if (addEnergyInputToMachineList(tTileEntity, CASING_INDEX))
+ return true;
+
+ if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 0, zDir + j) != GregTech_API.sBlockCasings1)
+ return false;
+ return aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 0, zDir + j) == CASING_INDEX;
+ }
+
+ @Override
+ public int getMaxEfficiency(ItemStack aStack) {
+ return 10000;
+ }
+
+ @Override
+ public int getPollutionPerTick(ItemStack aStack) {
+ return 20;
+ }
+
+ @Override
+ public int getDamageToComponent(ItemStack aStack) {
+ return 0;
+ }
+
+ @Override
+ public boolean explodesOnComponentBreak(ItemStack aStack) {
+ return false;
+ }
+}
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 061db80ece..488703d2b5 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
@@ -1,42 +1,43 @@
package gregtech.common.tileentities.machines.multi;
-import static gregtech.api.enums.GT_Values.V;
-import static gregtech.api.enums.GT_Values.VN;
-
-import java.util.ArrayList;
-
-import org.lwjgl.input.Keyboard;
-
import gregtech.api.GregTech_API;
+import gregtech.api.enums.HeatingCoilLevel;
import gregtech.api.enums.Materials;
import gregtech.api.enums.Textures;
import gregtech.api.gui.GT_GUIContainer_MultiMachine;
+import gregtech.api.interfaces.IHeatingCoil;
import gregtech.api.interfaces.ITexture;
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_Muffler;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
+import net.minecraft.block.Block;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
+import org.lwjgl.input.Keyboard;
+
+import static gregtech.api.enums.GT_Values.V;
+import static gregtech.api.enums.GT_Values.VN;
public class GT_MetaTileEntity_ElectricBlastFurnace
- extends GT_MetaTileEntity_MultiBlockBase {
+ extends GT_MetaTileEntity_AbstractMultiFurnace {
private int mHeatingCapacity = 0;
private int controllerY;
private FluidStack[] pollutionFluidStacks = new FluidStack[]{Materials.CarbonDioxide.getGas(1000),
Materials.CarbonMonoxide.getGas(1000), Materials.SulfurDioxide.getGas(1000)};
+ private static final int CASING_INDEX = 11;
+
public GT_MetaTileEntity_ElectricBlastFurnace(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
}
@@ -45,173 +46,168 @@ public class GT_MetaTileEntity_ElectricBlastFurnace
super(aName);
}
+ @Override
public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new GT_MetaTileEntity_ElectricBlastFurnace(this.mName);
}
+ @Override
public String[] getDescription() {
- final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
- tt.addMachineType("Blast Furnace")
- .addInfo("Controller block for the Electric Blast Furnace")
- .addInfo("You can use some fluids to reduce recipe time. Place the circuit in the Input Bus")
- .addInfo("Each 900K over the min. Heat required multiplies EU/t by 0.95")
- .addInfo("Each 1800K over the min. Heat required allows for one upgraded overclock instead of normal")
- .addInfo("Upgraded overclocks reduce recipe time to 25% (instead of 50%) and increase EU/t to 400%")
- .addInfo("Additionally gives +100K for every tier past MV")
- .addPollutionAmount(20 * getPollutionPerTick(null))
- .addSeparator()
- .beginStructureBlock(3, 4, 3, true)
- .addController("Front bottom")
- .addCasingInfo("Heat Proof Machine Casing", 0)
- .addOtherStructurePart("Heating Coils (any tier)", "Two middle Layers")
- .addEnergyHatch("Any bottom layer casing")
- .addMaintenanceHatch("Any bottom layer casing")
- .addMufflerHatch("Top middle")
- .addInputBus("Any bottom layer casing")
- .addInputHatch("Any bottom layer casing")
- .addOutputBus("Any bottom layer casing")
- .addOutputHatch("Gasses, Any top layer casing")
- .addStructureInfo("Recovery amount scales with Muffler Hatch tier")
- .addOutputHatch("Platline fluids, 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("Blast Furnace")
+ .addInfo("Controller block for the Electric Blast Furnace")
+ .addInfo("You can use some fluids to reduce recipe time. Place the circuit in the Input Bus")
+ .addInfo("Each 900K over the min. Heat required multiplies EU/t by 0.95")
+ .addInfo("Each 1800K over the min. Heat required allows for one upgraded overclock instead of normal")
+ .addInfo("Upgraded overclocks reduce recipe time to 25% (instead of 50%) and increase EU/t to 400%")
+ .addInfo("Additionally gives +100K for every tier past MV")
+ .addPollutionAmount(20 * getPollutionPerTick(null))
+ .addSeparator()
+ .beginStructureBlock(3, 4, 3, true)
+ .addController("Front bottom")
+ .addCasingInfo("Heat Proof Machine Casing", 0)
+ .addOtherStructurePart("Heating Coils", "Two middle Layers")
+ .addEnergyHatch("Any bottom layer casing")
+ .addMaintenanceHatch("Any bottom layer casing")
+ .addMufflerHatch("Top middle")
+ .addInputBus("Any bottom layer casing")
+ .addInputHatch("Any bottom layer casing")
+ .addOutputBus("Any bottom layer casing")
+ .addOutputHatch("Gasses, Any top layer casing")
+ .addStructureInfo("Recovery amount scales with Muffler Hatch tier")
+ .addOutputHatch("Platline fluids, Any bottom layer casing")
+ .toolTipFinisher("Gregtech");
+ if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
+ return tt.getInformation();
+ } else {
+ return tt.getStructureInformation();
+ }
}
+ @Override
public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
if (aSide == aFacing) {
- return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][11], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE)};
+ return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][CASING_INDEX], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE)};
}
- return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][11]};
+ return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][CASING_INDEX]};
}
+ @Override
public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "ElectricBlastFurnace.png");
}
+ @Override
public GT_Recipe.GT_Recipe_Map getRecipeMap() {
return GT_Recipe.GT_Recipe_Map.sBlastRecipes;
}
+ @Override
public boolean isCorrectMachinePart(ItemStack aStack) {
return true;
}
+ @Override
public boolean isFacingValid(byte aFacing) {
return aFacing > 1;
}
+ @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 = tInputList.toArray(new ItemStack[tInputList.size()]);
-
- 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;
- }
- }
- }
+ ItemStack[] tInputs = getCompactedInputs();
+ FluidStack[] tFluids = getCompactedFluids();
+
+ if (tInputs.length <= 0)
+ return false;
+
+ long tVoltage = getMaxInputVoltage();
+ byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage));
+ GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sBlastRecipes.findRecipe(
+ getBaseMetaTileEntity(),
+ false,
+ gregtech.api.enums.GT_Values.V[tTier],
+ tFluids,
+ tInputs
+ );
+
+ if (tRecipe == null)
+ return false;
+ if (this.mHeatingCapacity < tRecipe.mSpecialValue)
+ return false;
+ if (!tRecipe.isRecipeInputEqual(true, tFluids, tInputs))
+ return false;
+
+ this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
+ this.mEfficiencyIncrease = 10000;
+ int tHeatCapacityDivTiers = (mHeatingCapacity - tRecipe.mSpecialValue) / 900;
+ byte overclockCount = calculateOverclockednessEBF(tRecipe.mEUt, tRecipe.mDuration, tVoltage);
+ //In case recipe is too OP for that machine
+ if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1)
+ return false;
+ if (this.mEUt > 0) {
+ this.mEUt = (-this.mEUt);
}
- FluidStack[] tFluids = tFluidList.toArray(new FluidStack[tFluidList.size()]);
- if (tInputList.size() > 0) {
- long tVoltage = getMaxInputVoltage();
- byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage));
- GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sBlastRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs);
- if ((tRecipe != null) && (this.mHeatingCapacity >= tRecipe.mSpecialValue) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) {
- this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
- this.mEfficiencyIncrease = 10000;
- int tHeatCapacityDivTiers = (mHeatingCapacity - tRecipe.mSpecialValue)/900;
- byte overclockCount=calculateOverclockednessEBF(tRecipe.mEUt, tRecipe.mDuration, tVoltage);
- //In case recipe is too OP for that machine
- if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1)
- return false;
- if (this.mEUt > 0) {
- this.mEUt = (-this.mEUt);
- }
- if(tHeatCapacityDivTiers>0){
- this.mEUt = (int) (this.mEUt * (Math.pow(0.95, tHeatCapacityDivTiers)));
- this.mMaxProgresstime >>=Math.min(tHeatCapacityDivTiers/2,overclockCount);//extra free overclocking if possible
- if(this.mMaxProgresstime<1) this.mMaxProgresstime=1;//no eu efficiency correction
- }
- this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
- this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)};
- this.mOutputFluids = new FluidStack[]{tRecipe.getFluidOutput(0)};
- updateSlots();
- return true;
- }
+ if (tHeatCapacityDivTiers > 0) {
+ this.mEUt = (int) (this.mEUt * (Math.pow(0.95, tHeatCapacityDivTiers)));
+ this.mMaxProgresstime >>= Math.min(tHeatCapacityDivTiers / 2, overclockCount);//extra free overclocking if possible
+ if (this.mMaxProgresstime < 1)
+ this.mMaxProgresstime = 1;//no eu efficiency correction
}
- return false;
+ this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
+ this.mOutputItems = new ItemStack[]{
+ tRecipe.getOutput(0),
+ tRecipe.getOutput(1)
+ };
+ this.mOutputFluids = new FluidStack[]{
+ tRecipe.getFluidOutput(0)
+ };
+ updateSlots();
+ return true;
}
/**
* Calcualtes overclocked ness using long integers
- * @param aEUt - recipe EUt
- * @param aDuration - recipe Duration
+ *
+ * @param aEUt - recipe EUt
+ * @param aDuration - recipe Duration
*/
protected byte calculateOverclockednessEBF(int aEUt, int aDuration, long maxInputVoltage) {
- byte mTier=(byte)Math.max(0,GT_Utility.getTier(maxInputVoltage)), timesOverclocked=0;
- if(mTier==0){
+ byte mTier = (byte) Math.max(0, GT_Utility.getTier(maxInputVoltage)), timesOverclocked = 0;
+ if (mTier == 0) {
//Long time calculation
- long xMaxProgresstime = ((long)aDuration)<<1;
- if(xMaxProgresstime>Integer.MAX_VALUE-1){
+ long xMaxProgresstime = ((long) aDuration) << 1;
+ if (xMaxProgresstime > Integer.MAX_VALUE - 1) {
//make impossible if too long
- mEUt=Integer.MAX_VALUE-1;
- mMaxProgresstime=Integer.MAX_VALUE-1;
- }else{
- mEUt=aEUt>>2;
- mMaxProgresstime=(int)xMaxProgresstime;
+ mEUt = Integer.MAX_VALUE - 1;
+ mMaxProgresstime = Integer.MAX_VALUE - 1;
+ } else {
+ mEUt = aEUt >> 2;
+ mMaxProgresstime = (int) xMaxProgresstime;
}
//return 0;
- }else{
+ } else {
//Long EUt calculation
- long xEUt=aEUt;
+ long xEUt = aEUt;
//Isnt too low EUt check?
- long tempEUt = xEUt<V[1] ? V[1] : xEUt;
+ long tempEUt = Math.max(xEUt, V[1]);
mMaxProgresstime = aDuration;
- while (tempEUt <= V[mTier -1]) {
- tempEUt<<=2;//this actually controls overclocking
+ while (tempEUt <= V[mTier - 1]) {
+ tempEUt <<= 2;//this actually controls overclocking
//xEUt *= 4;//this is effect of everclocking
- mMaxProgresstime>>=1;//this is effect of overclocking
- xEUt = mMaxProgresstime==0 ? xEUt>>1 : xEUt<<2;//U know, if the time is less than 1 tick make the machine use less power
+ mMaxProgresstime >>= 1;//this is effect of overclocking
+ xEUt = mMaxProgresstime == 0 ? xEUt >> 1 : xEUt << 2;//U know, if the time is less than 1 tick make the machine use less power
timesOverclocked++;
}
- if(xEUt>Integer.MAX_VALUE-1){
- mEUt = Integer.MAX_VALUE-1;
- mMaxProgresstime = Integer.MAX_VALUE-1;
- }else{
- mEUt = (int)xEUt;
- if(mEUt==0)
+ if (xEUt > Integer.MAX_VALUE - 1) {
+ mEUt = Integer.MAX_VALUE - 1;
+ mMaxProgresstime = Integer.MAX_VALUE - 1;
+ } else {
+ mEUt = (int) xEUt;
+ if (mEUt == 0)
mEUt = 1;
- if(mMaxProgresstime==0)
+ if (mMaxProgresstime == 0)
mMaxProgresstime = 1;//set time to 1 tick
}
}
@@ -224,171 +220,136 @@ public class GT_MetaTileEntity_ElectricBlastFurnace
int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ;
this.mHeatingCapacity = 0;
- if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) {
- return false;
- }
- if (!aBaseMetaTileEntity.getAirOffset(xDir, 2, zDir)) {
+
+ replaceDeprecatedCoils(aBaseMetaTileEntity);
+ HeatingCoilLevel heatingCap = getInitialHeatLevel(aBaseMetaTileEntity, xDir, zDir);
+ if (heatingCap == null)
return false;
- }
- if (!addMufflerToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 3, zDir), 11)) {
+
+ if (!checkStructure(heatingCap, xDir, zDir, aBaseMetaTileEntity))
return false;
- }
- replaceDeprecatedCoils(aBaseMetaTileEntity);
- byte tUsedMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + 1, 2, zDir);
- switch (tUsedMeta) {
- case 0:
- this.mHeatingCapacity = 1801;
- break;
- case 1:
- this.mHeatingCapacity = 2701;
- break;
- case 2:
- this.mHeatingCapacity = 3601;
- break;
- case 3:
- this.mHeatingCapacity = 4501;
- break;
- case 4:
- this.mHeatingCapacity = 5401;
- break;
- case 5:
- this.mHeatingCapacity = 7201;
- break;
- case 6:
- this.mHeatingCapacity = 9001;
- break;
- case 7:
- this.mHeatingCapacity = 9901;
- break;
- case 8:
- this.mHeatingCapacity = 10801;
- break;
- default:
- return false;
- }
- for (int i = -1; i < 2; i++) {
- for (int j = -1; j < 2; j++) {
- if ((i != 0) || (j != 0)) {
- if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j) != GregTech_API.sBlockCasings5) {
- return false;
- }
- if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j) != tUsedMeta) {
- return false;
- }
- if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 1, zDir + j) != GregTech_API.sBlockCasings5) {
- return false;
- }
- if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir + j) != tUsedMeta) {
- return false;
- }
- if (!addOutputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 3, zDir + j), 11)) {
- if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 3, zDir + j) != GregTech_API.sBlockCasings1) {
- return false;
- }
- if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 3, zDir + j) != 11) {
- return false;
- }
- }
- }
- }
- }
- for (int i = -1; i < 2; i++) {
- for (int j = -1; j < 2; j++) {
- if ((xDir + i != 0) || (zDir + j != 0)) {
- IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 0, zDir + j);
- if ((!addMaintenanceToMachineList(tTileEntity, 11)) && (!addInputToMachineList(tTileEntity, 11)) && (!addOutputToMachineList(tTileEntity, 11)) && (!addEnergyInputToMachineList(tTileEntity, 11))) {
- if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 0, zDir + j) != GregTech_API.sBlockCasings1) {
- return false;
- }
- if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 0, zDir + j) != 11) {
- return false;
- }
- }
- }
- }
- }
+
+ this.mHeatingCapacity = (int) heatingCap.getHeat();
this.mHeatingCapacity += 100 * (GT_Utility.getTier(getMaxInputVoltage()) - 2);
return true;
}
- public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack){
- boolean result= this.checkMachineFunction(aBaseMetaTileEntity,aStack);
- if (!result) this.mHeatingCapacity=0;
- return result;
- }
+ @Override
+ protected boolean checkTopLayer(int i, int j, int xDir, int zDir, IGregTechTileEntity aBaseMetaTileEntity) {
+ if ((i == 0) && (j == 0)) {
+ return addMufflerToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 3, zDir), CASING_INDEX);
+ }
+ if (addOutputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 3, zDir + j), CASING_INDEX))
+ return true;
- public int getMaxEfficiency(ItemStack aStack) {
- return 10000;
- }
+ if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 3, zDir + j) != GregTech_API.sBlockCasings1)
+ return false;
- public int getPollutionPerTick(ItemStack aStack) {
- return 20;
+ return aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 3, zDir + j) == CASING_INDEX;
}
- public int getDamageToComponent(ItemStack aStack) {
- return 0;
+ @Override
+ protected boolean checkCoils(HeatingCoilLevel heatingCap, int i, int j, int xDir, int zDir, IGregTechTileEntity aBaseMetaTileEntity) {
+ if ((i == 0) && (j == 0)) {
+ if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir))
+ return false;
+
+ return aBaseMetaTileEntity.getAirOffset(xDir, 2, zDir);
+ }
+
+ Block blockLow = aBaseMetaTileEntity.getBlockOffset(xDir + i, 1, zDir + j);
+ if (!(blockLow instanceof IHeatingCoil))
+ return false;
+
+ Block blockHi = aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j);
+ if (!(blockHi instanceof IHeatingCoil))
+ return false;
+
+ byte metaLow = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir + j);
+ HeatingCoilLevel coilHeatLow = ((IHeatingCoil) blockLow).getCoilHeat(metaLow);
+ byte metaHi = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j);
+ HeatingCoilLevel coilHeatHi = ((IHeatingCoil) blockHi).getCoilHeat(metaHi);
+
+ return heatingCap == coilHeatLow && heatingCap == coilHeatHi;
}
- public boolean explodesOnComponentBreak(ItemStack aStack) {
- return false;
+ @Override
+ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
+ return this.checkMachineFunction(aBaseMetaTileEntity, aStack);
}
private void replaceDeprecatedCoils(IGregTechTileEntity aBaseMetaTileEntity) {
int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX;
int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ;
int tX = aBaseMetaTileEntity.getXCoord() + xDir;
- int tY = (int) aBaseMetaTileEntity.getYCoord();
+ int tY = aBaseMetaTileEntity.getYCoord();
int tZ = aBaseMetaTileEntity.getZCoord() + zDir;
int tUsedMeta;
for (int xPos = tX - 1; xPos <= tX + 1; xPos++) {
for (int zPos = tZ - 1; zPos <= tZ + 1; zPos++) {
- if ((xPos == tX) && (zPos == tZ)) {
+ if ((xPos == tX) && (zPos == tZ))
continue;
- }
for (int yPos = tY + 1; yPos <= tY + 2; yPos++) {
tUsedMeta = aBaseMetaTileEntity.getMetaID(xPos, yPos, zPos);
- if (tUsedMeta >= 12 && tUsedMeta <= 14 && aBaseMetaTileEntity.getBlock(xPos, yPos, zPos) == GregTech_API.sBlockCasings1) {
- aBaseMetaTileEntity.getWorld().setBlock(xPos, yPos, zPos, GregTech_API.sBlockCasings5, tUsedMeta - 12, 3);
- }
+ if (tUsedMeta < 12)
+ continue;
+ if (tUsedMeta > 14)
+ continue;
+ if (aBaseMetaTileEntity.getBlock(xPos, yPos, zPos) != GregTech_API.sBlockCasings1)
+ continue;
+
+ aBaseMetaTileEntity.getWorld().setBlock(
+ xPos,
+ yPos,
+ zPos,
+ GregTech_API.sBlockCasings5,
+ tUsedMeta - 12,
+ 3
+ );
}
}
}
}
+
@Override
- public boolean addOutput(FluidStack aLiquid) {
- if (aLiquid == null) return false;
+ public boolean addOutput(FluidStack aLiquid) {
+ if (aLiquid == null)
+ return false;
int targetHeight;
FluidStack tLiquid = aLiquid.copy();
boolean isOutputPollution = false;
for (FluidStack pollutionFluidStack : pollutionFluidStacks) {
- if (tLiquid.isFluidEqual(pollutionFluidStack)) {
- isOutputPollution = true;
- break;
- }
+ if (!tLiquid.isFluidEqual(pollutionFluidStack))
+ continue;
+
+ isOutputPollution = true;
+ break;
}
if (isOutputPollution) {
targetHeight = this.controllerY + 3;
int pollutionReduction = 0;
for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) {
- if (isValidMetaTileEntity(tHatch)) {
- pollutionReduction = 100 - tHatch.calculatePollutionReduction(100);
- break;
- }
+ if (!isValidMetaTileEntity(tHatch))
+ continue;
+ pollutionReduction = 100 - tHatch.calculatePollutionReduction(100);
+ break;
}
tLiquid.amount = tLiquid.amount * (pollutionReduction + 5) / 100;
} else {
targetHeight = this.controllerY;
}
for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) {
- if (isValidMetaTileEntity(tHatch) && GT_ModHandler.isSteam(aLiquid) ? tHatch.outputsSteam() : tHatch.outputsLiquids()) {
- if (tHatch.getBaseMetaTileEntity().getYCoord() == targetHeight) {
- int tAmount = tHatch.fill(tLiquid, false);
- if (tAmount >= tLiquid.amount) {
- return tHatch.fill(tLiquid, true) >= tLiquid.amount;
- } else if (tAmount > 0) {
- tLiquid.amount = tLiquid.amount - tHatch.fill(tLiquid, true);
- }
- }
+ if (isValidMetaTileEntity(tHatch) && GT_ModHandler.isSteam(aLiquid) ? !tHatch.outputsSteam() : !tHatch.outputsLiquids())
+ continue;
+
+ if (tHatch.getBaseMetaTileEntity().getYCoord() != targetHeight)
+ continue;
+
+ int tAmount = tHatch.fill(tLiquid, false);
+ if (tAmount >= tLiquid.amount) {
+ return tHatch.fill(tLiquid, true) >= tLiquid.amount;
+ } else if (tAmount > 0) {
+ tLiquid.amount = tLiquid.amount - tHatch.fill(tLiquid, true);
}
}
return false;
@@ -396,37 +357,37 @@ public class GT_MetaTileEntity_ElectricBlastFurnace
@Override
public String[] getInfoData() {
- int mPollutionReduction=0;
+ int mPollutionReduction = 0;
for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) {
- if (isValidMetaTileEntity(tHatch)) {
- mPollutionReduction=Math.max(tHatch.calculatePollutionReduction(100),mPollutionReduction);
- }
+ if (!isValidMetaTileEntity(tHatch))
+ continue;
+ mPollutionReduction = Math.max(tHatch.calculatePollutionReduction(100), mPollutionReduction);
}
- long storedEnergy=0;
- long maxEnergy=0;
- for(GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) {
- if (isValidMetaTileEntity(tHatch)) {
- storedEnergy+=tHatch.getBaseMetaTileEntity().getStoredEU();
- maxEnergy+=tHatch.getBaseMetaTileEntity().getEUCapacity();
- }
+ long storedEnergy = 0;
+ long maxEnergy = 0;
+ for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) {
+ if (!isValidMetaTileEntity(tHatch))
+ continue;
+ storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU();
+ maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity();
}
return new String[]{
- StatCollector.translateToLocal("GT5U.multiblock.Progress")+": " +EnumChatFormatting.GREEN + Integer.toString(mProgresstime/20) + EnumChatFormatting.RESET +" s / "+
- EnumChatFormatting.YELLOW + Integer.toString(mMaxProgresstime/20) + EnumChatFormatting.RESET +" s",
- StatCollector.translateToLocal("GT5U.multiblock.energy")+": " +EnumChatFormatting.GREEN + Long.toString(storedEnergy) + EnumChatFormatting.RESET +" EU / "+
- EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET +" EU",
- StatCollector.translateToLocal("GT5U.multiblock.usage")+": "+EnumChatFormatting.RED + Integer.toString(-mEUt) + EnumChatFormatting.RESET + " EU/t",
- StatCollector.translateToLocal("GT5U.multiblock.mei")+": "+EnumChatFormatting.YELLOW+Long.toString(getMaxInputVoltage())+EnumChatFormatting.RESET+" EU/t(*2A) "+StatCollector.translateToLocal("GT5U.machines.tier")+": "+
- EnumChatFormatting.YELLOW+VN[GT_Utility.getTier(getMaxInputVoltage())]+ EnumChatFormatting.RESET,
- StatCollector.translateToLocal("GT5U.multiblock.problems")+": "+
- EnumChatFormatting.RED+ (getIdealStatus() - getRepairStatus())+EnumChatFormatting.RESET+
- " "+StatCollector.translateToLocal("GT5U.multiblock.efficiency")+": "+
- EnumChatFormatting.YELLOW+Float.toString(mEfficiency / 100.0F)+EnumChatFormatting.RESET + " %",
- StatCollector.translateToLocal("GT5U.EBF.heat")+": "+
- EnumChatFormatting.GREEN+mHeatingCapacity+EnumChatFormatting.RESET+" K",
- StatCollector.translateToLocal("GT5U.multiblock.pollution")+": "+ EnumChatFormatting.GREEN + mPollutionReduction+ EnumChatFormatting.RESET+" %"
+ StatCollector.translateToLocal("GT5U.multiblock.Progress") + ": " + EnumChatFormatting.GREEN + Integer.toString(mProgresstime / 20) + EnumChatFormatting.RESET + " s / " +
+ EnumChatFormatting.YELLOW + Integer.toString(mMaxProgresstime / 20) + EnumChatFormatting.RESET + " s",
+ StatCollector.translateToLocal("GT5U.multiblock.energy") + ": " + EnumChatFormatting.GREEN + Long.toString(storedEnergy) + EnumChatFormatting.RESET + " EU / " +
+ EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET + " EU",
+ StatCollector.translateToLocal("GT5U.multiblock.usage") + ": " + EnumChatFormatting.RED + Integer.toString(-mEUt) + EnumChatFormatting.RESET + " EU/t",
+ StatCollector.translateToLocal("GT5U.multiblock.mei") + ": " + EnumChatFormatting.YELLOW + Long.toString(getMaxInputVoltage()) + EnumChatFormatting.RESET + " EU/t(*2A) " + StatCollector.translateToLocal("GT5U.machines.tier") + ": " +
+ EnumChatFormatting.YELLOW + VN[GT_Utility.getTier(getMaxInputVoltage())] + EnumChatFormatting.RESET,
+ StatCollector.translateToLocal("GT5U.multiblock.problems") + ": " +
+ EnumChatFormatting.RED + (getIdealStatus() - getRepa