aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
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
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')
-rw-r--r--src/main/java/gregtech/api/enums/GT_Values.java11
-rw-r--r--src/main/java/gregtech/api/enums/HeatingCoilLevel.java69
-rw-r--r--src/main/java/gregtech/api/enums/ItemList.java2
-rw-r--r--src/main/java/gregtech/api/enums/Textures.java2
-rw-r--r--src/main/java/gregtech/api/interfaces/IHeatingCoil.java18
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java67
-rw-r--r--src/main/java/gregtech/common/blocks/GT_Block_Casings5.java73
-rw-r--r--src/main/java/gregtech/common/blocks/GT_Item_Casings5.java39
-rw-r--r--src/main/java/gregtech/common/blocks/GT_Item_Machines.java6
-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
14 files changed, 1086 insertions, 818 deletions
diff --git a/src/main/java/gregtech/api/enums/GT_Values.java b/src/main/java/gregtech/api/enums/GT_Values.java
index 66b2e8a08f..8545f42bea 100644
--- a/src/main/java/gregtech/api/enums/GT_Values.java
+++ b/src/main/java/gregtech/api/enums/GT_Values.java
@@ -4,6 +4,7 @@ import gregtech.api.interfaces.internal.IGT_Mod;
import gregtech.api.interfaces.internal.IGT_RecipeAdder;
import gregtech.api.net.IGT_NetworkHandler;
import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
@@ -126,6 +127,16 @@ public class GT_Values {
"Ultimate High Voltage", "Ultimate Extreme Voltage", "Ultimate Insane Voltage",
"Ultimate Mega Voltage", "Ultimate Extended Mega Voltage", "Overpowered Voltage",
"Maximum Voltage"};
+
+ public static final String[] TIER_COLORS =
+ new String[]{
+ EnumChatFormatting.RED.toString(), EnumChatFormatting.GRAY.toString(), EnumChatFormatting.AQUA.toString(),
+ EnumChatFormatting.GOLD.toString(), EnumChatFormatting.DARK_PURPLE.toString(), EnumChatFormatting.DARK_BLUE.toString(),
+ EnumChatFormatting.LIGHT_PURPLE.toString(), EnumChatFormatting.WHITE.toString(), EnumChatFormatting.DARK_AQUA.toString(),
+ EnumChatFormatting.DARK_RED.toString(), EnumChatFormatting.GREEN.toString(), EnumChatFormatting.DARK_GREEN.toString(),
+ EnumChatFormatting.YELLOW.toString(), EnumChatFormatting.UNDERLINE.toString(), EnumChatFormatting.BOLD.toString(),
+ EnumChatFormatting.OBFUSCATED.toString()};
+
/**
* This way it is possible to have a Call Hierarchy of NullPointers in ItemStack based Functions, and also because most of the time I don't know what kind of Data Type the "null" stands for
*/
diff --git a/src/main/java/gregtech/api/enums/HeatingCoilLevel.java b/src/main/java/gregtech/api/enums/HeatingCoilLevel.java
new file mode 100644
index 0000000000..db94a3fe62
--- /dev/null
+++ b/src/main/java/gregtech/api/enums/HeatingCoilLevel.java
@@ -0,0 +1,69 @@
+package gregtech.api.enums;
+
+import net.minecraft.util.EnumChatFormatting;
+
+public enum HeatingCoilLevel {
+ None, // 0
+ ULV, //Not implemented 901
+ LV, //Cupronickel 1801
+ MV, //KANTHAL 2701
+ HV, //NICHROME 3601
+ EV, //TUNGSTENSTEEL 4501
+ IV, //HSSG 5401
+ LuV, //HSSS 6301
+ ZPM, //NAQUADAH 7201
+ UV, //NAQUADAHALLOY 8101
+ UHV, //TRINIUM 9001
+ UEV, //ELECTRUMFLUX 9901
+ UIV, //AWAKENEDDRACONIUM 10801
+ //Not Implemented yet
+ UMV,
+ UXV,
+ OpV,
+ MAX,
+ ;
+
+ /**
+ * @return the Coils Tier Name
+ */
+ public String getTierName() {
+ if (this.ordinal() < 1 || (this.ordinal()-1) >= GT_Values.VN.length)
+ return "ERROR!";
+ return GT_Values.TIER_COLORS[this.ordinal() - 1] + GT_Values.VOLTAGE_NAMES[this.ordinal() - 1] + EnumChatFormatting.RESET;
+ }
+
+ /**
+ * @return the coil heat, used for recipes in the Electronic Blast Furnace for example
+ */
+ public long getHeat() {
+ return this == None ? 0 : 1L + (900L * this.ordinal());
+ }
+
+ /**
+ * @return the coil tier, used for discount in the Pyrolyse Ofen for example
+ */
+ public byte getTier() {
+ return (byte) (this.ordinal() - 2);
+ }
+
+ /**
+ * @return the coil Level, used for Parallels in the Multi Furnace for example
+ */
+ public byte getLevel() {
+ return (byte) Math.max(16, 2 << (this.ordinal() - 2));
+ }
+
+ /**
+ * @return the coil Discount, used for discount in the Multi Furnace for example
+ */
+ public byte getCostDiscount() {
+ return (byte) Math.min(1, 2 << (this.ordinal() - 1 - 6)); //-1 bcs. of none, -4 = offset
+ }
+
+ public static HeatingCoilLevel getFromTier(byte tier){
+ if (tier < 0 || tier > HeatingCoilLevel.values().length -1)
+ return HeatingCoilLevel.None;
+
+ return HeatingCoilLevel.values()[tier+2];
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/api/enums/ItemList.java b/src/main/java/gregtech/api/enums/ItemList.java
index 2fba2462b5..207ec2eadc 100644
--- a/src/main/java/gregtech/api/enums/ItemList.java
+++ b/src/main/java/gregtech/api/enums/ItemList.java
@@ -1437,7 +1437,9 @@ public enum ItemList implements IItemContainer {
Casing_Coil_Nichrome,
Casing_Coil_TungstenSteel,
Casing_Coil_HSSG,
+ Casing_Coil_HSSS,
Casing_Coil_Naquadah,
+ Casing_Coil_Trinium,
Casing_Coil_NaquadahAlloy,
Casing_Coil_ElectrumFlux,
Casing_Coil_AwakenedDraconium,
diff --git a/src/main/java/gregtech/api/enums/Textures.java b/src/main/java/gregtech/api/enums/Textures.java
index e0d0ce6abe..8f78784caf 100644
--- a/src/main/java/gregtech/api/enums/Textures.java
+++ b/src/main/java/gregtech/api/enums/Textures.java
@@ -283,6 +283,8 @@ public class Textures {
MACHINE_COIL_NAQUADAHALLOY,
MACHINE_COIL_ELECTRUMFLUX,
MACHINE_COIL_AWAKENEDDRACONIUM,
+ MACHINE_COIL_HSSS,
+ MACHINE_COIL_TRINIUM,
BOILER_SOLAR,
BOILER_FRONT,
diff --git a/src/main/java/gregtech/api/interfaces/IHeatingCoil.java b/src/main/java/gregtech/api/interfaces/IHeatingCoil.java
new file mode 100644
index 0000000000..c8ceccf941
--- /dev/null
+++ b/src/main/java/gregtech/api/interfaces/IHeatingCoil.java
@@ -0,0 +1,18 @@
+package gregtech.api.interfaces;
+
+import gregtech.api.enums.HeatingCoilLevel;
+import net.minecraft.item.ItemStack;
+
+import java.util.function.Consumer;
+
+public interface IHeatingCoil {
+
+ HeatingCoilLevel getCoilHeat(int meta);
+ default HeatingCoilLevel getCoilHeat(ItemStack stack) {
+ return getCoilHeat(stack.getItemDamage());
+ }
+
+ void setOnCoilCheck(Consumer<IHeatingCoil> callback);
+ Consumer<IHeatingCoil> getOnCoilCheck();
+}
+
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
index 202e542c88..e15166cf62 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
@@ -34,21 +34,21 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
public static boolean disableMaintenance;
public boolean mMachine = false, mWrench = false, mScrewdriver = false, mSoftHammer = false, mHardHammer = false, mSolderingTool = false, mCrowbar = false, mRunningOnLoad = false;
public int mPollution = 0, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mEfficiencyIncrease = 0, mStartUpCheck = 100, mRuntime = 0, mEfficiency = 0;
- public volatile int mUpdate = 0;
+ public volatile int mUpdate = 0; //TODO: Replace with AtomicInteger
public ItemStack[] mOutputItems = null;
public FluidStack[] mOutputFluids = null;
public String mNEI;
public int damageFactorLow = 5;
public float damageFactorHigh = 0.6f;
- public ArrayList<GT_MetaTileEntity_Hatch_Input> mInputHatches = new ArrayList<GT_MetaTileEntity_Hatch_Input>();
- public ArrayList<GT_MetaTileEntity_Hatch_Output> mOutputHatches = new ArrayList<GT_MetaTileEntity_Hatch_Output>();
- public ArrayList<GT_MetaTileEntity_Hatch_InputBus> mInputBusses = new ArrayList<GT_MetaTileEntity_Hatch_InputBus>();
- public ArrayList<GT_MetaTileEntity_Hatch_OutputBus> mOutputBusses = new ArrayList<GT_MetaTileEntity_Hatch_OutputBus>();
- public ArrayList<GT_MetaTileEntity_Hatch_Dynamo> mDynamoHatches = new ArrayList<GT_MetaTileEntity_Hatch_Dynamo>();
- public ArrayList<GT_MetaTileEntity_Hatch_Muffler> mMufflerHatches = new ArrayList<GT_MetaTileEntity_Hatch_Muffler>();
- public ArrayList<GT_MetaTileEntity_Hatch_Energy> mEnergyHatches = new ArrayList<GT_MetaTileEntity_Hatch_Energy>();
- public ArrayList<GT_MetaTileEntity_Hatch_Maintenance> mMaintenanceHatches = new ArrayList<GT_MetaTileEntity_Hatch_Maintenance>();
+ public ArrayList<GT_MetaTileEntity_Hatch_Input> mInputHatches = new ArrayList<>();
+ public ArrayList<GT_MetaTileEntity_Hatch_Output> mOutputHatches = new ArrayList<>();
+ public ArrayList<GT_MetaTileEntity_Hatch_InputBus> mInputBusses = new ArrayList<>();
+ public ArrayList<GT_MetaTileEntity_Hatch_OutputBus> mOutputBusses = new ArrayList<>();
+ public ArrayList<GT_MetaTileEntity_Hatch_Dynamo> mDynamoHatches = new ArrayList<>();
+ public ArrayList<GT_MetaTileEntity_Hatch_Muffler> mMufflerHatches = new ArrayList<>();
+ public ArrayList<GT_MetaTileEntity_Hatch_Energy> mEnergyHatches = new ArrayList<>();
+ public ArrayList<GT_MetaTileEntity_Hatch_Maintenance> mMaintenanceHatches = new ArrayList<>();
public GT_MetaTileEntity_MultiBlockBase(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional, 2);
@@ -791,7 +791,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
}
public ArrayList<ItemStack> getStoredOutputs() {
- ArrayList<ItemStack> rList = new ArrayList<ItemStack>();
+ ArrayList<ItemStack> rList = new ArrayList<>();
// for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) {
// if (isValidMetaTileEntity(tHatch)) {
// rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(1));
@@ -808,7 +808,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
}
public ArrayList<FluidStack> getStoredFluids() {
- ArrayList<FluidStack> rList = new ArrayList<FluidStack>();
+ ArrayList<FluidStack> rList = new ArrayList<>();
for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) {
tHatch.mRecipeMap = getRecipeMap();
if (isValidMetaTileEntity(tHatch) && tHatch.getFillableStack() != null) {
@@ -819,7 +819,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
}
public ArrayList<ItemStack> getStoredInputs() {
- ArrayList<ItemStack> rList = new ArrayList<ItemStack>();
+ ArrayList<ItemStack> rList = new ArrayList<>();
// for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) {
// tHatch.mRecipeMap = getRecipeMap();
// if (isValidMetaTileEntity(tHatch) && tHatch.getBaseMetaTileEntity().getStackInSlot(0) != null) {
@@ -1003,4 +1003,47 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
return false;
}
+
+ protected ItemStack[] getCompactedInputs(){
+ //TODO: repalce method with a cleaner one
+ 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;
+ }
+ }
+ }
+ return tInputList.toArray(new ItemStack[0]);
+ }
+
+ protected FluidStack[] getCompactedFluids(){
+ //TODO: repalce method with a cleaner one
+ 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;
+ }
+ }
+ }
+ return tFluidList.toArray(new FluidStack[0]);
+ }
}
diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java
index 55492c961c..3e2be76356 100644
--- a/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java
+++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java
@@ -2,16 +2,23 @@ package gregtech.common.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
+import gregtech.api.enums.HeatingCoilLevel;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Textures;
+import gregtech.api.interfaces.IHeatingCoil;
import gregtech.api.objects.GT_CopiedBlockTexture;
import gregtech.api.util.GT_LanguageManager;
-import gregtech.api.util.GT_Utility;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
+import java.util.function.Consumer;
+
+import static gregtech.api.enums.HeatingCoilLevel.*;
+
public class GT_Block_Casings5
- extends GT_Block_Casings_Abstract {
+ extends GT_Block_Casings_Abstract
+ implements IHeatingCoil {
+
public GT_Block_Casings5() {
super(GT_Item_Casings5.class, "gt.blockcasings5", GT_Material_Casings.INSTANCE);
for (byte i = 0; i < 16; i = (byte) (i + 1)) {
@@ -26,6 +33,8 @@ public class GT_Block_Casings5
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Naquadah Alloy Coil Block");
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Electrum Flux Coil Block");
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Awakened Draconium Coil Block");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "HSS-S Coil Block");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Trinium Coil Block");
ItemList.Casing_Coil_Cupronickel.set(new ItemStack(this, 1, 0));
ItemList.Casing_Coil_Kanthal.set(new ItemStack(this, 1, 1));
@@ -36,7 +45,10 @@ public class GT_Block_Casings5
ItemList.Casing_Coil_NaquadahAlloy.set(new ItemStack(this, 1, 6));
ItemList.Casing_Coil_ElectrumFlux.set(new ItemStack(this, 1, 7));
ItemList.Casing_Coil_AwakenedDraconium.set(new ItemStack(this, 1, 8));
+ ItemList.Casing_Coil_HSSS.set(new ItemStack(this, 1, 9));
+ ItemList.Casing_Coil_Trinium.set(new ItemStack(this, 1, 10));
}
+
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int aSide, int aMeta) {
@@ -59,7 +71,62 @@ public class GT_Block_Casings5
return Textures.BlockIcons.MACHINE_COIL_ELECTRUMFLUX.getIcon();
case 8:
return Textures.BlockIcons.MACHINE_COIL_AWAKENEDDRACONIUM.getIcon();
+ case 9:
+ return Textures.BlockIcons.MACHINE_COIL_HSSS.getIcon();
+ case 10:
+ return Textures.BlockIcons.MACHINE_COIL_TRINIUM.getIcon();
}
return Textures.BlockIcons.MACHINE_COIL_CUPRONICKEL.getIcon();
}
-}
+
+ /*--------------- COIL CHECK IMPL. ------------*/
+
+ public static HeatingCoilLevel getCoilHeatFromDamage(int meta) {
+ switch (meta) {
+ case 0:
+ return LV;
+ case 1:
+ return MV;
+ case 2:
+ return HV;
+ case 3:
+ return EV;
+ case 4:
+ return IV;
+ case 5:
+ return ZPM;
+ case 6:
+ return UV;
+ case 7:
+ return UEV;
+ case 8:
+ return UIV;
+ case 9:
+ return LuV;
+ case 10:
+ return UHV;
+ default:
+ return None;
+ }
+ }
+
+ @Override
+ public HeatingCoilLevel getCoilHeat(int meta) {
+ getOnCoilCheck().accept(this);
+ return getCoilHeatFromDamage(meta);
+ }
+
+ /*--------------- CALLBACK ------------*/
+
+ private Consumer<IHeatingCoil> callback = coil -> {};
+
+ @Override
+ public void setOnCoilCheck(Consumer<IHeatingCoil> callback) {
+ this.callback = callback;
+ }
+
+ @Override
+ public Consumer<IHeatingCoil> getOnCoilCheck() {
+ return this.callback;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings5.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings5.java
index 759fcafb5e..a2286d81eb 100644
--- a/src/main/java/gregtech/common/blocks/GT_Item_Casings5.java
+++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings5.java
@@ -2,6 +2,8 @@ package gregtech.common.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
+import gregtech.api.enums.HeatingCoilLevel;
+import gregtech.api.util.GT_LanguageManager;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@@ -13,37 +15,18 @@ public class GT_Item_Casings5
public GT_Item_Casings5(Block par1) {
super(par1);
}
+
+ protected static final String mCoilHeatTooltip = GT_LanguageManager.addStringLocalization("gt.coilheattooltip", "Base Heating Capacity = ");
+ protected static final String mCoilUnitTooltip = GT_LanguageManager.addStringLocalization("gt.coilunittooltip", " Kelvin");
+ protected static final String mCoilTierTooltip = GT_LanguageManager.addStringLocalization("gt.coiltiertooltip", "Coil Tier = ");
+
@Override
@SideOnly(Side.CLIENT)
+ @SuppressWarnings("unchecked")
public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) {
super.addInformation(aStack, aPlayer, aList, aF3_H);
- switch (getDamage(aStack)) {
- case 0:
- aList.add(this.mCoil01Tooltip);
- break;
- case 1:
- aList.add(this.mCoil02Tooltip);
- break;
- case 2:
- aList.add(this.mCoil03Tooltip);
- break;
- case 3:
- aList.add(this.mCoil04Tooltip);
- break;
- case 4:
- aList.add(this.mCoil05Tooltip);
- break;
- case 5:
- aList.add(this.mCoil06Tooltip);
- break;
- case 6:
- aList.add(this.mCoil07Tooltip);
- break;
- case 7:
- aList.add(this.mCoil08Tooltip);
- break;
- case 8:
- aList.add(this.mCoil09Tooltip);
- }
+ HeatingCoilLevel coilLevel = GT_Block_Casings5.getCoilHeatFromDamage(aStack.getItemDamage());
+ aList.add(mCoilHeatTooltip + coilLevel.getHeat() + mCoilUnitTooltip);
+ aList.add(mCoilTierTooltip + coilLevel.getTierName());
}
}
diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java
index bf6b12b5cd..57cfe9266c 100644
--- a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java
+++ b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java
@@ -65,10 +65,12 @@ public class GT_Item_Machines
}
if (tTileEntity.getEUCapacity() > 0L) {
if (tTileEntity.getInputVoltage() > 0L) {
- aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_IN", "Voltage IN: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + tTileEntity.getInputVoltage() + " (" + GT_Values.VN[GT_Utility.getTier(tTileEntity.getInputVoltage())] + ")" + EnumChatFormatting.GRAY);
+ int inputTier = GT_Utility.getTier(tTileEntity.getInputVoltage());
+ aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_IN", "Voltage IN: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + tTileEntity.getInputVoltage() + " (" + GT_Values.TIER_COLORS[inputTier] + GT_Values.VN[inputTier] + EnumChatFormatting.GREEN +")" + EnumChatFormatting.GRAY);
}
if (tTileEntity.getOutputVoltage() > 0L) {
- aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_OUT", "Voltage OUT: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + tTileEntity.getOutputVoltage() + " (" + GT_Values.VN[GT_Utility.getTier(tTileEntity.getOutputVoltage())] + ")" + EnumChatFormatting.GRAY);
+ int outputTier = GT_Utility.getTier(tTileEntity.getOutputVoltage());
+ aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_OUT", "Voltage OUT: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + tTileEntity.getOutputVoltage() + " (" + GT_Values.TIER_COLORS[outputTier] + GT_Values.VN[outputTier] + EnumChatFormatting.GREEN + ")" + EnumChatFormatting.GRAY);
}
if (tTileEntity.getOutputAmperage() > 1L) {
aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_AMOUNT", "Amperage: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.YELLOW + tTileEntity.getOutputAmperage() + EnumChatFormatting.GRAY);
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() - 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 + " %"
};
}
-}
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java
index 5eca30def1..8b27932511 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java
@@ -1,36 +1,39 @@
package gregtech.common.tileentities.machines.multi;
-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.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_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 org.lwjgl.input.Keyboard;
+
+import java.util.ArrayList;
+
+import static gregtech.api.enums.GT_Values.VN;
public class GT_MetaTileEntity_MultiFurnace
- extends GT_MetaTileEntity_MultiBlockBase {
+ extends GT_MetaTileEntity_AbstractMultiFurnace {
private int mLevel = 0;
private int mCostDiscount = 1;
+ private static final int CASING_INDEX = 11;
+
public GT_MetaTileEntity_MultiFurnace(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
}
@@ -39,10 +42,12 @@ public class GT_MetaTileEntity_MultiFurnace
super(aName);
}
+ @Override
public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new GT_MetaTileEntity_MultiFurnace(this.mName);
}
+ @Override
public String[] getDescription() {
final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
tt.addMachineType("Furnace")
@@ -54,70 +59,56 @@ public class GT_MetaTileEntity_MultiFurnace
.beginStructureBlock(3, 3, 3, true)
.addController("Front bottom")
.addCasingInfo("Heat Proof Machine Casing", 8)
- .addOtherStructurePart("Heating Coils (any tier)", "Middle layer")
+ .addOtherStructurePart("Heating Coils", "Middle layer")
.addEnergyHatch("Any bottom casing")
.addMaintenanceHatch("Any bottom casing")
.addMufflerHatch("Top Middle")
.addInputBus("Any bottom casing")
.addOutputBus("Any bottom casing")
.toolTipFinisher("Gregtech");
- if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
- return tt.getInformation();
- } else {
- return tt.getStructureInformation();
- }
+ if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
+ return tt.getInformation();
+ 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_MULTI_SMELTER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER)};
- }
- return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][11]};
+ if (aSide == aFacing)
+ return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][CASING_INDEX], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER)};
+ 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(), "MultiFurnace.png");
}
+ @Override
public GT_Recipe.GT_Recipe_Map getRecipeMap() {
return GT_Recipe.GT_Recipe_Map.sFurnaceRecipes;
}
- public boolean isCorrectMachinePart(ItemStack aStack) {
- return true;
- }
-
- public boolean isFacingValid(byte aFacing) {
- return aFacing > 1;
- }
-
+ @Override
public boolean checkRecipe(ItemStack aStack) {
ArrayList<ItemStack> tInputList = getStoredInputs();
- if (!tInputList.isEmpty()) {
- int mVolatage=GT_Utility.safeInt(getMaxInputVoltage());
- int tMaxParrallel = 8 * this.mLevel;
- int tCurrenParrallel = 0;
- ItemStack tSmeltStack = tInputList.get(0);
- ItemStack tOutputStack = GT_ModHandler.getSmeltingOutput(tSmeltStack,false,null);
- if (tOutputStack == null)
- return false;
- for (int i = 0;i<tInputList.size();i++)
- {
- ItemStack item = tInputList.get(i);
- if (tSmeltStack.isItemEqual(item))
- {
- if (item.stackSize<(tMaxParrallel-tCurrenParrallel))
- {
- tCurrenParrallel += item.stackSize;
- item.stackSize = 0;
- }
- else
- {
- item.stackSize = (tCurrenParrallel + item.stackSize) - tMaxParrallel;
- tCurrenParrallel = tMaxParrallel;
- break;
- }
- }
+ if (tInputList.isEmpty())
+ return false;
+
+ int mVolatage = GT_Utility.safeInt(getMaxInputVoltage());
+ int tMaxParrallel = 8 * this.mLevel;
+ int tCurrenParrallel = 0;
+ ItemStack tSmeltStack = tInputList.get(0);
+ ItemStack tOutputStack = GT_ModHandler.getSmeltingOutput(tSmeltStack,false,null);
+ if (tOutputStack == null)
+ return false;
+ for (ItemStack item : tInputList)
+ if (tSmeltStack.isItemEqual(item)) if (item.stackSize < (tMaxParrallel - tCurrenParrallel)) {
+ tCurrenParrallel += item.stackSize;
+ item.stackSize = 0;
+ } else {
+ item.stackSize = (tCurrenParrallel + item.stackSize) - tMaxParrallel;
+ tCurrenParrallel = tMaxParrallel;
+ break;
}
// this.mOutputItems = new ItemStack[8 * this.mLevel];
// for (int i = 0; (i < 256) && (j < this.mOutputItems.length); i++) {
@@ -125,37 +116,33 @@ public class GT_MetaTileEntity_MultiFurnace
// j++;
// }
// }
- tCurrenParrallel *= tOutputStack.stackSize;
- this.mOutputItems = new ItemStack[(tCurrenParrallel/64)+1];
- for (int i = 0; i<this.mOutputItems.length;i++)
- {
- ItemStack tNewStack = tOutputStack.copy();
- int size = tCurrenParrallel>64 ? 64 : tCurrenParrallel;
- tNewStack.stackSize = size;
- tCurrenParrallel -= size;
- this.mOutputItems[i] = tNewStack;
- }
+ tCurrenParrallel *= tOutputStack.stackSize;
+ this.mOutputItems = new ItemStack[(tCurrenParrallel/64)+1];
+ for (int i = 0; i < this.mOutputItems.length; i++) {
+ ItemStack tNewStack = tOutputStack.copy();
+ int size = Math.min(tCurrenParrallel, 64);
+ tNewStack.stackSize = size;
+ tCurrenParrallel -= size;
+ this.mOutputItems[i] = tNewStack;
+ }
+ if (this.mOutputItems.length > 0) {
+ this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
+ this.mEfficiencyIncrease = 10000;
+ calculateOverclockedNessMulti(4, 512, 1, mVolatage);
+ //In case recipe is too OP for that machine
+ if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1)
+ return false;
- if (this.mOutputItems != null && this.mOutputItems.length > 0) {
- this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
- this.mEfficiencyIncrease = 10000;
- calculateOverclockedNessMulti(4, 512, 1, mVolatage);
- //In case recipe is too OP for that machine
- if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1)
- return false;
-
- this.mEUt = GT_Utility.safeInt(((long)mEUt) * this.mLevel / (long)this.mCostDiscount,1);
- if (mEUt == Integer.MAX_VALUE - 1)
- return false;
- if (this.mEUt > 0) {
- this.mEUt = (-this.mEUt);
- }
- }
- updateSlots();
- return true;
+ this.mEUt = GT_Utility.safeInt(((long)mEUt) * this.mLevel / (long)this.mCostDiscount,1);
+ if (mEUt == Integer.MAX_VALUE - 1)
+ return false;
+
+ if (this.mEUt > 0)
+ this.mEUt = (-this.mEUt);
}
- return false;
+ updateSlots();
+ return true;
}
private boolean checkMachineFunction(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
@@ -164,147 +151,82 @@ public class GT_MetaTileEntity_MultiFurnace
this.mLevel = 0;
this.mCostDiscount = 1;
- if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) {
- return false;
- }
- addMufflerToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 2, zDir), 11);
+
replaceDeprecatedCoils(aBaseMetaTileEntity);
- byte tUsedMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + 1, 1, zDir);
- switch (tUsedMeta) {
- case 0:
- this.mLevel = 1;
- this.mCostDiscount = 1;
- break;
- case 1:
- this.mLevel = 2;
- this.mCostDiscount = 1;
- break;
- case 2:
- this.mLevel = 4;
- this.mCostDiscount = 1;
- break;
- case 3:
- this.mLevel = 8;
- this.mCostDiscount = 1;
- break;
- case 4:
- this.mLevel = 16;
- this.mCostDiscount = 2;
- break;
- case 5:
- this.mLevel = 16;
- this.mCostDiscount = 4;
- break;
- case 6:
- this.mLevel = 16;
- this.mCostDiscount = 8;
- break;
- case 7:
- this.mLevel = 16;
- this.mCostDiscount = 16;
- break;
- case 8:
- this.mLevel = 16;
- this.mCostDiscount = 24;
- 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, 1, zDir + j) != GregTech_API.sBlockCasings5) {
- return false;
- }
- if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir + j) != tUsedMeta) {
- return false;
- }
- if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j) != GregTech_API.sBlockCasings1) {
- return false;
- }
- if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, 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;
- }
- }
- }
- }
- }
+ HeatingCoilLevel heatingCap = getInitialHeatLevel(aBaseMetaTileEntity, xDir, zDir);
+ if (heatingCap == null)
+ return false;
+
+ if (!checkStructure(heatingCap, xDir, zDir, aBaseMetaTileEntity))
+ return false;
+
+ this.mLevel = heatingCap.getLevel();
+ this.mCostDiscount = heatingCap.getCostDiscount();
return true;
}
- public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack){
- boolean result= this.checkMachineFunction(aBaseMetaTileEntity,aStack);
- if (!result) this.mLevel=0;
- return result;
- }
- public int getMaxEfficiency(ItemStack aStack) {
- return 10000;
- }
+ @Override
+ protected boolean checkCoils(HeatingCoilLevel heatingCap, int i, int j, int xDir, int zDir, IGregTechTileEntity aBaseMetaTileEntity) {
+ if ((i == 0) && (j == 0))
+ return aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir);
+
+ Block coilM = aBaseMetaTileEntity.getBlockOffset(xDir + i, 1, zDir + j);
+ if (!(coilM instanceof IHeatingCoil))
+ return false;
+ byte usedMetaM = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir + j);
+
+ IHeatingCoil heatingCoilM = (IHeatingCoil) coilM;
+ HeatingCoilLevel heatingLevelM = heatingCoilM.getCoilHeat(usedMetaM);
- public int getPollutionPerTick(ItemStack aStack) {
- return 20;
+ return heatingLevelM == heatingCap;
}
- public int getDamageToComponent(ItemStack aStack) {
- return 0;
+ @Override
+ protected boolean checkTopLayer(int i, int j, int xDir, int zDir, IGregTechTileEntity aBaseMetaTileEntity) {
+ if ((i == 0) && (j == 0)) {
+ return addMufflerToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 2, zDir), CASING_INDEX);
+ }
+ if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j) != GregTech_API.sBlockCasings1)
+ return false;
+ return aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j) == CASING_INDEX;
}
- 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 xPos = tX - 1; xPos <= tX + 1; xPos++)
for (int zPos = tZ - 1; zPos <= tZ + 1; zPos++) {
- if ((xPos == tX) && (zPos == tZ)) {
- continue;
- }
+ if ((xPos == tX) && (zPos == tZ)) continue;
tUsedMeta = aBaseMetaTileEntity.getMetaID(xPos, tY + 1, zPos);
- if (tUsedMeta >= 12 && tUsedMeta <= 14 && aBaseMetaTileEntity.getBlock(xPos, tY + 1, zPos) == GregTech_API.sBlockCasings1) {
+ if (tUsedMeta >= 12 && tUsedMeta <= 14 && aBaseMetaTileEntity.getBlock(xPos, tY + 1, zPos) == GregTech_API.sBlockCasings1)
aBaseMetaTileEntity.getWorld().setBlock(xPos, tY + 1, zPos, GregTech_API.sBlockCasings5, tUsedMeta - 12, 3);
- }
}
- }
}
@Override
public String[] getInfoData() {
int mPollutionReduction=0;
- for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) {
- if (isValidMetaTileEntity(tHatch)) {
- mPollutionReduction=Math.max(tHatch.calculatePollutionReduction(100),mPollutionReduction);
- }
- }
+ for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches)
+ if (isValidMetaTileEntity(tHatch))
+ mPollutionReduction = Math.max(tHatch.calculatePollutionReduction(100), mPollutionReduction);
long storedEnergy=0;
long maxEnergy=0;
- for(GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) {
+ for(GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches)
if (isValidMetaTileEntity(tHatch)) {
- storedEnergy+=tHatch.getBaseMetaTileEntity().getStoredEU();
- maxEnergy+=tHatch.getBaseMetaTileEntity().getEUCapacity();
+ storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU();
+ maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity();
}
- }
return new String[]{
StatCollector.translateToLocal("GT5U.multiblock.Progress")+": "+
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 e4ad65e4a4..302a76b7b7 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
@@ -1,9 +1,11 @@
package gregtech.common.tileentities.machines.multi;
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;
@@ -14,19 +16,24 @@ 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.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;
private int controllerX, controllerZ;
+ private static final byte CASING_INDEX = 49;
+ private HeatingCoilLevel heatLevel;
+
public GT_MetaTileEntity_OilCracker(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
}
@@ -35,6 +42,7 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa
super(aName);
}
+ @Override
public String[] getDescription() {
final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
tt.addMachineType("Cracker")
@@ -46,7 +54,9 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa
.beginStructureBlock(5, 3, 3, true)
.addController("Front center")
.addCasingInfo("Clean Stainless Steel Machine Casing", 18)
- .addOtherStructurePart("2 Rings of 8 Cupronickel Coils", "Each side of the controller")
+ .addOtherStructurePart("2 Rings of 8 Coils", "Each side of the controller")
+ .addInfo("Processing speed scales linearly with Coil tier:")
+ .addInfo("CuNi: 100%, FeAlCr: 150%, Ni4Cr: 200%, Fe50CW: 250%, etc.")
.addEnergyHatch("Any casing")
.addMaintenanceHatch("Any casing")
.addInputHatch("Steam/Hydrogen, Any middle ring casing")
@@ -54,21 +64,18 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa
.addOutputHatch("Any left/right side casing")
.addStructureInfo("Input/Output Hatches must be on opposite sides!")
.toolTipFinisher("Gregtech");
- if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
- return tt.getInformation();
- } else {
- return tt.getStructureInformation();
- }
+ if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) return tt.getInformation();
+ 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][49],
- new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER)};
- }
- return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][49]};
+ if (aSide == aFacing) return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][CASING_INDEX],
+ new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER)};
+ 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(), "OilCrackingUnit.png");
}
@@ -76,13 +83,22 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa
@Override
public boolean checkRecipe(ItemStack aStack) {
ArrayList<FluidStack> tInputList = getStoredFluids();
- FluidStack[] tFluidInputs = tInputList.toArray(new FluidStack[tInputList.size()]);
+ FluidStack[] tFluidInputs = tInputList.toArray(new FluidStack[0]);
long tVoltage = getMaxInputVoltage();
byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage));
GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sCrakingRecipes.findRecipe(
- getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluidInputs ,new ItemStack[]{mInventory[1]});
- if (tRecipe != null && tRecipe.isRecipeInputEqual(true, tFluidInputs, new ItemStack[]{mInventory[1]})) {
+ getBaseMetaTileEntity(),
+ false,
+ gregtech.api.enums.GT_Values.V[tTier],
+ tFluidInputs ,
+ mInventory[1]
+ );
+
+ if (tRecipe == null)
+ return false;
+
+ if (tRecipe.isRecipeInputEqual(true, tFluidInputs, mInventory[1])) {
this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
this.mEfficiencyIncrease = 10000;
this.mEUt = tRecipe.mEUt;
@@ -91,147 +107,153 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa
this.mEUt *= 4;
this.mMaxProgresstime /= 2;
}
- if (this.mEUt > 0) {
+
+ if (this.mEUt > 0)
this.mEUt = (-this.mEUt);
- }
- this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
+
+ this.mMaxProgresstime = Math.max(mMaxProgresstime / heatLevel.getTier(), 1);
+
this.mOutputFluids = new FluidStack[]{tRecipe.getFluidOutput(0)};
return true;
}
return false;
}
+ private boolean coilsNotPresent(IGregTechTileEntity aBaseMetaTileEntity, int x , int y, int z) {
+
+ Block coil = aBaseMetaTileEntity.getBlockOffset(x, y, z);
+
+ if (!(coil instanceof IHeatingCoil))
+ return true;
+
+ IHeatingCoil heatingCoil = (IHeatingCoil) coil;
+ byte meta = aBaseMetaTileEntity.getMetaIDOffset(x, y, z);
+ HeatingCoilLevel heatLevel = heatingCoil.getCoilHeat(meta);
+ if (heatLevel == HeatingCoilLevel.None)
+ return true;
+
+ if (this.heatLevel == HeatingCoilLevel.None)
+ this.heatLevel = heatLevel;
+
+ return this.heatLevel != heatLevel;
+ }
+
@Override
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
+ 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;
- if (xDir != 0) {
- for (int i = -1; i < 2; i++) {// xDirection
- for (int j = -1; j < 2; j++) {// height
- for (int h = -2; h < 3; h++) {
- if (!(j == 0 && i == 0 && (h == -1 || h == 0 || h == 1))) {
- if (h == 1 || h == -1) {
- if (aBaseMetaTileEntity.getBlockOffset(xDir + i, j, h + zDir) != GregTech_API.sBlockCasings5) {
- return false;
- }
- if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, j, h + zDir) != 0) {
- return false;
- }
- }
- if (h == 2 || h == -2) {
- IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, j, h + zDir);
- if (addInputToMachineList(tTileEntity, 49)) {
- if (h == -2) {
- negSideInput = true;
- } else {
- posSideInput = true;
- }
- } else if (addOutputToMachineList(tTileEntity, 49)) {
- if (h == -2) {
- negSideOutput = true;
- } else {
- posSideOutput = true;
- }
- } else if (!addEnergyInputToMachineList(tTileEntity, 49) && !addMaintenanceToMachineList(tTileEntity, 49)){
- 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, 49)) && (!addInputToMachineList(tTileEntity, 49))
- && (!addEnergyInputToMachineList(tTileEntity, 49))) {
- if (!((xDir + i) == 0 && j == 0 && (h + zDir) == 0)) {
- 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++) {// zDirection
- for (int j = -1; j < 2; j++) {// height
- for (int h = -2; h < 3; h++) {
- if (!(j == 0 && i == 0 && (h == -1 || h == 0 || h == 1))) {
- if (h == 1 || h == -1) {
- if (aBaseMetaTileEntity.getBlockOffset(xDir + h, j, i + zDir) != GregTech_API.sBlockCasings5) {
- return false;
- }
- if (aBaseMetaTileEntity.getMetaIDOffset(xDir + h, j, i + zDir) != 0) {
- return false;
- }
- }
- if (h == 2 || h == -2) {
- IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + h, j, i + zDir);
- if (addInputToMachineList(tTileEntity, 49)) {
- if (h == -2) {
- negSideInput = true;
- } else {
- posSideInput = true;
- }
- } else if (addOutputToMachineList(tTileEntity, 49)) {
- if (h == -2) {
- negSideOutput = true;
- } else {
- posSideOutput = true;
- }
- } else if (!addEnergyInputToMachineList(tTileEntity, 49) && !addMaintenanceToMachineList(tTileEntity, 49)){
- 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++;
- }
- }
- if (h == 0) {
- IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + h, j, i + zDir);
- if ((!addMaintenanceToMachineList(tTileEntity, 49)) && (!addInputToMachineList(tTileEntity, 49))
- && (!addEnergyInputToMachineList(tTileEntity, 49))) {
- if (!((xDir + h) == 0 && j == 0 && (i + zDir) == 0)) {
- 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++;
- }
- }
- }
-
- }
+ 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(checkInputOutputBroken(flags))
+ return false;
+
+ 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 (a == 1 || a == -1) {
+ return coilsNotPresent(aBaseMetaTileEntity, xDir + a, b, c + zDir);
}
- if ((negSideInput && negSideOutput) || (posSideInput && posSideOutput)
- || (negSideInput && posSideInput) || (negSideOutput && posSideOutput)) {
- return false;
+ else if (a == 2 || a == -2) {
+ return checkEndsBroken(xDir, zDir, a, b, c, aBaseMetaTileEntity, amount, flags);
}
- if (amount < 18) return false;
- return true;
+ 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 (addInputToMachineList(tTileEntity, CASING_INDEX))
+ return false;
+ 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
@@ -259,6 +281,7 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa
return false;
}
+ @Override
public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new GT_MetaTileEntity_OilCracker(this.mName);
}
@@ -267,50 +290,52 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa
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;
- for (int xPos = tX - 1; xPos <= tX + 1; xPos += (xDir != 0 ? 1 : 2)) {
- for (int yPos = tY - 1; yPos <= tY + 1; yPos++) {
+ for (int xPos = tX - 1; xPos <= tX + 1; xPos += (xDir != 0 ? 1 : 2))
+ for (int yPos = tY - 1; yPos <= tY + 1; yPos++)
for (int zPos = tZ - 1; zPos <= tZ + 1; zPos += (xDir != 0 ? 2 : 1)) {
- if ((yPos == tY) && (xPos == tX || zPos == tZ)) {
+ if ((yPos == tY) && (xPos == tX || zPos == tZ))
continue;
- }
- if (aBaseMetaTileEntity.getBlock(xPos, yPos, zPos) == GregTech_API.sBlockCasings1 &&
- aBaseMetaTileEntity.getMetaID(xPos, yPos, zPos) == 12)
- {
- aBaseMetaTileEntity.getWorld().setBlock(xPos, yPos, zPos, GregTech_API.sBlockCasings5, 0, 3);
- }
+ byte tUsedMeta = aBaseMetaTileEntity.getMetaID(xPos, yPos, zPos);
+ 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 ArrayList<FluidStack> getStoredFluids() {
- ArrayList<FluidStack> rList = new ArrayList<FluidStack>();
+ ArrayList<FluidStack> rList = new ArrayList<>();
for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) {
tHatch.mRecipeMap = getRecipeMap();
if (isValidMetaTileEntity(tHatch) && tHatch.getFillableStack() != null) {
FluidStack tStack = tHatch.getFillableStack();
if (tStack.isFluidEqual(GT_ModHandler.getSteam(1000)) || tStack.isFluidEqual(Materials.Hydrogen.getGas(1000))) {
- if (isHatchInMiddleRing(tHatch)) {
- rList.add(tStack);
- }
- } else {
- if (!isHatchInMiddleRing(tHatch)) {
+ if (isHatchInMiddleRing(tHatch))
rList.add(tStack);
- }
- }
+ } else if (!isHatchInMiddleRing(tHatch))
+ rList.add(tStack);
}
}
return rList;
}
private boolean isHatchInMiddleRing(GT_MetaTileEntity_Hatch_Input inputHatch){
- if (orientation == ForgeDirection.NORTH || orientation == ForgeDirection.SOUTH) {
+ if (orientation == ForgeDirection.NORTH || orientation == ForgeDirection.SOUTH)
return inputHatch.getBaseMetaTileEntity().getXCoord() == this.controllerX;
- } else {
- return inputHatch.getBaseMetaTileEntity().getZCoord() == this.controllerZ;
- }
+ return inputHatch.getBaseMetaTileEntity().getZCoord() == this.controllerZ;
}
} \ No newline at end of file
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 c2e13a815f..edf652923b 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
@@ -3,8 +3,10 @@ package gregtech.common.tileentities.machines.multi;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.GameRegistry;
import gregtech.api.GregTech_API;
+import gregtech.api.enums.HeatingCoilLevel;
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;
@@ -20,17 +22,14 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-
+import org.apache.commons.lang3.mutable.MutableBoolean;
import org.lwjgl.input.Keyboard;
public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlockBase {
-
- private int coilMetaID;
- //public static GT_CopiedBlockTexture mTextureULV = new GT_CopiedBlockTexture(Block.getBlockFromItem(ItemList.Casing_ULV.get(1).getItem()), 6, 0, Dyes.MACHINE_METAL.mRGBa);
- private 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);
@@ -40,35 +39,37 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock
super(aName);
}
+ @Override
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 (any tier)", "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();
+ }
}
+ @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[8][66], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN)};
@@ -76,145 +77,103 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock
return new ITexture[]{Textures.BlockIcons.casingTexturePages[8][66]};
}
+ @Override
public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "PyrolyseOven.png");
}
@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((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) {
- if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) {
- tInputList.remove(j--); tInputList_sS=tInputList.size();
- } else {
- tInputList.remove(i--); tInputList_sS=tInputList.size();
- break;
- }
- }
- }
- }
- ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 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((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) {
- if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) {
- tFluidList.remove(j--); tFluidList_sS=tFluidList.size();
- } else {
- tFluidList.remove(i--); tFluidList_sS=tFluidList.size();
- break;
- }
- }
- }
- }
- FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1);
- 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.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){
- for(ItemStack is:tInputs) {
- for (int id : OreDictionary.getOreIDs(is)) {
- if (OreDictionary.getOreName(id).equals("logWood"))
- ProcessingLog.addPyrolyeOvenRecipes(is);
- }
- }
- tRecipe = GT_Recipe.GT_Recipe_Map.sPyrolyseRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs);
- }
+ 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.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)
+ tRecipe = addRecipesDynamically(tInputs, tFluids, tTier);
- if (tRecipe != null && tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) {
- this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
- this.mEfficiencyIncrease = 10000;
+ if (tRecipe == null || !tRecipe.isRecipeInputEqual(true, tFluids, tInputs))
+ return false;
- calculateOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, 1, 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);
+ this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
+ this.mEfficiencyIncrease = 10000;
+
+ calculateOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, 1, 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);
+ this.mMaxProgresstime = Math.max(mMaxProgresstime * 2 / (1 + coilHeat.getTier()), 1);
+ 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);
+ }
}
- this.mMaxProgresstime = Math.max(mMaxProgresstime * 2 / (1 + coilMetaID), 1);
- 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;
}
}
- return false;
+ 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= Loader.isModLoaded("dreamcraft")? GameRegistry.findBlock("dreamcraft","gt.blockcasingsNH"): GregTech_API.sBlockCasings1;
- int CasingMeta= Loader.isModLoaded("dreamcraft")?2:0;
+ if (Loader.isModLoaded("dreamcraft")) {
+ casingBlock = GameRegistry.findBlock("dreamcraft", "gt.blockcasingsNH");
+ casingMeta = 2;
+ } else {
+ 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 (Cupronickel or Kanthal coils)
- if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != GregTech_API.sBlockCasings5) {
- return false;
- }
- int metaID = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j);
- if (metaID > 8) {
- return false;
- } else {
- if (firstCoil) {
- this.coilMetaID = metaID;
- firstCoil = false;
- } else if (metaID != this.coilMetaID) {
- return false;
- }
- }
- } else if (h == 3) {// inner ceiling (ulv casings + input + muffler)
- if ((!addInputToMachineList(tTileEntity, CASING_INDEX)) && (!addMufflerToMachineList(tTileEntity, CASING_INDEX))) {
- 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;
- }
- }
+ if (checkInnerBroken(
+ xDir, zDir,
+ i, h, j,
+ aBaseMetaTileEntity, tTileEntity,
+ casingBlock, casingMeta,
+ firstCoil
+ )
+ )
+ return false;
} else {// outer 5x5 without height
- if (h == 0) {// outer floor (controller, output, energy, maintainance, rest ulv casings)
- if ((!addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) && (!addOutputToMachineList(tTileEntity, CASING_INDEX)) && (!addEnergyInputToMachineList(tTileEntity, CASING_INDEX))) {
- if ((xDir + i != 0) || (zDir + j != 0)) {//no controller
- if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != CasingBlock) {
- return false;
- }
- if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != CasingMeta) {
- return false;
- }
- }
- }
- } else {// outer above floor (ulv casings)
- if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != CasingBlock) {
- return false;
- }
- if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != CasingMeta) {
- return false;
- }
- }
+ if (checkOuterBroken(
+ xDir, zDir,
+ i, h, j,
+ aBaseMetaTileEntity, tTileEntity,
+ casingBlock, casingMeta
+ )
+ )
+ return false;
}
}
}
@@ -222,6 +181,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;
@@ -247,6 +312,7 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock
return false;
}
+ @Override
public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new GT_MetaTileEntity_PyrolyseOven(this.mName);
}
@@ -255,13 +321,12 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock
int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX;
int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ;
int tX = aBaseMetaTileEntity.getXCoord() + xDir * 2;
- int tY = (int) aBaseMetaTileEntity.getYCoord();
+ int tY = aBaseMetaTileEntity.getYCoord();
int tZ = aBaseMetaTileEntity.getZCoord() + zDir * 2;
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);
}
}