From eacdf1e10f02be6f42957bbb065fec0345e3b64a Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Thu, 24 Dec 2020 18:46:40 +0100 Subject: Heating Coil Logic Overhaul --- .../GT_MetaTileEntity_ElectricBlastFurnace.java | 337 +++++++++++---------- .../multi/GT_MetaTileEntity_MultiFurnace.java | 287 ++++++++---------- .../multi/GT_MetaTileEntity_OilCracker.java | 320 ++++++++++--------- .../multi/GT_MetaTileEntity_PyrolyseOven.java | 150 ++++----- 4 files changed, 559 insertions(+), 535 deletions(-) (limited to 'src/main/java/gregtech/common/tileentities') 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..c3b960476d 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 @@ -5,6 +5,9 @@ import static gregtech.api.enums.GT_Values.VN; import java.util.ArrayList; +import gregtech.api.enums.HeatingCoilLevel; +import gregtech.api.interfaces.IHeatingCoil; +import net.minecraft.block.Block; import org.lwjgl.input.Keyboard; import gregtech.api.GregTech_API; @@ -37,6 +40,8 @@ public class GT_MetaTileEntity_ElectricBlastFurnace 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); } @@ -63,7 +68,7 @@ public class GT_MetaTileEntity_ElectricBlastFurnace .beginStructureBlock(3, 4, 3, true) .addController("Front bottom") .addCasingInfo("Heat Proof Machine Casing", 0) - .addOtherStructurePart("Heating Coils (any tier)", "Two middle Layers") + .addOtherStructurePart("Heating Coils", "Two middle Layers") .addEnergyHatch("Any bottom layer casing") .addMaintenanceHatch("Any bottom layer casing") .addMufflerHatch("Top middle") @@ -83,9 +88,9 @@ public class GT_MetaTileEntity_ElectricBlastFurnace 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]}; } public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { @@ -109,65 +114,85 @@ public class GT_MetaTileEntity_ElectricBlastFurnace 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; - } + if (!GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) + continue; + + if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { + tInputList.remove(j--); + tInputList_sS = tInputList.size(); + } else { + tInputList.remove(i--); + tInputList_sS = tInputList.size(); + break; } } } - ItemStack[] tInputs = tInputList.toArray(new ItemStack[tInputList.size()]); + ItemStack[] tInputs = tInputList.toArray(new ItemStack[0]); ArrayList 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; - } + if (!GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) + continue; + + if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { + tFluidList.remove(j--); + tFluidList_sS = tFluidList.size(); + } else { + tFluidList.remove(i--); + tFluidList_sS = tFluidList.size(); + break; } } } - FluidStack[] tFluids = tFluidList.toArray(new FluidStack[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; - } + FluidStack[] tFluids = tFluidList.toArray(new FluidStack[0]); + if (tInputList.size() <= 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); } - return false; + 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; } /** @@ -193,7 +218,7 @@ public class GT_MetaTileEntity_ElectricBlastFurnace //Long EUt calculation long xEUt=aEUt; //Isnt too low EUt check? - long tempEUt = xEUt= 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 + ); } } } @@ -361,34 +379,37 @@ public class GT_MetaTileEntity_ElectricBlastFurnace 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; @@ -398,18 +419,18 @@ public class GT_MetaTileEntity_ElectricBlastFurnace public String[] getInfoData() { 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(); - } + if (!isValidMetaTileEntity(tHatch)) + continue; + storedEnergy+=tHatch.getBaseMetaTileEntity().getStoredEU(); + maxEnergy+=tHatch.getBaseMetaTileEntity().getEUCapacity(); } return new String[]{ 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..580bbea08d 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,14 +1,10 @@ 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; @@ -20,17 +16,25 @@ 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 { 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); } @@ -54,25 +58,22 @@ 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(); } 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]}; } public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { @@ -93,31 +94,24 @@ public class GT_MetaTileEntity_MultiFurnace public boolean checkRecipe(ItemStack aStack) { ArrayList 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;i64 ? 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; - 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; + if (this.mEUt > 0) + this.mEUt = (-this.mEUt); } - return false; + updateSlots(); + return true; } private boolean checkMachineFunction(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { @@ -164,92 +154,68 @@ public class GT_MetaTileEntity_MultiFurnace this.mLevel = 0; this.mCostDiscount = 1; - if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { + + if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) return false; - } - addMufflerToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 2, zDir), 11); + + addMufflerToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 2, zDir), CASING_INDEX); replaceDeprecatedCoils(aBaseMetaTileEntity); + Block coil = aBaseMetaTileEntity.getBlockOffset(xDir + 1, 1, zDir); + if (!(coil instanceof IHeatingCoil)) + return false; + IHeatingCoil heatingCoil = (IHeatingCoil) coil; 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++) { + HeatingCoilLevel heatingLevel = heatingCoil.getCoilHeat(tUsedMeta); + + 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; - } - } - } + + //Middle + if ((i == 0) && (j == 0)) + continue; + + 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); + + if (heatingLevelM != heatingLevel) + return false; + + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j) != GregTech_API.sBlockCasings1) + return false; + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j) != CASING_INDEX) + return false; + + //Controller + if ((xDir + i == 0) && (zDir + j == 0)) + continue; + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 0, zDir + j); + if (addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) + continue; + if (addInputToMachineList(tTileEntity, CASING_INDEX)) + continue; + if (addOutputToMachineList(tTileEntity, CASING_INDEX)) + continue; + if (addEnergyInputToMachineList(tTileEntity, CASING_INDEX)) + continue; + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 0, zDir + j) != GregTech_API.sBlockCasings1) + return false; + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 0, zDir + j) != CASING_INDEX) + return false; } - } + + this.mLevel = heatingLevel.getLevel(); + this.mCostDiscount = heatingLevel.getCostDiscount(); return true; } - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack){ - boolean result= this.checkMachineFunction(aBaseMetaTileEntity,aStack); - if (!result) this.mLevel=0; - return result; - } + + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack){ + return this.checkMachineFunction(aBaseMetaTileEntity,aStack); + } public int getMaxEfficiency(ItemStack aStack) { return 10000; @@ -271,40 +237,33 @@ public class GT_MetaTileEntity_MultiFurnace 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..5738703aef 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,6 +16,7 @@ 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; @@ -27,6 +30,9 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa 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); } @@ -46,7 +52,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,19 +62,14 @@ 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(); } 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]}; } public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { @@ -76,13 +79,22 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa @Override public boolean checkRecipe(ItemStack aStack) { ArrayList 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,18 +103,40 @@ 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) { + heatLevel = HeatingCoilLevel.None; this.orientation = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()); this.controllerX = aBaseMetaTileEntity.getXCoord(); this.controllerZ = aBaseMetaTileEntity.getZCoord(); @@ -111,127 +145,121 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa int amount = 0; replaceDeprecatedCoils(aBaseMetaTileEntity); boolean negSideInput = false, negSideOutput = false, posSideInput = false, posSideOutput = false; + // zDirection + // height + // xDirection + // height if (xDir != 0) { - for (int i = -1; i < 2; i++) {// xDirection - for (int j = -1; j < 2; j++) {// height + for (int i = -1; i < 2; i++) + for (int j = -1; j < 2; j++) for (int h = -2; h < 3; h++) { - if (!(j == 0 && i == 0 && (h == -1 || h == 0 || h == 1))) { - 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) { + if (j == 0 && i == 0 && (h == -1 || h == 0 || h == 1)) + continue; + if (h == 1 || h == -1) { + if (coilsNotPresent(aBaseMetaTileEntity, xDir + h, j, i + zDir)) + return false; + } + if (h == 2 || h == -2) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, j, h + zDir); + if (addInputToMachineList(tTileEntity, CASING_INDEX)) + if (h == -2) + negSideInput = true; + else + posSideInput = true; + else if (addOutputToMachineList(tTileEntity, CASING_INDEX)) + if (h == -2) + negSideOutput = true; + else + posSideOutput = true; + else if (!addEnergyInputToMachineList(tTileEntity, CASING_INDEX)) + if (!addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, j, h + zDir) != GregTech_API.sBlockCasings4) return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, j, h + zDir) != 1) { + 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++; - } - } - } - } + if (h == 0) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, j, h + zDir); + if (addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) + continue; + if (addInputToMachineList(tTileEntity, CASING_INDEX)) + continue; + if (addEnergyInputToMachineList(tTileEntity, CASING_INDEX)) + continue; + if ((xDir + i) == 0 && j == 0 && (h + zDir) == 0) + continue; + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, j, h + zDir) != GregTech_API.sBlockCasings4) + return false; + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, j, h + zDir) != 1) + return false; + amount++; + } + } - } - } - } else { - for (int i = -1; i < 2; i++) {// zDirection - for (int j = -1; j < 2; j++) {// height + } else + for (int i = -1; i < 2; i++) + for (int j = -1; j < 2; j++) for (int h = -2; h < 3; h++) { - if (!(j == 0 && i == 0 && (h == -1 || h == 0 || h == 1))) { - 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 (j == 0 && i == 0 && (h == -1 || h == 0 || h == 1)) + continue; + if (h == 1 || h == -1) { + if (coilsNotPresent(aBaseMetaTileEntity, xDir + h, j, i + zDir)) + return false; + } else { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + h, j, i + zDir); if (h == 2 || h == -2) { - 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) { + if (addInputToMachineList(tTileEntity, CASING_INDEX)) + if (h == -2) + negSideInput = true; + else + posSideInput = true; + else if (addOutputToMachineList(tTileEntity, CASING_INDEX)) { + if (h == -2) + negSideOutput = true; + else + posSideOutput = true; + } else { + if (addEnergyInputToMachineList(tTileEntity, CASING_INDEX)) + continue; + if (addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) + continue; + if (aBaseMetaTileEntity.getBlockOffset(xDir + h, j, i + zDir) != GregTech_API.sBlockCasings4) return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + h, j, i + zDir) != 1) { + 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++; - } - } - } + } else { + if (addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) + continue; + if (addInputToMachineList(tTileEntity, CASING_INDEX)) + continue; + if (addEnergyInputToMachineList(tTileEntity, CASING_INDEX)) + continue; + if (j == 0 && i + zDir == 0) + continue; + if (aBaseMetaTileEntity.getBlockOffset(0, j, i + zDir) != GregTech_API.sBlockCasings4) + return false; + if (aBaseMetaTileEntity.getMetaIDOffset(0, j, i + zDir) != 1) + return false; + amount++; + } } } - } - } - } - if ((negSideInput && negSideOutput) || (posSideInput && posSideOutput) - || (negSideInput && posSideInput) || (negSideOutput && posSideOutput)) { - return false; - } - if (amount < 18) return false; - return true; + + if (negSideInput && negSideOutput) + return false; + if (posSideInput && posSideOutput) + return false; + if (negSideInput && posSideInput) + return false; + if (negSideOutput && posSideOutput) + return false; + + return amount >= 18; } @Override @@ -267,50 +295,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 getStoredFluids() { - ArrayList rList = new ArrayList(); + ArrayList 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..b04510e981 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; @@ -28,9 +30,9 @@ import org.lwjgl.input.Keyboard; public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlockBase { - private int coilMetaID; + 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 final int CASING_INDEX = 1090; + private static final int CASING_INDEX = 1090; public GT_MetaTileEntity_PyrolyseOven(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -53,7 +55,7 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock .beginStructureBlock(5, 4, 5, true) .addController("Front center") .addCasingInfo("Pyrolyse Oven Casing", 60) - .addOtherStructurePart("Heating Coils (any tier)", "Center 3x1x3 of the bottom layer") + .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") @@ -86,8 +88,8 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock 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) { + 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(); @@ -96,14 +98,14 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock } } } - ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[0]), 0, 2); ArrayList 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) { + 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(); @@ -112,43 +114,43 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock } } } - 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); - } + FluidStack[] tFluids = Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); + if (tInputList.size() <= 0) + return false; - if (tRecipe != null && tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) { - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; + 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); - 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); + //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); } - 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; } + tRecipe = GT_Recipe.GT_Recipe_Map.sPyrolyseRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); } - return false; + + if (tRecipe == null || !tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) + return false; + + 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; } @Override @@ -166,29 +168,36 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock 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) { + if (h == 0) {// inner floor (Coils) + + Block coil = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + + if (!(coil instanceof IHeatingCoil)) return false; - } + int metaID = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); - if (metaID > 8) { + + HeatingCoilLevel coilHeat = ((IHeatingCoil)coil).getCoilHeat(metaID); + + if (coilHeat == HeatingCoilLevel.None) { return false; } else { if (firstCoil) { - this.coilMetaID = metaID; + this.coilHeat = coilHeat; firstCoil = false; - } else if (metaID != this.coilMetaID) { + } else if (coilHeat != this.coilHeat) { return false; } } } else if (h == 3) {// inner ceiling (ulv casings + input + muffler) - if ((!addInputToMachineList(tTileEntity, CASING_INDEX)) && (!addMufflerToMachineList(tTileEntity, CASING_INDEX))) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != CasingBlock) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != CasingMeta) { - return false; - } + if ((addInputToMachineList(tTileEntity, CASING_INDEX)) || (addMufflerToMachineList(tTileEntity, CASING_INDEX))) { + continue; + } + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != CasingBlock) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != CasingMeta) { + return false; } } else {// inside air if (!aBaseMetaTileEntity.getAirOffset(xDir + i, h, zDir + j)) { @@ -197,23 +206,28 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock } } 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; - } - } + if (addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) { + continue; } - } else {// outer above floor (ulv casings) - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != CasingBlock) { - return false; + + if (addOutputToMachineList(tTileEntity, CASING_INDEX)) { + continue; } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != CasingMeta) { - return false; + + if (addEnergyInputToMachineList(tTileEntity, CASING_INDEX)) { + continue; } + + if ((xDir + i == 0) && (zDir + j == 0)) { + continue; + }//no controller + } + // outer above floor (ulv casings) + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != CasingBlock) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != CasingMeta) { + return false; } } } @@ -255,7 +269,7 @@ 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++) { -- cgit From bc69f1a70cb6f5fe015ac96b4be373583d38783b Mon Sep 17 00:00:00 2001 From: Prometheus0000000 Date: Sat, 26 Dec 2020 20:13:33 -0500 Subject: Fixes chest buffers at higher tiers not working --- .../common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/gregtech/common/tileentities') diff --git a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java index 6605d4fc35..4e80b7b779 100644 --- a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java +++ b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java @@ -19,7 +19,7 @@ import java.util.Comparator; public class GT_MetaTileEntity_ChestBuffer extends GT_MetaTileEntity_Buffer { - private static final int[] tickRate = {400, 200, 100, 20, 4, 1, 1, 1,1,1}; + private static final int[] tickRate = {400, 200, 100, 20, 4, 1, 1, 1, 1, 1, 1, 1, 1}; public GT_MetaTileEntity_ChestBuffer(int aID, String aName, String aNameRegional, int aTier) { -- cgit From e141a558bbf5fa37c75d1420691fcf969e5759c8 Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Mon, 28 Dec 2020 04:28:06 +0100 Subject: Refactor + Added 2 more coils + Improved Tooltips --- .../java/gregtech/api/enums/HeatingCoilLevel.java | 59 ++-- src/main/java/gregtech/api/enums/ItemList.java | 2 + src/main/java/gregtech/api/enums/Textures.java | 2 + .../gregtech/common/blocks/GT_Block_Casings5.java | 26 +- .../gregtech/common/blocks/GT_Item_Casings5.java | 39 +-- .../GT_MetaTileEntity_AbstractMultiFurnace.java | 92 +++++++ .../GT_MetaTileEntity_ElectricBlastFurnace.java | 297 +++++++++------------ .../multi/GT_MetaTileEntity_MultiFurnace.java | 101 ++----- .../multi/GT_MetaTileEntity_PyrolyseOven.java | 46 ++-- .../textures/blocks/iconsets/MACHINE_COIL_HSSS.png | Bin 0 -> 496 bytes .../blocks/iconsets/MACHINE_COIL_TRINIUM.png | Bin 0 -> 510 bytes 11 files changed, 348 insertions(+), 316 deletions(-) create mode 100644 src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_COIL_HSSS.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_COIL_TRINIUM.png (limited to 'src/main/java/gregtech/common/tileentities') diff --git a/src/main/java/gregtech/api/enums/HeatingCoilLevel.java b/src/main/java/gregtech/api/enums/HeatingCoilLevel.java index 7b1b3f7334..56c09dccbe 100644 --- a/src/main/java/gregtech/api/enums/HeatingCoilLevel.java +++ b/src/main/java/gregtech/api/enums/HeatingCoilLevel.java @@ -1,64 +1,67 @@ package gregtech.api.enums; public enum HeatingCoilLevel { - None ( 0L), - // ULV ( 901L), //Not implemented - LV ( 1_801L), //Cupronickel - MV ( 2_701L), //KANTHAL - HV ( 3_601L), //NICHROME - EV ( 4_501L), //TUNGSTENSTEEL - IV ( 5_401L), //HSSG - // LuV ( 6_301L), //Not implemented - ZPM ( 7_201L), //NAQUADAH - UV ( 9_001L), //NAQUADAHALLOY - UHV ( 9_901L), //ELECTRUMFLUX - UEV (10_801L), //AWAKENEDDRACONIUM - UIV (11_701L), - + 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 (12_601L), - UXV (13_501L), - OpV (14_401L), - MAX (15_301L), + UMV, + UXV, + OpV, + MAX, ; - private final long HEAT; - - HeatingCoilLevel(long heat) { - this.HEAT = heat; + /** + * @return the coil heat, used for recipes in the Electronic Blast Furnace for example + */ + public String getTierName() { + if (this.ordinal() < 1 || (this.ordinal()-1) >= GT_Values.VN.length) + return "ERROR!"; + return GT_Values.VN[this.ordinal() - 1]; } + /** * @return the coil heat, used for recipes in the Electronic Blast Furnace for example */ public long getHeat() { - return HEAT; + 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() - 1); + 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() -1)); + 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 -4)); //-1 bcs. of none, -4 = offset + 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+1]; + 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 420c371c40..8fb41a2923 100644 --- a/src/main/java/gregtech/api/enums/ItemList.java +++ b/src/main/java/gregtech/api/enums/ItemList.java @@ -1440,7 +1440,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/common/blocks/GT_Block_Casings5.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java index 1e03541fde..3e2be76356 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java @@ -33,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)); @@ -43,6 +45,8 @@ 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 @@ -67,15 +71,17 @@ 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. ------------*/ - @Override - public HeatingCoilLevel getCoilHeat(int meta) { - getOnCoilCheck().accept(this); + public static HeatingCoilLevel getCoilHeatFromDamage(int meta) { switch (meta) { case 0: return LV; @@ -92,17 +98,27 @@ public class GT_Block_Casings5 case 6: return UV; case 7: - return UHV; + 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 callback; + private Consumer callback = coil -> {}; @Override public void setOnCoilCheck(Consumer callback) { 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..a1d2920f59 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 final static String mCoilHeatTooltip = GT_LanguageManager.addStringLocalization("gt.coilheattooltip", "Base Heating Capacity = "); + protected final static String mCoilUnitTooltip = GT_LanguageManager.addStringLocalization("gt.coilunittooltip", "Kelvin"); + protected final static 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/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..e629f78d1d --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java @@ -0,0 +1,92 @@ +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; + + public GT_MetaTileEntity_AbstractMultiFurnace(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_AbstractMultiFurnace(String aName) { + super(aName); + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + 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; + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerTick(ItemStack aStack) { + return 20; + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + 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 c3b960476d..d4643ab4c8 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,40 +1,38 @@ 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 gregtech.api.enums.HeatingCoilLevel; -import gregtech.api.interfaces.IHeatingCoil; -import net.minecraft.block.Block; -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 java.util.ArrayList; + +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), @@ -55,35 +53,35 @@ public class GT_MetaTileEntity_ElectricBlastFurnace } 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", "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(); + } } public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { @@ -177,18 +175,18 @@ public class GT_MetaTileEntity_ElectricBlastFurnace if (this.mEUt > 0) { this.mEUt = (-this.mEUt); } - if(tHeatCapacityDivTiers > 0) { + 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 >>= 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[] { + this.mOutputItems = new ItemStack[]{ tRecipe.getOutput(0), tRecipe.getOutput(1) }; - this.mOutputFluids = new FluidStack[] { + this.mOutputFluids = new FluidStack[]{ tRecipe.getFluidOutput(0) }; updateSlots(); @@ -197,46 +195,47 @@ public class GT_MetaTileEntity_ElectricBlastFurnace /** * 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 = 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 } } @@ -249,95 +248,59 @@ 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)) - return false; - - if (!addMufflerToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 3, zDir), CASING_INDEX)) - return false; replaceDeprecatedCoils(aBaseMetaTileEntity); - Block heatingCoil = aBaseMetaTileEntity.getBlockOffset(xDir + 1, 2, zDir); - if (!(heatingCoil instanceof IHeatingCoil)) + HeatingCoilLevel heatingCap = getInitialHeatLevel(aBaseMetaTileEntity, xDir, zDir); + if (heatingCap == null) return false; - byte tUsedMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + 1, 2, zDir); - HeatingCoilLevel heatingCap = ((IHeatingCoil)heatingCoil).getCoilHeat(tUsedMeta); - - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if ((i == 0) && (j == 0)) - continue; - if ((xDir + i == 0) && (zDir + j == 0)) - continue; - - Block blockLow = aBaseMetaTileEntity.getBlockOffset(xDir + i, 1, zDir); - if (!(blockLow instanceof IHeatingCoil)) - return false; - - Block blockHi = aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir); - if (!(blockHi instanceof IHeatingCoil)) - return false; - - byte metaLow = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir); - HeatingCoilLevel coilHeatLow = ((IHeatingCoil) blockLow).getCoilHeat(metaLow); - byte metaHi = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir); - HeatingCoilLevel coilHeatHi = ((IHeatingCoil) blockHi).getCoilHeat(metaHi); - - if (heatingCap != coilHeatLow || heatingCap != coilHeatHi) - return false; + if (!checkStructure(heatingCap, xDir, zDir, aBaseMetaTileEntity)) + return false; - if (addOutputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 3, zDir + j), CASING_INDEX)) - continue; + this.mHeatingCapacity = (int) heatingCap.getHeat(); + this.mHeatingCapacity += 100 * (GT_Utility.getTier(getMaxInputVoltage()) - 2); + return true; + } - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 3, zDir + j) != GregTech_API.sBlockCasings1) - return false; + 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; - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 3, zDir + j) != CASING_INDEX) - return false; + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 3, zDir + j) != GregTech_API.sBlockCasings1) + return false; - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 0, zDir + j); + return aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 3, zDir + j) == CASING_INDEX; + } - if (addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) - continue; - if (addInputToMachineList(tTileEntity, CASING_INDEX)) - continue; - if (addOutputToMachineList(tTileEntity, CASING_INDEX)) - continue; - if (addEnergyInputToMachineList(tTileEntity, CASING_INDEX)) - continue; + 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; - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 0, zDir + j) != GregTech_API.sBlockCasings1) - return false; - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 0, zDir + j) != CASING_INDEX) - return false; - } + return aBaseMetaTileEntity.getAirOffset(xDir, 2, zDir); } - this.mHeatingCapacity = (int) heatingCap.getHeat(); - this.mHeatingCapacity += 100 * (GT_Utility.getTier(getMaxInputVoltage()) - 2); - return true; - } - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack){ - return this.checkMachineFunction(aBaseMetaTileEntity,aStack); - } + Block blockLow = aBaseMetaTileEntity.getBlockOffset(xDir + i, 1, zDir + j); + if (!(blockLow instanceof IHeatingCoil)) + return false; - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } + Block blockHi = aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j); + if (!(blockHi instanceof IHeatingCoil)) + return false; - public int getPollutionPerTick(ItemStack aStack) { - return 20; - } + 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); - public int getDamageToComponent(ItemStack aStack) { - return 0; + return heatingCap == coilHeatLow && heatingCap == coilHeatHi; } - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + return this.checkMachineFunction(aBaseMetaTileEntity, aStack); } private void replaceDeprecatedCoils(IGregTechTileEntity aBaseMetaTileEntity) { @@ -372,9 +335,11 @@ public class GT_MetaTileEntity_ElectricBlastFurnace } } } + @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; @@ -417,37 +382,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)) continue; - mPollutionReduction=Math.max(tHatch.calculatePollutionReduction(100),mPollutionReduction); + mPollutionReduction = Math.max(tHatch.calculatePollutionReduction(100), mPollutionReduction); } - long storedEnergy=0; - long maxEnergy=0; - for(GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { + 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(); + 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 580bbea08d..cdd539c72d 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 @@ -10,7 +10,6 @@ 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; @@ -29,7 +28,7 @@ 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; @@ -84,14 +83,6 @@ public class GT_MetaTileEntity_MultiFurnace return GT_Recipe.GT_Recipe_Map.sFurnaceRecipes; } - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; - } - public boolean checkRecipe(ItemStack aStack) { ArrayList tInputList = getStoredInputs(); if (tInputList.isEmpty()) @@ -155,82 +146,46 @@ public class GT_MetaTileEntity_MultiFurnace this.mLevel = 0; this.mCostDiscount = 1; - if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) + replaceDeprecatedCoils(aBaseMetaTileEntity); + HeatingCoilLevel heatingCap = getInitialHeatLevel(aBaseMetaTileEntity, xDir, zDir); + if (heatingCap == null) return false; - addMufflerToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 2, zDir), CASING_INDEX); - replaceDeprecatedCoils(aBaseMetaTileEntity); - Block coil = aBaseMetaTileEntity.getBlockOffset(xDir + 1, 1, zDir); - if (!(coil instanceof IHeatingCoil)) + if (!checkStructure(heatingCap, xDir, zDir, aBaseMetaTileEntity)) return false; - IHeatingCoil heatingCoil = (IHeatingCoil) coil; - byte tUsedMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + 1, 1, zDir); - HeatingCoilLevel heatingLevel = heatingCoil.getCoilHeat(tUsedMeta); - - for (int i = -1; i < 2; i++) - for (int j = -1; j < 2; j++) { - - //Middle - if ((i == 0) && (j == 0)) - continue; - - 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); - - if (heatingLevelM != heatingLevel) - return false; - - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j) != GregTech_API.sBlockCasings1) - return false; - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j) != CASING_INDEX) - return false; - - //Controller - if ((xDir + i == 0) && (zDir + j == 0)) - continue; - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 0, zDir + j); - if (addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) - continue; - if (addInputToMachineList(tTileEntity, CASING_INDEX)) - continue; - if (addOutputToMachineList(tTileEntity, CASING_INDEX)) - continue; - if (addEnergyInputToMachineList(tTileEntity, CASING_INDEX)) - continue; - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 0, zDir + j) != GregTech_API.sBlockCasings1) - return false; - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 0, zDir + j) != CASING_INDEX) - return false; - } - this.mLevel = heatingLevel.getLevel(); - this.mCostDiscount = heatingLevel.getCostDiscount(); + this.mLevel = heatingCap.getLevel(); + this.mCostDiscount = heatingCap.getCostDiscount(); return true; } - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack){ - return this.checkMachineFunction(aBaseMetaTileEntity,aStack); - } + 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); - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } + Block coilM = aBaseMetaTileEntity.getBlockOffset(xDir + i, 1, zDir + j); + if (!(coilM instanceof IHeatingCoil)) + return false; + byte usedMetaM = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir + j); - public int getPollutionPerTick(ItemStack aStack) { - return 20; + IHeatingCoil heatingCoilM = (IHeatingCoil) coilM; + HeatingCoilLevel heatingLevelM = heatingCoilM.getCoilHeat(usedMetaM); + + return heatingLevelM == heatingCap; } - public int getDamageToComponent(ItemStack aStack) { - return 0; + 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 (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; + + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack){ + return this.checkMachineFunction(aBaseMetaTileEntity,aStack); } private void replaceDeprecatedCoils(IGregTechTileEntity aBaseMetaTileEntity) { 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 b04510e981..b4e657295e 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java @@ -22,12 +22,11 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; +import org.lwjgl.input.Keyboard; import java.util.ArrayList; import java.util.Arrays; -import org.lwjgl.input.Keyboard; - public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlockBase { private HeatingCoilLevel coilHeat; @@ -90,9 +89,11 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock 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(); + tInputList.remove(j--); + tInputList_sS=tInputList.size(); } else { - tInputList.remove(i--); tInputList_sS=tInputList.size(); + tInputList.remove(i--); + tInputList_sS=tInputList.size(); break; } } @@ -106,9 +107,11 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock 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(); + tFluidList.remove(j--); + tFluidList_sS=tFluidList.size(); } else { - tFluidList.remove(i--); tFluidList_sS=tFluidList.size(); + tFluidList.remove(i--); + tFluidList_sS=tFluidList.size(); break; } } @@ -123,15 +126,19 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sPyrolyseRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); //Dynamic recipe adding for newly found logWoods - wont be visible in nei most probably - if(tRecipe==null){ - for(ItemStack is:tInputs) { - for (int id : OreDictionary.getOreIDs(is)) { - if (OreDictionary.getOreName(id).equals("logWood")) - ProcessingLog.addPyrolyeOvenRecipes(is); + if(tRecipe == null) + if (tInputs.length > 1 || (tInputs[0] != null && tInputs[0].getItem() != GT_Utility.getIntegratedCircuit(0).getItem())) { + int oreId = OreDictionary.getOreID("logWood"); + outer : for(ItemStack is : tInputs) { + for (int id : OreDictionary.getOreIDs(is)) { + if (oreId == id) { + ProcessingLog.addPyrolyeOvenRecipes(is); + tRecipe = GT_Recipe.GT_Recipe_Map.sPyrolyseRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + break outer; + } + } } } - tRecipe = GT_Recipe.GT_Recipe_Map.sPyrolyseRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - } if (tRecipe == null || !tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) return false; @@ -157,9 +164,16 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock 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= Loader.isModLoaded("dreamcraft")? GameRegistry.findBlock("dreamcraft","gt.blockcasingsNH"): GregTech_API.sBlockCasings1; - int CasingMeta= Loader.isModLoaded("dreamcraft")?2:0; + Block CasingBlock; + int CasingMeta; + + if (Loader.isModLoaded("dreamcraft")){ + CasingBlock = GameRegistry.findBlock("dreamcraft","gt.blockcasingsNH"); + CasingMeta = 2; + } else { + CasingBlock = GregTech_API.sBlockCasings1; + CasingMeta = 0; + } replaceDeprecatedCoils(aBaseMetaTileEntity); boolean firstCoil = true; diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_COIL_HSSS.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_COIL_HSSS.png new file mode 100644 index 0000000000..3851bf2c41 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_COIL_HSSS.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_COIL_TRINIUM.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_COIL_TRINIUM.png new file mode 100644 index 0000000000..f110674d6b Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_COIL_TRINIUM.png differ -- cgit From fae05f1aa4959c5b165400ed41398685c90a047a Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Mon, 28 Dec 2020 04:33:17 +0100 Subject: Fixed small oversight --- .../tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/gregtech/common/tileentities') 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 cdd539c72d..dae1816801 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 @@ -176,7 +176,7 @@ public class GT_MetaTileEntity_MultiFurnace 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); + return addMufflerToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 2, zDir), CASING_INDEX); } if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j) != GregTech_API.sBlockCasings1) return false; -- cgit From 4e04bf5e76ad92e1cc1b2b2eeaa0bc141975e73a Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Mon, 28 Dec 2020 15:02:27 +0100 Subject: More Refactor --- .../GT_MetaTileEntity_MultiBlockBase.java | 65 +++- .../GT_MetaTileEntity_ElectricBlastFurnace.java | 42 +-- .../multi/GT_MetaTileEntity_OilCracker.java | 219 +++++++------ .../multi/GT_MetaTileEntity_PyrolyseOven.java | 337 +++++++++++---------- 4 files changed, 346 insertions(+), 317 deletions(-) (limited to 'src/main/java/gregtech/common/tileentities') 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..b859607ada 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 mInputHatches = new ArrayList(); - public ArrayList mOutputHatches = new ArrayList(); - public ArrayList mInputBusses = new ArrayList(); - public ArrayList mOutputBusses = new ArrayList(); - public ArrayList mDynamoHatches = new ArrayList(); - public ArrayList mMufflerHatches = new ArrayList(); - public ArrayList mEnergyHatches = new ArrayList(); - public ArrayList mMaintenanceHatches = new ArrayList(); + public ArrayList mInputHatches = new ArrayList<>(); + public ArrayList mOutputHatches = new ArrayList<>(); + public ArrayList mInputBusses = new ArrayList<>(); + public ArrayList mOutputBusses = new ArrayList<>(); + public ArrayList mDynamoHatches = new ArrayList<>(); + public ArrayList mMufflerHatches = new ArrayList<>(); + public ArrayList mEnergyHatches = new ArrayList<>(); + public ArrayList 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 getStoredOutputs() { - ArrayList rList = new ArrayList(); + ArrayList 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 getStoredFluids() { - ArrayList rList = new ArrayList(); + ArrayList 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 getStoredInputs() { - ArrayList rList = new ArrayList(); + ArrayList rList = new ArrayList<>(); // for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { // tHatch.mRecipeMap = getRecipeMap(); // if (isValidMetaTileEntity(tHatch) && tHatch.getBaseMetaTileEntity().getStackInSlot(0) != null) { @@ -1003,4 +1003,45 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { return false; } + + protected ItemStack[] getCompactedInputs(){ + ArrayList 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(){ + ArrayList 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/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java index d4643ab4c8..33d071dc6f 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java @@ -26,8 +26,6 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import org.lwjgl.input.Keyboard; -import java.util.ArrayList; - import static gregtech.api.enums.GT_Values.V; import static gregtech.api.enums.GT_Values.VN; @@ -108,44 +106,10 @@ public class GT_MetaTileEntity_ElectricBlastFurnace } public boolean checkRecipe(ItemStack aStack) { - ArrayList tInputList = getStoredInputs(); - int tInputList_sS = tInputList.size(); - for (int i = 0; i < tInputList_sS - 1; i++) { - for (int j = i + 1; j < tInputList_sS; j++) { - if (!GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) - continue; - - if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { - tInputList.remove(j--); - tInputList_sS = tInputList.size(); - } else { - tInputList.remove(i--); - tInputList_sS = tInputList.size(); - break; - } - } - } - ItemStack[] tInputs = tInputList.toArray(new ItemStack[0]); + ItemStack[] tInputs = getCompactedInputs(); + FluidStack[] tFluids = getCompactedFluids(); - ArrayList tFluidList = getStoredFluids(); - int tFluidList_sS = tFluidList.size(); - for (int i = 0; i < tFluidList_sS - 1; i++) { - for (int j = i + 1; j < tFluidList_sS; j++) { - if (!GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) - continue; - - if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { - tFluidList.remove(j--); - tFluidList_sS = tFluidList.size(); - } else { - tFluidList.remove(i--); - tFluidList_sS = tFluidList.size(); - break; - } - } - } - FluidStack[] tFluids = tFluidList.toArray(new FluidStack[0]); - if (tInputList.size() <= 0) + if (tInputs.length <= 0) return false; long tVoltage = getMaxInputVoltage(); diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java index 5738703aef..67d696438d 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java @@ -21,10 +21,11 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; +import org.apache.commons.lang3.mutable.MutableInt; +import org.lwjgl.input.Keyboard; import java.util.ArrayList; - -import org.lwjgl.input.Keyboard; +import java.util.BitSet; public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBase { private ForgeDirection orientation; @@ -136,130 +137,120 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - heatLevel = HeatingCoilLevel.None; + this.heatLevel = HeatingCoilLevel.None; this.orientation = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()); this.controllerX = aBaseMetaTileEntity.getXCoord(); this.controllerZ = aBaseMetaTileEntity.getZCoord(); int xDir = this.orientation.offsetX; int zDir = this.orientation.offsetZ; - int amount = 0; + MutableInt amount = new MutableInt(0); replaceDeprecatedCoils(aBaseMetaTileEntity); - boolean negSideInput = false, negSideOutput = false, posSideInput = false, posSideOutput = false; - // zDirection - // height - // xDirection - // height - if (xDir != 0) { - for (int i = -1; i < 2; i++) - for (int j = -1; j < 2; j++) - for (int h = -2; h < 3; h++) { - if (j == 0 && i == 0 && (h == -1 || h == 0 || h == 1)) - continue; - if (h == 1 || h == -1) { - if (coilsNotPresent(aBaseMetaTileEntity, xDir + h, j, i + zDir)) - return false; - } - if (h == 2 || h == -2) { - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, j, h + zDir); - if (addInputToMachineList(tTileEntity, CASING_INDEX)) - if (h == -2) - negSideInput = true; - else - posSideInput = true; - else if (addOutputToMachineList(tTileEntity, CASING_INDEX)) - if (h == -2) - negSideOutput = true; - else - posSideOutput = true; - else if (!addEnergyInputToMachineList(tTileEntity, CASING_INDEX)) - if (!addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, j, h + zDir) != GregTech_API.sBlockCasings4) - return false; - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, j, h + zDir) != 1) - return false; - amount++; - } - } - if (h == 0) { - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, j, h + zDir); - if (addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) - continue; - if (addInputToMachineList(tTileEntity, CASING_INDEX)) - continue; - if (addEnergyInputToMachineList(tTileEntity, CASING_INDEX)) - continue; - if ((xDir + i) == 0 && j == 0 && (h + zDir) == 0) - continue; - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, j, h + zDir) != GregTech_API.sBlockCasings4) - return false; - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, j, h + zDir) != 1) - return false; - amount++; - } - - } - } else - for (int i = -1; i < 2; i++) - for (int j = -1; j < 2; j++) - for (int h = -2; h < 3; h++) { - if (j == 0 && i == 0 && (h == -1 || h == 0 || h == 1)) - continue; - if (h == 1 || h == -1) { - if (coilsNotPresent(aBaseMetaTileEntity, xDir + h, j, i + zDir)) - return false; - } else { - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + h, j, i + zDir); - if (h == 2 || h == -2) { - if (addInputToMachineList(tTileEntity, CASING_INDEX)) - if (h == -2) - negSideInput = true; - else - posSideInput = true; - else if (addOutputToMachineList(tTileEntity, CASING_INDEX)) { - if (h == -2) - negSideOutput = true; - else - posSideOutput = true; - } else { - if (addEnergyInputToMachineList(tTileEntity, CASING_INDEX)) - continue; - if (addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) - continue; - if (aBaseMetaTileEntity.getBlockOffset(xDir + h, j, i + zDir) != GregTech_API.sBlockCasings4) - return false; - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + h, j, i + zDir) != 1) - return false; - amount++; - } - } else { - if (addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) - continue; - if (addInputToMachineList(tTileEntity, CASING_INDEX)) - continue; - if (addEnergyInputToMachineList(tTileEntity, CASING_INDEX)) - continue; - - if (j == 0 && i + zDir == 0) - continue; - if (aBaseMetaTileEntity.getBlockOffset(0, j, i + zDir) != GregTech_API.sBlockCasings4) - return false; - if (aBaseMetaTileEntity.getMetaIDOffset(0, j, i + zDir) != 1) - return false; - amount++; - } - } + BitSet flags = new BitSet(4); + + for (int depth = -1; depth < 2; depth++) + for (int height = -1; height < 2; height++) + for (int slice = -2; slice < 3; slice++) + if (xDir != 0) { + if (isStructureBroken(xDir, zDir, depth, height, slice, aBaseMetaTileEntity, amount, flags)) + return false; + } else { + if (isStructureBroken(xDir, zDir, slice, height, depth, aBaseMetaTileEntity, amount, flags)) + return false; } - if (negSideInput && negSideOutput) + if(checkInputOutputBroken(flags)) return false; - if (posSideInput && posSideOutput) + + return amount.intValue() >= 18; + } + + private boolean checkInputOutputBroken(BitSet flags){ + if (flags.get(0) && flags.get(2)) //input and output on side 1 + return true; + if (flags.get(1) && flags.get(3)) //input and output on side 2 + return true; + if (flags.get(1) && flags.get(2)) //input on both sides + return true; + return flags.get(2) && flags.get(3); //output on both sides + } + + private boolean isStructureBroken( + int xDir, + int zDir, + int a, + int b, + int c, + IGregTechTileEntity aBaseMetaTileEntity, + MutableInt amount, + BitSet flags) { + if (b == 0 && c == 0 && (a == -1 || a == 0 || a == 1)) return false; - if (negSideInput && posSideInput) + if (a == 1 || a == -1) { + return coilsNotPresent(aBaseMetaTileEntity, xDir + a, b, c + zDir); + } + else if (a == 2 || a == -2) { + return checkEndsBroken(xDir, zDir, a, b, c, aBaseMetaTileEntity, amount, flags); + } + else if (a == 0) + return checkMiddleBroken(xDir, zDir, a, b, c, aBaseMetaTileEntity, amount); + + return false; + } + + private boolean checkEndsBroken( + int xDir, + int zDir, + int a, + int b, + int c, + IGregTechTileEntity aBaseMetaTileEntity, + MutableInt amount, + BitSet flags + ){ + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + c, b, a + zDir); + if (addInputToMachineList(tTileEntity, CASING_INDEX)) + if (a == -2) + flags.set(0); //input on side 1 + else + flags.set(1); //input on side 2 + else if (addOutputToMachineList(tTileEntity, CASING_INDEX)) + if (a == -2) + flags.set(2); //output on side 1 + else + flags.set(3); //output on side 2 + else if (!addEnergyInputToMachineList(tTileEntity, CASING_INDEX)) + if (!addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + c, b, a + zDir) != GregTech_API.sBlockCasings4) + return true; + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + c, b, a + zDir) != 1) + return true; + amount.increment(); + } + return false; + } + + private boolean checkMiddleBroken( int xDir, + int zDir, + int a, + int b, + int c, + IGregTechTileEntity aBaseMetaTileEntity, + MutableInt amount){ + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + c, b, a + zDir); + if (addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) return false; - if (negSideOutput && posSideOutput) + if (addInputToMachineList(tTileEntity, CASING_INDEX)) return false; - - return amount >= 18; + if (addEnergyInputToMachineList(tTileEntity, CASING_INDEX)) + return false; + if ((xDir + c) == 0 && b == 0 && (a + zDir) == 0) + return false; + if (aBaseMetaTileEntity.getBlockOffset(xDir + c, b, a + zDir) != GregTech_API.sBlockCasings4) + return true; + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + c, b, a + zDir) != 1) + return true; + amount.increment(); + return false; } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java index b4e657295e..96c661e283 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java @@ -22,16 +22,14 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; +import org.apache.commons.lang3.mutable.MutableBoolean; import org.lwjgl.input.Keyboard; -import java.util.ArrayList; -import java.util.Arrays; - public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlockBase { - - private HeatingCoilLevel coilHeat; - //public static GT_CopiedBlockTexture mTextureULV = new GT_CopiedBlockTexture(Block.getBlockFromItem(ItemList.Casing_ULV.get(1).getItem()), 6, 0, Dyes.MACHINE_METAL.mRGBa); - private static final int CASING_INDEX = 1090; + + private HeatingCoilLevel coilHeat; + //public static GT_CopiedBlockTexture mTextureULV = new GT_CopiedBlockTexture(Block.getBlockFromItem(ItemList.Casing_ULV.get(1).getItem()), 6, 0, Dyes.MACHINE_METAL.mRGBa); + private static final int CASING_INDEX = 1090; public GT_MetaTileEntity_PyrolyseOven(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -42,32 +40,32 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock } public String[] getDescription() { - final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType("Coke Oven") - .addInfo("Controller block for the Pyrolyse Oven") - .addInfo("Industrial Charcoal producer") - .addInfo("Processing speed scales linearly with Coil tier:") - .addInfo("CuNi: 50%, FeAlCr: 100%, Ni4Cr: 150%, Fe50CW: 200%, etc.") - .addInfo("EU/t is not affected by Coil tier") - .addPollutionAmount(20 * getPollutionPerTick(null)) - .addSeparator() - .beginStructureBlock(5, 4, 5, true) - .addController("Front center") - .addCasingInfo("Pyrolyse Oven Casing", 60) - .addOtherStructurePart("Heating Coils", "Center 3x1x3 of the bottom layer") - .addEnergyHatch("Any bottom layer casing") - .addMaintenanceHatch("Any bottom layer casing") - .addMufflerHatch("Center 3x1x3 area in top layer") - .addInputBus("Center 3x1x3 area in top layer") - .addInputHatch("Center 3x1x3 area in top layer") - .addOutputBus("Any bottom layer casing") - .addOutputHatch("Any bottom layer casing") - .toolTipFinisher("Gregtech"); - if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getInformation(); - } else { - return tt.getStructureInformation(); - } + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Coke Oven") + .addInfo("Controller block for the Pyrolyse Oven") + .addInfo("Industrial Charcoal producer") + .addInfo("Processing speed scales linearly with Coil tier:") + .addInfo("CuNi: 50%, FeAlCr: 100%, Ni4Cr: 150%, Fe50CW: 200%, etc.") + .addInfo("EU/t is not affected by Coil tier") + .addPollutionAmount(20 * getPollutionPerTick(null)) + .addSeparator() + .beginStructureBlock(5, 4, 5, true) + .addController("Front center") + .addCasingInfo("Pyrolyse Oven Casing", 60) + .addOtherStructurePart("Heating Coils", "Center 3x1x3 of the bottom layer") + .addEnergyHatch("Any bottom layer casing") + .addMaintenanceHatch("Any bottom layer casing") + .addMufflerHatch("Center 3x1x3 area in top layer") + .addInputBus("Center 3x1x3 area in top layer") + .addInputHatch("Center 3x1x3 area in top layer") + .addOutputBus("Any bottom layer casing") + .addOutputHatch("Any bottom layer casing") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { @@ -83,42 +81,10 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock @Override public boolean checkRecipe(ItemStack aStack) { - ArrayList tInputList = getStoredInputs(); - int tInputList_sS=tInputList.size(); - for (int i = 0; i < tInputList_sS - 1; i++) { - for (int j = i + 1; j < tInputList_sS; j++) { - if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { - if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { - tInputList.remove(j--); - tInputList_sS=tInputList.size(); - } else { - tInputList.remove(i--); - tInputList_sS=tInputList.size(); - break; - } - } - } - } - ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[0]), 0, 2); - - ArrayList tFluidList = getStoredFluids(); - int tFluidList_sS=tFluidList.size(); - for (int i = 0; i < tFluidList_sS - 1; i++) { - for (int j = i + 1; j < tFluidList_sS; j++) { - if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { - if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { - tFluidList.remove(j--); - tFluidList_sS=tFluidList.size(); - } else { - tFluidList.remove(i--); - tFluidList_sS=tFluidList.size(); - break; - } - } - } - } - FluidStack[] tFluids = Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); - if (tInputList.size() <= 0) + ItemStack[] tInputs = getCompactedInputs(); + FluidStack[] tFluids = getCompactedFluids(); + + if (tInputs.length <= 0) return false; long tVoltage = getMaxInputVoltage(); @@ -126,19 +92,8 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sPyrolyseRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); //Dynamic recipe adding for newly found logWoods - wont be visible in nei most probably - if(tRecipe == null) - if (tInputs.length > 1 || (tInputs[0] != null && tInputs[0].getItem() != GT_Utility.getIntegratedCircuit(0).getItem())) { - int oreId = OreDictionary.getOreID("logWood"); - outer : for(ItemStack is : tInputs) { - for (int id : OreDictionary.getOreIDs(is)) { - if (oreId == id) { - ProcessingLog.addPyrolyeOvenRecipes(is); - tRecipe = GT_Recipe.GT_Recipe_Map.sPyrolyseRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - break outer; - } - } - } - } + if (tRecipe == null) + tRecipe = addRecipesDynamically(tInputs, tFluids, tTier); if (tRecipe == null || !tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) return false; @@ -153,96 +108,69 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock if (this.mEUt > 0) this.mEUt = (-this.mEUt); this.mMaxProgresstime = Math.max(mMaxProgresstime * 2 / (1 + coilHeat.getTier()), 1); - if (tRecipe.mOutputs.length > 0) this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; + if (tRecipe.mOutputs.length > 0) + this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; if (tRecipe.mFluidOutputs.length > 0) this.mOutputFluids = new FluidStack[]{tRecipe.getFluidOutput(0)}; updateSlots(); return true; } + private GT_Recipe addRecipesDynamically(ItemStack[] tInputs, FluidStack[] tFluids, int tTier) { + if (tInputs.length > 1 || (tInputs[0] != null && tInputs[0].getItem() != GT_Utility.getIntegratedCircuit(0).getItem())) { + int oreId = OreDictionary.getOreID("logWood"); + for (ItemStack is : tInputs) { + for (int id : OreDictionary.getOreIDs(is)) { + if (oreId == id) { + ProcessingLog.addPyrolyeOvenRecipes(is); + return GT_Recipe.GT_Recipe_Map.sPyrolyseRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + } + } + } + } + return null; + } + @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2; int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2; - Block CasingBlock; - int CasingMeta; + Block casingBlock; + int casingMeta; - if (Loader.isModLoaded("dreamcraft")){ - CasingBlock = GameRegistry.findBlock("dreamcraft","gt.blockcasingsNH"); - CasingMeta = 2; + if (Loader.isModLoaded("dreamcraft")) { + casingBlock = GameRegistry.findBlock("dreamcraft", "gt.blockcasingsNH"); + casingMeta = 2; } else { - CasingBlock = GregTech_API.sBlockCasings1; - CasingMeta = 0; + casingBlock = GregTech_API.sBlockCasings1; + casingMeta = 0; } replaceDeprecatedCoils(aBaseMetaTileEntity); - boolean firstCoil = true; + MutableBoolean firstCoil = new MutableBoolean(true); for (int i = -2; i < 3; i++) { for (int j = -2; j < 3; j++) { for (int h = 0; h < 4; h++) { IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); if ((i != -2 && i != 2) && (j != -2 && j != 2)) {// inner 3x3 without height - if (h == 0) {// inner floor (Coils) - - Block coil = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - - if (!(coil instanceof IHeatingCoil)) - return false; - - int metaID = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); - - HeatingCoilLevel coilHeat = ((IHeatingCoil)coil).getCoilHeat(metaID); - - if (coilHeat == HeatingCoilLevel.None) { - return false; - } else { - if (firstCoil) { - this.coilHeat = coilHeat; - firstCoil = false; - } else if (coilHeat != this.coilHeat) { - return false; - } - } - } else if (h == 3) {// inner ceiling (ulv casings + input + muffler) - if ((addInputToMachineList(tTileEntity, CASING_INDEX)) || (addMufflerToMachineList(tTileEntity, CASING_INDEX))) { - continue; - } - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != CasingBlock) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != CasingMeta) { - return false; - } - } else {// inside air - if (!aBaseMetaTileEntity.getAirOffset(xDir + i, h, zDir + j)) { - return false; - } - } - } else {// outer 5x5 without height - if (h == 0) {// outer floor (controller, output, energy, maintainance, rest ulv casings) - if (addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) { - continue; - } - - if (addOutputToMachineList(tTileEntity, CASING_INDEX)) { - continue; - } - - if (addEnergyInputToMachineList(tTileEntity, CASING_INDEX)) { - continue; - } - - if ((xDir + i == 0) && (zDir + j == 0)) { - continue; - }//no controller - } - // outer above floor (ulv casings) - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != CasingBlock) { + if (checkInnerBroken( + xDir, zDir, + i, h, j, + aBaseMetaTileEntity, tTileEntity, + casingBlock, casingMeta, + firstCoil + ) + ) return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != CasingMeta) { + } else {// outer 5x5 without height + if (checkOuterBroken( + xDir, zDir, + i, h, j, + aBaseMetaTileEntity, tTileEntity, + casingBlock, casingMeta + ) + ) return false; - } } } } @@ -250,6 +178,112 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock return true; } + private boolean checkInnerBroken(int xDir, + int zDir, + int a, + int b, + int c, + IGregTechTileEntity aBaseMetaTileEntity, + IGregTechTileEntity tTileEntity, + Block casingBlock, + int casingMeta, + MutableBoolean firstCoil + ) { + if (b == 0) {// inner floor (Coils) + return areCoilsBroken(xDir, zDir, a, b, c, aBaseMetaTileEntity, firstCoil); + } else if (b == 3) {// inner ceiling (ulv casings + input + muffler) + return checkInnerCeilingBroken(xDir, zDir, a, b, c, aBaseMetaTileEntity, tTileEntity, casingBlock, casingMeta); + } else {// inside air + return !aBaseMetaTileEntity.getAirOffset(xDir + a, b, zDir + c); + } + } + + private boolean checkOuterBroken(int xDir, + int zDir, + int a, + int b, + int c, + IGregTechTileEntity aBaseMetaTileEntity, + IGregTechTileEntity tTileEntity, + Block casingBlock, + int casingMeta) { + if (b == 0) {// outer floor (controller, output, energy, maintainance, rest ulv casings) + if (checkOuterFloorLoopControl(xDir, zDir, a, c, tTileEntity)) + return false; + } + // outer above floor (ulv casings) + if (aBaseMetaTileEntity.getBlockOffset(xDir + a, b, zDir + c) != casingBlock) { + return true; + } + return aBaseMetaTileEntity.getMetaIDOffset(xDir + a, b, zDir + c) != casingMeta; + } + + private boolean checkOuterFloorLoopControl(int xDir, + int zDir, + int a, + int c, + IGregTechTileEntity tTileEntity + ) { + if (addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) { + return true; + } + if (addOutputToMachineList(tTileEntity, CASING_INDEX)) { + return true; + } + + if (addEnergyInputToMachineList(tTileEntity, CASING_INDEX)) { + return true; + } + + return (xDir + a == 0) && (zDir + c == 0); + } + + private boolean checkInnerCeilingBroken(int xDir, + int zDir, + int a, + int b, + int c, + IGregTechTileEntity aBaseMetaTileEntity, + IGregTechTileEntity tTileEntity, + Block casingBlock, + int casingMeta) { + if ((addInputToMachineList(tTileEntity, CASING_INDEX)) || (addMufflerToMachineList(tTileEntity, CASING_INDEX))) { + return false; + } + if (aBaseMetaTileEntity.getBlockOffset(xDir + a, b, zDir + c) != casingBlock) { + return true; + } + return aBaseMetaTileEntity.getMetaIDOffset(xDir + a, b, zDir + c) != casingMeta; + } + + private boolean areCoilsBroken(int xDir, + int zDir, + int a, + int b, + int c, + IGregTechTileEntity aBaseMetaTileEntity, + MutableBoolean firstCoil + ) { + Block coil = aBaseMetaTileEntity.getBlockOffset(xDir + a, b, zDir + c); + + if (!(coil instanceof IHeatingCoil)) + return true; + + int metaID = aBaseMetaTileEntity.getMetaIDOffset(xDir + a, b, zDir + c); + + HeatingCoilLevel coilHeat = ((IHeatingCoil) coil).getCoilHeat(metaID); + + if (coilHeat == HeatingCoilLevel.None) { + return true; + } else { + if (firstCoil.isTrue()) { + this.coilHeat = coilHeat; + firstCoil.setFalse(); + } else return coilHeat != this.coilHeat; + } + return false; + } + @Override public boolean isCorrectMachinePart(ItemStack aStack) { return true; @@ -288,8 +322,7 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock for (int xPos = tX - 1; xPos <= tX + 1; xPos++) { for (int zPos = tZ - 1; zPos <= tZ + 1; zPos++) { if (aBaseMetaTileEntity.getBlock(xPos, tY, zPos) == GregTech_API.sBlockCasings1 && - aBaseMetaTileEntity.getMetaID(xPos, tY, zPos) == 13) - { + aBaseMetaTileEntity.getMetaID(xPos, tY, zPos) == 13) { aBaseMetaTileEntity.getWorld().setBlock(xPos, tY, zPos, GregTech_API.sBlockCasings5, 1, 3); } } -- cgit From cd7ace3400372d5945f6c58f5e63d54f5c05d2e6 Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Mon, 28 Dec 2020 17:35:28 +0100 Subject: Added missing @Override Annotations --- .../multi/GT_MetaTileEntity_AbstractMultiFurnace.java | 6 ++++++ .../multi/GT_MetaTileEntity_ElectricBlastFurnace.java | 11 +++++++++++ .../machines/multi/GT_MetaTileEntity_MultiFurnace.java | 10 +++++++++- .../machines/multi/GT_MetaTileEntity_OilCracker.java | 4 ++++ .../machines/multi/GT_MetaTileEntity_PyrolyseOven.java | 4 ++++ 5 files changed, 34 insertions(+), 1 deletion(-) (limited to 'src/main/java/gregtech/common/tileentities') 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 index e629f78d1d..d756c59b0d 100644 --- 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 @@ -20,10 +20,12 @@ public abstract class GT_MetaTileEntity_AbstractMultiFurnace extends GT_MetaTile super(aName); } + @Override public boolean isCorrectMachinePart(ItemStack aStack) { return true; } + @Override public boolean isFacingValid(byte aFacing) { return aFacing > 1; } @@ -74,18 +76,22 @@ public abstract class GT_MetaTileEntity_AbstractMultiFurnace extends GT_MetaTile 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 33d071dc6f..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 @@ -46,10 +46,12 @@ 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") @@ -82,6 +84,7 @@ public class GT_MetaTileEntity_ElectricBlastFurnace } } + @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][CASING_INDEX], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE)}; @@ -89,22 +92,27 @@ public class GT_MetaTileEntity_ElectricBlastFurnace 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) { ItemStack[] tInputs = getCompactedInputs(); FluidStack[] tFluids = getCompactedFluids(); @@ -226,6 +234,7 @@ public class GT_MetaTileEntity_ElectricBlastFurnace return true; } + @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); @@ -239,6 +248,7 @@ public class GT_MetaTileEntity_ElectricBlastFurnace return aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 3, zDir + j) == CASING_INDEX; } + @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)) @@ -263,6 +273,7 @@ public class GT_MetaTileEntity_ElectricBlastFurnace return heatingCap == coilHeatLow && heatingCap == coilHeatHi; } + @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { return this.checkMachineFunction(aBaseMetaTileEntity, aStack); } 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 dae1816801..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 @@ -42,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") @@ -69,20 +71,24 @@ public class GT_MetaTileEntity_MultiFurnace 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][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; } + @Override public boolean checkRecipe(ItemStack aStack) { ArrayList tInputList = getStoredInputs(); if (tInputList.isEmpty()) @@ -159,6 +165,7 @@ public class GT_MetaTileEntity_MultiFurnace return true; } + @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); @@ -174,6 +181,7 @@ public class GT_MetaTileEntity_MultiFurnace return heatingLevelM == heatingCap; } + @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); @@ -183,7 +191,7 @@ public class GT_MetaTileEntity_MultiFurnace return aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j) == CASING_INDEX; } - + @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack){ return this.checkMachineFunction(aBaseMetaTileEntity,aStack); } 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 67d696438d..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 @@ -42,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") @@ -67,12 +68,14 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa 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][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"); } @@ -278,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); } 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 96c661e283..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 @@ -39,6 +39,7 @@ 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") @@ -68,6 +69,7 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock } } + @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)}; @@ -75,6 +77,7 @@ 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"); } @@ -309,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); } -- cgit From 7ffffe073b4b6d5695661dcd52a2e0844c6856bb Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Mon, 28 Dec 2020 17:38:24 +0100 Subject: Removed some code smell --- src/main/java/gregtech/common/blocks/GT_Item_Casings5.java | 6 +++--- .../machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/main/java/gregtech/common/tileentities') 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 1b8f2abdd1..a2286d81eb 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings5.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings5.java @@ -16,9 +16,9 @@ public class GT_Item_Casings5 super(par1); } - protected final static String mCoilHeatTooltip = GT_LanguageManager.addStringLocalization("gt.coilheattooltip", "Base Heating Capacity = "); - protected final static String mCoilUnitTooltip = GT_LanguageManager.addStringLocalization("gt.coilunittooltip", " Kelvin"); - protected final static String mCoilTierTooltip = GT_LanguageManager.addStringLocalization("gt.coiltiertooltip", "Coil Tier = "); + 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) 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 index d756c59b0d..1ac4df6d73 100644 --- 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 @@ -12,11 +12,11 @@ public abstract class GT_MetaTileEntity_AbstractMultiFurnace extends GT_MetaTile private static final int CASING_INDEX = 11; - public GT_MetaTileEntity_AbstractMultiFurnace(int aID, String aName, String aNameRegional) { + protected GT_MetaTileEntity_AbstractMultiFurnace(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } - public GT_MetaTileEntity_AbstractMultiFurnace(String aName) { + protected GT_MetaTileEntity_AbstractMultiFurnace(String aName) { super(aName); } -- cgit From e95b871625d4c7471da57c3eb5c0890944b2e947 Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Tue, 29 Dec 2020 12:42:06 +0100 Subject: Added wrong boni to Oil Cracker This commit synches the Oil Cracker with the Advanced Structure Check version --- .../tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/main/java/gregtech/common/tileentities') 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 302a76b7b7..d0c3f1f8a0 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 @@ -55,8 +55,7 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa .addController("Front center") .addCasingInfo("Clean Stainless Steel Machine Casing", 18) .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.") + .addInfo("Gets 5% energy cost reduction per coil tier") .addEnergyHatch("Any casing") .addMaintenanceHatch("Any casing") .addInputHatch("Steam/Hydrogen, Any middle ring casing") @@ -108,11 +107,11 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa this.mMaxProgresstime /= 2; } + this.mEUt *= Math.pow(0.95D, this.heatLevel.getTier()); + if (this.mEUt > 0) this.mEUt = (-this.mEUt); - this.mMaxProgresstime = Math.max(mMaxProgresstime / heatLevel.getTier(), 1); - this.mOutputFluids = new FluidStack[]{tRecipe.getFluidOutput(0)}; return true; } -- cgit From c3defc0dd1bc4a6cf3ab3fddcb44f969a85934ec Mon Sep 17 00:00:00 2001 From: Glease <4586901+glease@users.noreply.github.com> Date: Tue, 29 Dec 2020 20:46:28 +0800 Subject: Remove all energy cost of moving fluid and items Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java | 3 +-- .../api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java | 2 -- src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java | 1 - .../tileentities/automation/GT_MetaTileEntity_ItemDistributor.java | 1 - .../common/tileentities/automation/GT_MetaTileEntity_Regulator.java | 1 - 5 files changed, 1 insertion(+), 7 deletions(-) (limited to 'src/main/java/gregtech/common/tileentities') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java index 2c632c596b..497e42b9aa 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java @@ -516,8 +516,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B if (tMaxStacks > mOutputItems.length) tMaxStacks = mOutputItems.length; - int tCost = moveMultipleItemStacks(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1,tMaxStacks); - aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCost, true); + moveMultipleItemStacks(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1,tMaxStacks); // for (int i = 0, tCosts = 1; i < mOutputItems.length && tCosts > 0 && aBaseMetaTileEntity.isUniversalEnergyStored(128); i++) { // tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); // if (tCosts > 0) aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCosts, true); diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java index 8758ea1a02..981072070b 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java @@ -261,7 +261,6 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM if (mInventory[i] == null) { for(byte b = 0;b<6;b++) aBaseMetaTileEntity.setInternalOutputRedstoneSignal(b,bInvert ? (byte)15 : (byte)0); - aBaseMetaTileEntity.decreaseStoredEnergyUnits(1, true); break; } } @@ -284,7 +283,6 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM if (tCost > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) { mSuccess = 50; - aBaseMetaTileEntity.decreaseStoredEnergyUnits(Math.abs(tCost), true); } } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java b/src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java index 39c87669f1..d62e7c67f7 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java @@ -52,7 +52,6 @@ public class GT_Cover_FluidRegulator extends GT_CoverBehavior { if (tLiquid.amount > 0) { if (aTileEntity.getUniversalEnergyCapacity() >= Math.min(1, tLiquid.amount / 10)) { if (aTileEntity.isUniversalEnergyStored(Math.min(1, tLiquid.amount / 10))) { - aTileEntity.decreaseStoredEnergyUnits(Math.min(1, tLiquid.amount / 10), true); tTank2.fill(directionTo, tTank1.drain(directionFrom, tLiquid.amount, true), true); } } else { diff --git a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java index 5fa3bc8c82..37d8585310 100644 --- a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java +++ b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java @@ -143,7 +143,6 @@ public class GT_MetaTileEntity_ItemDistributor extends GT_MetaTileEntity_Buffer } if (movedItems > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) { mSuccess = 50; - aBaseMetaTileEntity.decreaseStoredEnergyUnits(Math.abs(movedItems), true); } fillStacksIntoFirstSlots(); } diff --git a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_Regulator.java b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_Regulator.java index b5a33bfb81..746e182066 100644 --- a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_Regulator.java +++ b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_Regulator.java @@ -95,7 +95,6 @@ public class GT_MetaTileEntity_Regulator tCosts = GT_Utility.moveOneItemStackIntoSlot(getBaseMetaTileEntity(), getBaseMetaTileEntity().getTileEntityAtSide(getBaseMetaTileEntity().getBackFacing()), getBaseMetaTileEntity().getBackFacing(), this.mTargetSlots[i], Arrays.asList(new ItemStack[]{this.mInventory[(i + 9)]}), false, (byte) this.mInventory[(i + 9)].stackSize, (byte) this.mInventory[(i + 9)].stackSize, (byte) 64, (byte) 1) * 3; if (tCosts > 0) { this.mSuccess = 50; - getBaseMetaTileEntity().decreaseStoredEnergyUnits(tCosts, true); break; } } -- cgit From 2db36cb988b58ace9d91d6f7b636a6059507c873 Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Mon, 21 Sep 2020 23:08:22 +0200 Subject: Disassembler rework Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> --- .../java/gregtech/api/util/GT_Shaped_Recipe.java | 63 +++- .../gregtech/api/util/GT_Shapeless_Recipe.java | 52 ++- .../basic/GT_MetaTileEntity_Disassembler.java | 419 +++++++++++++++++---- 3 files changed, 436 insertions(+), 98 deletions(-) (limited to 'src/main/java/gregtech/common/tileentities') diff --git a/src/main/java/gregtech/api/util/GT_Shaped_Recipe.java b/src/main/java/gregtech/api/util/GT_Shaped_Recipe.java index e51c490519..ea4182a16e 100644 --- a/src/main/java/gregtech/api/util/GT_Shaped_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Shaped_Recipe.java @@ -1,17 +1,20 @@ package gregtech.api.util; import gregtech.api.interfaces.internal.IGT_CraftingRecipe; -import gregtech.api.items.GT_MetaGenerated_Tool; +import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.oredict.ShapedOreRecipe; +import java.util.List; + public class GT_Shaped_Recipe extends ShapedOreRecipe implements IGT_CraftingRecipe { - public final boolean mDismantleable, mRemovableByGT, mKeepingNBT; + public final boolean /*mDismantleable,*/ mRemovableByGT, mKeepingNBT; private final Enchantment[] mEnchantmentsAdded; private final int[] mEnchantmentLevelsAdded; @@ -21,7 +24,31 @@ public class GT_Shaped_Recipe extends ShapedOreRecipe implements IGT_CraftingRec mEnchantmentLevelsAdded = aEnchantmentLevelsAdded; mRemovableByGT = aRemovableByGT; mKeepingNBT = aKeepingNBT; - mDismantleable = aDismantleAble; +// mDismantleable = aDismantleAble; + if (aDismantleAble){ + for (Object o : aRecipe) { + String toPrint = null; + if (o instanceof String) { + toPrint = (String) o; + toPrint += " String"; + } else if (o instanceof ItemStack) { + toPrint = GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName((ItemStack) o)); + toPrint += " ItemStack"; + } else if (o instanceof List) { + toPrint = String.join(", ", ((List) o)); + toPrint += " List"; + } else if (o instanceof Item) { + toPrint = GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(new ItemStack((Item) o))); + toPrint += " Item"; + } else if (o instanceof Block) { + toPrint = GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(new ItemStack((Block) o))); + toPrint += " Block"; + } + if (toPrint != null) + System.out.println(toPrint); + } + } + //TODO: Register Dissassembler "Recipe" } @Override @@ -66,21 +93,21 @@ public class GT_Shaped_Recipe extends ShapedOreRecipe implements IGT_CraftingRec } // Saving Ingredients inside the Item. - if (mDismantleable) { - NBTTagCompound rNBT = rStack.getTagCompound(), tNBT = new NBTTagCompound(); - if (rNBT == null) rNBT = new NBTTagCompound(); - for (int i = 0; i < 9; i++) { - ItemStack tStack = aGrid.getStackInSlot(i); - if (tStack != null && GT_Utility.getContainerItem(tStack, true) == null && !(tStack.getItem() instanceof GT_MetaGenerated_Tool)) { - tStack = GT_Utility.copyAmount(1, tStack); - if(GT_Utility.isStackValid(tStack)){ - GT_ModHandler.dischargeElectricItem(tStack, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false, true); - tNBT.setTag("Ingredient." + i, tStack.writeToNBT(new NBTTagCompound()));} - } - } - rNBT.setTag("GT.CraftingComponents", tNBT); - rStack.setTagCompound(rNBT); - } +// if (mDismantleable) { +// NBTTagCompound rNBT = rStack.getTagCompound(), tNBT = new NBTTagCompound(); +// if (rNBT == null) rNBT = new NBTTagCompound(); +// for (int i = 0; i < 9; i++) { +// ItemStack tStack = aGrid.getStackInSlot(i); +// if (tStack != null && GT_Utility.getContainerItem(tStack, true) == null && !(tStack.getItem() instanceof GT_MetaGenerated_Tool)) { +// tStack = GT_Utility.copyAmount(1, tStack); +// if(GT_Utility.isStackValid(tStack)){ +// GT_ModHandler.dischargeElectricItem(tStack, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false, true); +// tNBT.setTag("Ingredient." + i, tStack.writeToNBT(new NBTTagCompound()));} +// } +// } +// rNBT.setTag("GT.CraftingComponents", tNBT); +// rStack.setTagCompound(rNBT); +// } // Add Enchantments for (int i = 0; i < mEnchantmentsAdded.length; i++) diff --git a/src/main/java/gregtech/api/util/GT_Shapeless_Recipe.java b/src/main/java/gregtech/api/util/GT_Shapeless_Recipe.java index 937ba0a837..42141f6780 100644 --- a/src/main/java/gregtech/api/util/GT_Shapeless_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Shapeless_Recipe.java @@ -1,17 +1,20 @@ package gregtech.api.util; import gregtech.api.interfaces.internal.IGT_CraftingRecipe; -import gregtech.api.items.GT_MetaGenerated_Tool; +import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.oredict.ShapelessOreRecipe; +import java.util.List; + public class GT_Shapeless_Recipe extends ShapelessOreRecipe implements IGT_CraftingRecipe { - public final boolean mDismantleable, mRemovableByGT, mKeepingNBT; + public final boolean /*mDismantleable,*/ mRemovableByGT, mKeepingNBT; private final Enchantment[] mEnchantmentsAdded; private final int[] mEnchantmentLevelsAdded; @@ -21,7 +24,22 @@ public class GT_Shapeless_Recipe extends ShapelessOreRecipe implements IGT_Craft mEnchantmentLevelsAdded = aEnchantmentLevelsAdded; mRemovableByGT = aRemovableByGT; mKeepingNBT = aKeepingNBT; - mDismantleable = aDismantleAble; +// mDismantleable = aDismantleAble; + if (aDismantleAble){ + for (Object o : aRecipe) { + String toPrint = o.toString(); + if (o instanceof ItemStack) + toPrint = GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName((ItemStack)o)); + else if (o instanceof List) + toPrint = String.join(", ", ((List) o)); + else if (o instanceof Item) + toPrint = GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(new ItemStack((Item)o))); + else if (o instanceof Block) + toPrint = GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(new ItemStack((Block)o))); + System.out.println(toPrint); + } + } + //TODO: Register Dissassembler "Recipe" } @Override @@ -66,20 +84,20 @@ public class GT_Shapeless_Recipe extends ShapelessOreRecipe implements IGT_Craft } // Saving Ingredients inside the Item. - if (mDismantleable) { - NBTTagCompound rNBT = rStack.getTagCompound(), tNBT = new NBTTagCompound(); - if (rNBT == null) rNBT = new NBTTagCompound(); - for (int i = 0; i < 9; i++) { - ItemStack tStack = aGrid.getStackInSlot(i); - if (tStack != null && GT_Utility.getContainerItem(tStack, true) == null && !(tStack.getItem() instanceof GT_MetaGenerated_Tool)) { - tStack = GT_Utility.copyAmount(1, tStack); - GT_ModHandler.dischargeElectricItem(tStack, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false, true); - tNBT.setTag("Ingredient." + i, tStack.writeToNBT(new NBTTagCompound())); - } - } - rNBT.setTag("GT.CraftingComponents", tNBT); - rStack.setTagCompound(rNBT); - } +// if (mDismantleable) { +// NBTTagCompound rNBT = rStack.getTagCompound(), tNBT = new NBTTagCompound(); +// if (rNBT == null) rNBT = new NBTTagCompound(); +// for (int i = 0; i < 9; i++) { +// ItemStack tStack = aGrid.getStackInSlot(i); +// if (tStack != null && GT_Utility.getContainerItem(tStack, true) == null && !(tStack.getItem() instanceof GT_MetaGenerated_Tool)) { +// tStack = GT_Utility.copyAmount(1, tStack); +// GT_ModHandler.dischargeElectricItem(tStack, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false, true); +// tNBT.setTag("Ingredient." + i, tStack.writeToNBT(new NBTTagCompound())); +// } +// } +// rNBT.setTag("GT.CraftingComponents", tNBT); +// rStack.setTagCompound(rNBT); +// } // Add Enchantments for (int i = 0; i < mEnchantmentsAdded.length; i++) diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java index ce1812a9cf..4589940a14 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java @@ -1,15 +1,34 @@ package gregtech.common.tileentities.machines.basic; -import gregtech.api.enums.GT_Values; +import com.google.common.collect.ArrayListMultimap; +import gregtech.api.GregTech_API; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; +import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.objects.ItemData; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.oredict.OreDictionary; + +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; +import java.util.stream.IntStream; public class GT_MetaTileEntity_Disassembler extends GT_MetaTileEntity_BasicMachine { @@ -29,79 +48,353 @@ public class GT_MetaTileEntity_Disassembler return new GT_MetaTileEntity_Disassembler(this.mName, this.mTier, this.mDescriptionArray, this.mTextures, this.mGUIName, this.mNEIName); } + private static final ItemStack[][] alwaysReplace = new ItemStack[][]{ + { + //ItemStack to look for + new ItemStack(Blocks.trapped_chest, 1, OreDictionary.WILDCARD_VALUE) + }, + { + //ItemStack to replace + new ItemStack(Blocks.chest) + } + }; + + private static final Object[][] OreDictionaryOverride = new Object[][]{ + { + //String to look for + "plankWood", + "stoneCobble", + "gemDiamond", + "logWood", + "stickWood", + "treeSapling" + }, + { + //ItemStack to replace + new ItemStack(Blocks.planks), + new ItemStack(Blocks.cobblestone), + new ItemStack(Items.diamond), + new ItemStack(Blocks.log), + new ItemStack(Items.stick), + new ItemStack(Blocks.sapling) + } + }; + + public static ArrayListMultimap getOutputHardOverrides() { + return outputHardOverrides; + } + + private static final ArrayListMultimap outputHardOverrides; + + static { + outputHardOverrides = ArrayListMultimap.create(); + outputHardOverrides.put(new GT_ItemStack(new ItemStack(Blocks.torch,6)), new ItemStack(Items.stick)); + } + public int checkRecipe() { - //if ((getInputAt(0) != null) && (isOutputEmpty())) { - // if(GT_Utility.areStacksEqual(getInputAt(0), new ItemStack(Items.egg))){ - // getInputAt(0).stackSize -= 1; - // this.mEUt = (16 * (1 << this.mTier - 1) * (1 << this.mTier - 1)); - // this.mMaxProgresstime = 2400; - // this.mMaxProgresstime = this.mMaxProgresstime >> (mTier); - //if (getBaseMetaTileEntity().getRandomNumber(100) < (this.mTier+1)) { - // this.mOutputItems[0] = ItemList.Circuit_Chip_Stemcell.get(1, new Object[0]); - //} - //return 2; - //} - NBTTagCompound tNBT = getInputAt(0).getTagCompound(); - if (tNBT != null) { - tNBT = tNBT.getCompoundTag("GT.CraftingComponents"); - if (tNBT != null) { - boolean isAnyOutput=false; - calculateOverclockedNessDisassembler(16); - this.mMaxProgresstime = 80; - //In case recipe is too OP for that machine - if (mEUt == Integer.MAX_VALUE - 1)//&& mMaxProgresstime==Integer.MAX_VALUE-1 - return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; - for (int i = 0; i < this.mOutputItems.length; i++) { - if (getBaseMetaTileEntity().getRandomNumber(100) < 50 + 10 * this.mTier) { - this.mOutputItems[i] = GT_Utility.loadItem(tNBT, "Ingredient." + i); - if (this.mOutputItems[i] != null) { - this.mMaxProgresstime *= 1.7F; - isAnyOutput=true; - } - } - } - if(!isAnyOutput) - return DID_NOT_FIND_RECIPE; - for(int i=mTier-5;i>0;i--){ - this.mMaxProgresstime>>=1; - if(this.mMaxProgresstime==0) - this.mEUt = this.mEUt>>1; - } - if(this.mEUt==0) - mEUt = 1; - if(this.mMaxProgresstime==0) - this.mMaxProgresstime = 1; - getInputAt(0).stackSize -= 1; - return FOUND_AND_SUCCESSFULLY_USED_RECIPE; - } + ItemStack is = getInputAt(0); + if (GT_Utility.isStackInvalid(is)) + return DID_NOT_FIND_RECIPE; + if (is.getItem() instanceof GT_MetaGenerated_Tool) + return DID_NOT_FIND_RECIPE; + ItemStack comp = new ItemStack(GregTech_API.sBlockMachines); + if (is.getItem() == comp.getItem()) { + IMetaTileEntity iMetaTileEntity = GregTech_API.METATILEENTITIES[is.getItemDamage()]; + if (iMetaTileEntity instanceof GT_MetaTileEntity_TieredMachineBlock && + ((GT_MetaTileEntity_TieredMachineBlock) iMetaTileEntity).mTier > this.mTier) + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + } + Set stacks = outputHardOverrides.keySet(); + for (GT_ItemStack stack : stacks) { + ItemStack in = is.copy(); + in.stackSize = 1; + if (stack.isStackEqual(in) && stack.mStackSize <= is.stackSize) { + return setOutputsAndTime(outputHardOverrides.get(stack).toArray(new ItemStack[0]), stack.mStackSize) + ? FOUND_AND_SUCCESSFULLY_USED_RECIPE + : DID_NOT_FIND_RECIPE; } + } + return process() + ? FOUND_AND_SUCCESSFULLY_USED_RECIPE + : DID_NOT_FIND_RECIPE; + } + + private boolean process(){ + Collection recipes = this.findRecipeFromMachine(); + if (recipes.isEmpty()) + return false; + + DissassembleReference recipe = ensureDowncasting(recipes); - return DID_NOT_FIND_RECIPE; + for (int i = 0; i < recipe.inputs.length; i++) + if (GT_Utility.isStackInvalid(recipe.inputs[i]) || recipe.inputs[i].stackSize < 1) + recipe.inputs[i] = null; + + recipe.inputs = GT_Utility.getArrayListWithoutNulls(recipe.inputs).toArray(new ItemStack[0]); + return setOutputsAndTime(recipe.inputs, recipe.stackSize); + } + + private boolean setOutputsAndTime(ItemStack[] inputs, int stackSize){ + if (this.getInputAt(0).stackSize >= stackSize) + this.getInputAt(0).stackSize -= stackSize; + else + return false; + + System.arraycopy(inputs, 0, this.mOutputItems, 0, inputs.length); + this.calculateOverclockedNess(30,600); + + return true; } - private void calculateOverclockedNessDisassembler(int aEUt) { - if(mTier==0){ - mEUt=aEUt>>2; - }else{ - //Long EUt calculation - long xEUt=aEUt; - //Isnt too low EUt check? - long tempEUt = xEUt recipes) { + ItemStack[] inputs = recipes.stream() + .findFirst() + .orElseThrow(NullPointerException::new) + .inputs; + + ItemStack[] output = new ItemStack[inputs.length]; + List recipesColl = null; + if (recipes.size() > 1) + recipesColl = recipes.stream() + .skip(1) + .map(x -> x.recipe) + .collect(Collectors.toList()); + + handleRecipeTranceformation(inputs, output, recipesColl); + + return new DissassembleReference(recipes.stream().mapToInt(x -> x.stackSize).min().orElseThrow(NumberFormatException::new), output, null); + } - while (tempEUt <= GT_Values.V[mTier -1] * (long)mAmperage) { - tempEUt<<=2;//this actually controls overclocking - xEUt<<=2;//this is effect of overclocking + private static void handleRecipeTranceformation(ItemStack[] inputs, ItemStack[] output, List recipesColl) { + for (int i = 0, inputsLength = inputs.length; i < inputsLength; i++) { + Set inputsStacks = null; + if (recipesColl != null) + inputsStacks = recipesColl.stream() + .map(x -> x.mInputs) + .collect(Collectors.toSet()); + ItemStack input = inputs[i]; + ItemData data = GT_OreDictUnificator.getItemData(input); + if (data == null || data.mMaterial == null || data.mMaterial.mMaterial == null || data.mPrefix == null) { + output[i] = input; + continue; } - if(xEUt>Integer.MAX_VALUE-1){ - mEUt = Integer.MAX_VALUE-1; - }else{ - mEUt = (int)xEUt; + handleReplacement(inputsStacks, data, output, input, i); + } + addOthersAndHandleAlwaysReplace(inputs, output); + } + + private static void addOthersAndHandleAlwaysReplace(ItemStack[] inputs, ItemStack[] output){ + for (int i = 0; i < inputs.length; i++) { + //Adds rest of Items + if (output[i] == null) + output[i] = inputs[i]; + + //Math.min the recipe output if Items are the same + if (GT_Utility.areStacksEqual(output[i], inputs[i])) + output[i].stackSize = Math.min(output[i].stackSize, inputs[i].stackSize); + + //Handles replacement Overrides + ItemStack[] itemStacks = GT_MetaTileEntity_Disassembler.alwaysReplace[0]; + for (int j = 0; j < itemStacks.length; j++) { + ItemStack x = itemStacks[j]; + if (GT_Utility.areStacksEqual(x, output[i], true)) { + output[i] = GT_MetaTileEntity_Disassembler.alwaysReplace[1][j]; + break; + } } + + //Unification + output[i] = handleUnification(output[i]); } } + private static ItemStack handleUnification(ItemStack stack) { + for (int oreID : OreDictionary.getOreIDs(stack)) { + for (int i = 0; i < OreDictionaryOverride[0].length; i++) + if (OreDictionary.getOreName(oreID).equals(OreDictionaryOverride[0][i])){ + ItemStack ret = ((ItemStack) OreDictionaryOverride[1][i]).copy(); + ret.stackSize = stack.stackSize; + return ret; + } + } + return GT_OreDictUnificator.get(stack); + } + + private static void handleReplacement(Set inputsStacks, ItemData data, ItemStack[] output, ItemStack input, int i){ + AtomicReference toRpl = new AtomicReference<>(); + Materials first = data.mMaterial.mMaterial; + if (inputsStacks != null) { + handleInputStacks(inputsStacks, toRpl, data, first, i); + } + if (toRpl.get() == null) { + //Remove Magnetic and Annealed Modifiers + handleBetterMaterialsVersions(data, toRpl); + } + if (toRpl.get() != null) { + output[i] = GT_OreDictUnificator.get(data.mPrefix, toRpl.get(), input.stackSize); + return; + } + if (data.mPrefix == OrePrefixes.circuit) { + handleCircuits(first, output, input, i); + } + } + + private static void handleInputStacks(Set inputsStacks, AtomicReference toRpl, ItemData data, Materials first, int i){ + final int finalIndex = i; + inputsStacks.forEach(stackArray -> { + ItemData dataAgainst = GT_OreDictUnificator.getItemData(stackArray[finalIndex]); + if ( + dataAgainst == null || + dataAgainst.mMaterial == null || + dataAgainst.mMaterial.mMaterial == null || + dataAgainst.mPrefix == null || + dataAgainst.mPrefix != data.mPrefix + ) { + return; + } + handleDifferentMaterialsOnRecipes(first, dataAgainst.mMaterial.mMaterial, toRpl); + handleAnyMaterials(first,toRpl); + }); + } + + private static void handleAnyMaterials(Materials first, AtomicReference toRpl){ + if (first.mOreReRegistrations.stream().anyMatch(y -> y.equals(Materials.AnyIron))) + toRpl.set(Materials.Iron); + else if (first.mOreReRegistrations.stream().anyMatch(y -> y.equals(Materials.AnyCopper))) + toRpl.set(Materials.Copper); + else if (first.mOreReRegistrations.stream().anyMatch(y -> y.equals(Materials.AnyRubber))) + toRpl.set(Materials.Rubber); + else if (first.mOreReRegistrations.stream().anyMatch(y -> y.equals(Materials.AnyBronze))) + toRpl.set(Materials.Bronze); + else if (first.mOreReRegistrations.stream().anyMatch(y -> y.equals(Materials.AnySyntheticRubber))) + toRpl.set(Materials.Rubber); + } + + private static void handleDifferentMaterialsOnRecipes(Materials first, Materials second, AtomicReference toRpl){ + if (!first.equals(second)) + if (first.equals(Materials.Aluminium) && second.equals(Materials.Iron)) + toRpl.set(second); + else if (first.equals(Materials.Steel) && second.equals(Materials.Iron)) + toRpl.set(second); + else if (first.equals(Materials.WroughtIron) && second.equals(Materials.Iron)) + toRpl.set(second); + else if (first.equals(Materials.Aluminium) && second.equals(Materials.WroughtIron)) + toRpl.set(Materials.Iron); + else if (first.equals(Materials.Aluminium) && second.equals(Materials.Steel)) + toRpl.set(second); + else if (first.equals(Materials.Polytetrafluoroethylene) && second.equals(Materials.Plastic)) + toRpl.set(second); + else if (first.equals(Materials.Polybenzimidazole) && second.equals(Materials.Plastic)) + toRpl.set(second); + else if (first.equals(Materials.Polystyrene) && second.equals(Materials.Plastic)) + toRpl.set(second); + else if (first.equals(Materials.Silicone) && second.equals(Materials.Plastic)) + toRpl.set(second); + else if (first.equals(Materials.NetherQuartz) || first.equals(Materials.CertusQuartz) && second.equals(Materials.Quartzite)) + toRpl.set(second); + else if (first.equals(Materials.Plastic) && second.equals(Materials.Wood)) + toRpl.set(second); + else if (first.equals(Materials.Diamond) && second.equals(Materials.Glass)) + toRpl.set(second); + } + + private static void handleBetterMaterialsVersions(ItemData data, AtomicReference toRpl){ + if (Materials.SteelMagnetic.equals(data.mMaterial.mMaterial)) { + toRpl.set(Materials.Steel); + } else if (Materials.IronMagnetic.equals(data.mMaterial.mMaterial)) { + toRpl.set(Materials.Iron); + } else if (Materials.NeodymiumMagnetic.equals(data.mMaterial.mMaterial)) { + toRpl.set(Materials.Neodymium); + } else if (Materials.SamariumMagnetic.equals(data.mMaterial.mMaterial)) { + toRpl.set(Materials.Samarium); + } else if (Materials.AnnealedCopper.equals(data.mMaterial.mMaterial)) { + toRpl.set(Materials.Copper); + } + } + + @SuppressWarnings("deprecation") + private static void handleCircuits(Materials first, ItemStack[] output, ItemStack input, int i){ + if (first.equals(Materials.Primitive)) + output[i] = ItemList.NandChip.get(input.stackSize); + else if (first.equals(Materials.Basic)) + output[i] = ItemList.Circuit_Microprocessor.get(input.stackSize); + else if (first.equals(Materials.Good)) + output[i] = ItemList.Circuit_Good.get(input.stackSize); + else if (first.equals(Materials.Advanced)) + output[i] = ItemList.Circuit_Advanced.get(input.stackSize); + else if (first.equals(Materials.Data)) + output[i] = ItemList.Circuit_Data.get(input.stackSize); + else if (first.equals(Materials.Master)) + output[i] = ItemList.Circuit_Master.get(input.stackSize); + else if (first.equals(Materials.Ultimate)) + output[i] = ItemList.Circuit_Quantummainframe.get(input.stackSize); + else if (first.equals(Materials.Superconductor)) + output[i] = ItemList.Circuit_Crystalmainframe.get(input.stackSize); + else if (first.equals(Materials.Infinite)) + output[i] = ItemList.Circuit_Wetwaremainframe.get(input.stackSize); + else if (first.equals(Materials.Bio)) + output[i] = ItemList.Circuit_Biomainframe.get(input.stackSize); + } + + static class DissassembleReference { + final int stackSize; + ItemStack[] inputs; + final GT_Recipe recipe; + + public DissassembleReference(int stackSize, ItemStack[] inputs, GT_Recipe recipe) { + this.stackSize = stackSize; + this.inputs = inputs; + this.recipe = recipe; + } + } + + private Collection findRecipeFromMachine() { + ItemStack is = getInputAt(0); + if (GT_Utility.isStackInvalid(is)) + return Collections.emptySet(); + + AtomicInteger stacksize = new AtomicInteger(); + //Check Recipe Maps for creation of Item + List possibleRecipes = GT_Recipe.GT_Recipe_Map.sAssemblerRecipes.mRecipeList.stream() + .filter(x -> Arrays.stream(x.mOutputs) + .anyMatch(y -> + { + ItemStack out = is.copy(); + out.stackSize = y.stackSize; + boolean isDone = GT_Utility.areStacksEqual(y, out, true) && y.stackSize <= is.stackSize; + if (isDone) + stacksize.set(y.stackSize); + return isDone; + }) + ) + .map(x -> new DissassembleReference(stacksize.get(), x.mInputs, x)) + .collect(Collectors.toList()); + + //Is there only one way to create it? + if (possibleRecipes.size() == 1) + return possibleRecipes; + + //There are Multiple Ways -> Get recipe with cheapest inputs + //More Inputs should mean cheaper Materials + return possibleRecipes + .stream() + .sorted(Comparator.comparingDouble(x -> + { + double fluidInputValueRaw = Arrays.stream(x.recipe.mFluidInputs).flatMapToInt(f -> IntStream.of(f.amount)).sum(); + fluidInputValueRaw = fluidInputValueRaw > 0 ? fluidInputValueRaw : 144D; + double inputValue = Arrays.stream(x.inputs).flatMapToInt(f -> IntStream.of(f.stackSize)).sum() + + (fluidInputValueRaw / 144D); + double fluidOutputValueRaw = Arrays.stream(x.recipe.mFluidOutputs).flatMapToInt(f -> IntStream.of(f.amount)).sum(); + fluidOutputValueRaw = fluidOutputValueRaw > 0 ? fluidOutputValueRaw : 144D; + double outputValue = Arrays.stream(x.recipe.mOutputs).flatMapToInt(f -> IntStream.of(f.stackSize)).sum() + + (fluidOutputValueRaw / 144D); + return inputValue / outputValue; + } + )).collect(Collectors.toList()); + } + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { return //(aIndex == 4 && GT_Utility.areStacksEqual(aStack, new ItemStack(Items.egg))) || (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) && (aStack.getTagCompound() != null) && (aStack.getTagCompound().getCompoundTag("GT.CraftingComponents") != null); } -} +} \ No newline at end of file -- cgit From 939441f7b24e5f6abb0b5534dfea715b4be6e5ed Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Wed, 30 Dec 2020 23:30:33 +0100 Subject: Implemented ReverseRecipes --- src/main/java/gregtech/GT_Mod.java | 5 + .../gregtech/api/objects/ReverseShapedRecipe.java | 43 +++++ .../api/objects/ReverseShapelessRecipe.java | 43 +++++ src/main/java/gregtech/api/util/GT_Recipe.java | 2 +- .../java/gregtech/api/util/GT_Shaped_Recipe.java | 50 +----- .../gregtech/api/util/GT_Shapeless_Recipe.java | 20 +-- src/main/java/gregtech/api/util/GT_Utility.java | 179 +++++++++++++++++++-- .../basic/GT_MetaTileEntity_Disassembler.java | 31 +++- 8 files changed, 291 insertions(+), 82 deletions(-) create mode 100644 src/main/java/gregtech/api/objects/ReverseShapedRecipe.java create mode 100644 src/main/java/gregtech/api/objects/ReverseShapelessRecipe.java (limited to 'src/main/java/gregtech/common/tileentities') diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index b0ac434c61..fe44141324 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -32,6 +32,8 @@ import gregtech.api.enums.SubTag; import gregtech.api.enums.Textures; import gregtech.api.interfaces.internal.IGT_Mod; import gregtech.api.objects.ItemData; +import gregtech.api.objects.ReverseShapedRecipe; +import gregtech.api.objects.ReverseShapelessRecipe; import gregtech.api.objects.XSTR; import gregtech.api.threads.GT_Runnable_MachineBlockUpdate; import gregtech.api.util.GT_Assemblyline_Server; @@ -1077,6 +1079,9 @@ public class GT_Mod implements IGT_Mod { achievements = new GT_Achievements(); + ReverseShapedRecipe.runReverseRecipes(); + ReverseShapelessRecipe.runReverseRecipes(); + GT_Recipe.GTppRecipeHelper = true; GT_Log.out.println("GT_Mod: Loading finished, deallocating temporary Init Variables."); GregTech_API.sBeforeGTPreload = null; diff --git a/src/main/java/gregtech/api/objects/ReverseShapedRecipe.java b/src/main/java/gregtech/api/objects/ReverseShapedRecipe.java new file mode 100644 index 0000000000..cb9e7d4d83 --- /dev/null +++ b/src/main/java/gregtech/api/objects/ReverseShapedRecipe.java @@ -0,0 +1,43 @@ +package gregtech.api.objects; + +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_Disassembler; +import net.minecraft.item.ItemStack; + +import java.util.Collections; +import java.util.LinkedList; +import java.util.Optional; +import java.util.Queue; + +import static gregtech.api.util.GT_Recipe.GT_Recipe_Map.sDisassemblerRecipes; + +public class ReverseShapedRecipe { + private static Queue reverseRecipes = new LinkedList<>(); + private ItemStack aResult; + private Object[] aRecipe; + + public static Queue getReverseRecipes() { + return reverseRecipes; + } + + public ReverseShapedRecipe(ItemStack output, Object[] aRecipe) { + this.aResult = output; + this.aRecipe = aRecipe; + reverseRecipes.add(this); + } + + public static void runReverseRecipes() { + for (ReverseShapedRecipe x : reverseRecipes) { + Optional recipeOptional = GT_Utility.reverseShapedRecipe(x.aResult, x.aRecipe); + if (!recipeOptional.isPresent()) + continue; + GT_Recipe recipe = recipeOptional.get(); + ItemStack[] replacement = new ItemStack[recipe.mOutputs.length]; + GT_MetaTileEntity_Disassembler.handleRecipeTransformation(recipe.mOutputs, replacement, Collections.singleton(recipe.mOutputs)); + + recipe.mOutputs = replacement; + sDisassemblerRecipes.add(recipe); + } + } +} diff --git a/src/main/java/gregtech/api/objects/ReverseShapelessRecipe.java b/src/main/java/gregtech/api/objects/ReverseShapelessRecipe.java new file mode 100644 index 0000000000..1c5e27d246 --- /dev/null +++ b/src/main/java/gregtech/api/objects/ReverseShapelessRecipe.java @@ -0,0 +1,43 @@ +package gregtech.api.objects; + +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_Disassembler; +import net.minecraft.item.ItemStack; + +import java.util.Collections; +import java.util.LinkedList; +import java.util.Optional; +import java.util.Queue; + +import static gregtech.api.util.GT_Recipe.GT_Recipe_Map.sDisassemblerRecipes; + +public class ReverseShapelessRecipe { + private static Queue reverseRecipes = new LinkedList<>(); + private ItemStack aResult; + private Object[] aRecipe; + + public static Queue getReverseRecipes() { + return reverseRecipes; + } + + public ReverseShapelessRecipe(ItemStack output, Object[] aRecipe) { + this.aResult = output; + this.aRecipe = aRecipe; + reverseRecipes.add(this); + } + + public static void runReverseRecipes() { + for (ReverseShapelessRecipe x : reverseRecipes) { + Optional recipeOptional = GT_Utility.reverseShapelessRecipe(x.aResult, x.aRecipe); + if (!recipeOptional.isPresent()) + continue; + GT_Recipe recipe = recipeOptional.get(); + ItemStack[] replacement = new ItemStack[recipe.mOutputs.length]; + GT_MetaTileEntity_Disassembler.handleRecipeTransformation(recipe.mOutputs, replacement, Collections.singleton(recipe.mOutputs)); + + recipe.mOutputs = replacement; + sDisassemblerRecipes.add(recipe); + } + } +} diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 537d92b365..9756a8199a 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -561,7 +561,7 @@ public class GT_Recipe implements Comparable { public static final GT_Recipe_Map sRecyclerRecipes = new GT_Recipe_Map_Recycler(new HashSet<>(0), "ic.recipe.recycler", "Recycler", "ic2.recycler", RES_PATH_GUI + "basicmachines/Recycler", 1, 1, 1, 0, 1, E, 1, E, true, false); public static final GT_Recipe_Map sFurnaceRecipes = new GT_Recipe_Map_Furnace(new HashSet<>(0), "mc.recipe.furnace", "Furnace", "smelting", RES_PATH_GUI + "basicmachines/E_Furnace", 1, 1, 1, 0, 1, E, 1, E, true, false); public static final GT_Recipe_Map sMicrowaveRecipes = new GT_Recipe_Map_Microwave(new HashSet<>(0), "gt.recipe.microwave", "Microwave", "smelting", RES_PATH_GUI + "basicmachines/E_Furnace", 1, 1, 1, 0, 1, E, 1, E, true, false); - + public static final GT_Recipe_Map sDisassemblerRecipes = new GT_Recipe_Map(new HashSet<>(250), "gt.recipe.disassembler", "Disassembler", null, RES_PATH_GUI + "basicmachines/Disassembler", 1, 9, 1, 0, 1, E, 1, E, true, false); public static final GT_Recipe_Map sScannerFakeRecipes = new GT_Recipe_Map(new HashSet<>(300), "gt.recipe.scanner", "Scanner", null, RES_PATH_GUI + "basicmachines/Scanner", 1, 1, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sRockBreakerFakeRecipes = new GT_Recipe_Map(new HashSet<>(200), "gt.recipe.rockbreaker", "Rock Breaker", null, RES_PATH_GUI + "basicmachines/RockBreaker", 1, 1, 0, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sByProductList = new GT_Recipe_Map(new HashSet<>(1000), "gt.recipe.byproductlist", "Ore Byproduct List", null, RES_PATH_GUI + "basicmachines/Default", 1, 6, 1, 0, 1, E, 1, E, true, true); diff --git a/src/main/java/gregtech/api/util/GT_Shaped_Recipe.java b/src/main/java/gregtech/api/util/GT_Shaped_Recipe.java index ea4182a16e..f00fc7758e 100644 --- a/src/main/java/gregtech/api/util/GT_Shaped_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Shaped_Recipe.java @@ -1,20 +1,17 @@ package gregtech.api.util; import gregtech.api.interfaces.internal.IGT_CraftingRecipe; -import net.minecraft.block.Block; +import gregtech.api.objects.ReverseShapedRecipe; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.oredict.ShapedOreRecipe; -import java.util.List; - public class GT_Shaped_Recipe extends ShapedOreRecipe implements IGT_CraftingRecipe { - public final boolean /*mDismantleable,*/ mRemovableByGT, mKeepingNBT; + public final boolean mRemovableByGT, mKeepingNBT; private final Enchantment[] mEnchantmentsAdded; private final int[] mEnchantmentLevelsAdded; @@ -24,31 +21,9 @@ public class GT_Shaped_Recipe extends ShapedOreRecipe implements IGT_CraftingRec mEnchantmentLevelsAdded = aEnchantmentLevelsAdded; mRemovableByGT = aRemovableByGT; mKeepingNBT = aKeepingNBT; -// mDismantleable = aDismantleAble; - if (aDismantleAble){ - for (Object o : aRecipe) { - String toPrint = null; - if (o instanceof String) { - toPrint = (String) o; - toPrint += " String"; - } else if (o instanceof ItemStack) { - toPrint = GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName((ItemStack) o)); - toPrint += " ItemStack"; - } else if (o instanceof List) { - toPrint = String.join(", ", ((List) o)); - toPrint += " List"; - } else if (o instanceof Item) { - toPrint = GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(new ItemStack((Item) o))); - toPrint += " Item"; - } else if (o instanceof Block) { - toPrint = GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(new ItemStack((Block) o))); - toPrint += " Block"; - } - if (toPrint != null) - System.out.println(toPrint); - } + if (aDismantleAble) { + new ReverseShapedRecipe(aResult, aRecipe); } - //TODO: Register Dissassembler "Recipe" } @Override @@ -92,23 +67,6 @@ public class GT_Shaped_Recipe extends ShapedOreRecipe implements IGT_CraftingRec if (tCharge > 0) GT_ModHandler.chargeElectricItem(rStack, tCharge, Integer.MAX_VALUE, true, false); } - // Saving Ingredients inside the Item. -// if (mDismantleable) { -// NBTTagCompound rNBT = rStack.getTagCompound(), tNBT = new NBTTagCompound(); -// if (rNBT == null) rNBT = new NBTTagCompound(); -// for (int i = 0; i < 9; i++) { -// ItemStack tStack = aGrid.getStackInSlot(i); -// if (tStack != null && GT_Utility.getContainerItem(tStack, true) == null && !(tStack.getItem() instanceof GT_MetaGenerated_Tool)) { -// tStack = GT_Utility.copyAmount(1, tStack); -// if(GT_Utility.isStackValid(tStack)){ -// GT_ModHandler.dischargeElectricItem(tStack, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false, true); -// tNBT.setTag("Ingredient." + i, tStack.writeToNBT(new NBTTagCompound()));} -// } -// } -// rNBT.setTag("GT.CraftingComponents", tNBT); -// rStack.setTagCompound(rNBT); -// } - // Add Enchantments for (int i = 0; i < mEnchantmentsAdded.length; i++) GT_Utility.ItemNBT.addEnchantment(rStack, mEnchantmentsAdded[i], EnchantmentHelper.getEnchantmentLevel(mEnchantmentsAdded[i].effectId, rStack) + mEnchantmentLevelsAdded[i]); diff --git a/src/main/java/gregtech/api/util/GT_Shapeless_Recipe.java b/src/main/java/gregtech/api/util/GT_Shapeless_Recipe.java index 42141f6780..fce135dfe6 100644 --- a/src/main/java/gregtech/api/util/GT_Shapeless_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Shapeless_Recipe.java @@ -1,18 +1,15 @@ package gregtech.api.util; import gregtech.api.interfaces.internal.IGT_CraftingRecipe; -import net.minecraft.block.Block; +import gregtech.api.objects.ReverseShapelessRecipe; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.oredict.ShapelessOreRecipe; -import java.util.List; - public class GT_Shapeless_Recipe extends ShapelessOreRecipe implements IGT_CraftingRecipe { public final boolean /*mDismantleable,*/ mRemovableByGT, mKeepingNBT; private final Enchantment[] mEnchantmentsAdded; @@ -24,22 +21,9 @@ public class GT_Shapeless_Recipe extends ShapelessOreRecipe implements IGT_Craft mEnchantmentLevelsAdded = aEnchantmentLevelsAdded; mRemovableByGT = aRemovableByGT; mKeepingNBT = aKeepingNBT; -// mDismantleable = aDismantleAble; if (aDismantleAble){ - for (Object o : aRecipe) { - String toPrint = o.toString(); - if (o instanceof ItemStack) - toPrint = GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName((ItemStack)o)); - else if (o instanceof List) - toPrint = String.join(", ", ((List) o)); - else if (o instanceof Item) - toPrint = GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(new ItemStack((Item)o))); - else if (o instanceof Block) - toPrint = GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(new ItemStack((Block)o))); - System.out.println(toPrint); - } + new ReverseShapelessRecipe(aResult, aRecipe); } - //TODO: Register Dissassembler "Recipe" } @Override diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 3530fa17c2..adc0f95881 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -14,6 +14,7 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.*; import gregtech.api.items.GT_EnergyArmor_Item; import gregtech.api.items.GT_Generic_Item; +import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.net.GT_Packet_Sound; import gregtech.api.objects.GT_CopiedBlockTexture; import gregtech.api.objects.GT_ItemStack; @@ -1022,7 +1023,7 @@ public class GT_Utility { return copyMetaData(Items.feather.getDamage(aStack) + 1, aStack); return null; } - + public static synchronized boolean removeIC2BottleRecipe(ItemStack aContainer, ItemStack aInput, Map aRecipeList, ItemStack aOutput){ if ((isStackInvalid(aInput) && isStackInvalid(aOutput) && isStackInvalid(aContainer)) || aRecipeList == null) return false; boolean rReturn = false; @@ -1742,7 +1743,7 @@ public class GT_Utility { if(aDimensionID<=1 && aDimensionID>=-1 && !GregTech_API.sDimensionalList.contains(aDimensionID)) return true; return !GregTech_API.sDimensionalList.contains(aDimensionID) && DimensionManager.isDimensionRegistered(aDimensionID); } - + //public static boolean isRealDimension(int aDimensionID) { // try { // if (DimensionManager.getProvider(aDimensionID).getClass().getName().contains("com.xcompwiz.mystcraft")) @@ -1756,7 +1757,7 @@ public class GT_Utility { // } catch (Throwable e) {/*Do nothing*/} // return GregTech_API.sDimensionalList.contains(aDimensionID); //} - + public static boolean moveEntityToDimensionAtCoords(Entity entity, int aDimension, double aX, double aY, double aZ) { //Credit goes to BrandonCore Author :!: @@ -2040,7 +2041,7 @@ public class GT_Utility { if (D1) e.printStackTrace(GT_Log.err); } } - + if (aPlayer.capabilities.isCreativeMode) { FluidStack tFluid = undergroundOilReadInformation(aWorld.getChunkFromBlockCoords(aX,aZ));//-# to only read if (tFluid!=null) @@ -2355,7 +2356,7 @@ public class GT_Utility { setBookTitle(aStack, "Raw Prospection Data"); NBTTagCompound tNBT = GT_Utility.ItemNBT.getNBT(aStack); - + tNBT.setByte("prospection_tier", aTier); tNBT.setString("prospection_pos", "Dim: " + aDim + "\nX: " + aX + " Y: " + aY + " Z: " + aZ); @@ -2369,27 +2370,27 @@ public class GT_Utility { String[] aStats = aStr.split(","); tOilsTransformed.add(aStats[0] + ": " + aStats[1] + "L " + aStats[2]); } - + tNBT.setString("prospection_oils", joinListToString(tOilsTransformed)); String tOilsPosStr = "X: " + Math.floorDiv(aX, 16*8)*16*8 + " Z: " + Math.floorDiv(aZ, 16*8)*16*8 + "\n"; int xOff = aX - Math.floorDiv(aX, 16*8)*16*8; xOff = xOff/16; int xOffRemain = 7 - xOff; - + int zOff = aZ - Math.floorDiv(aZ, 16*8)*16*8; zOff = zOff/16; int zOffRemain = 7 - zOff; - + for( ; zOff > 0; zOff-- ) { tOilsPosStr = tOilsPosStr.concat("--------\n"); } for( ; xOff > 0; xOff-- ) { tOilsPosStr = tOilsPosStr.concat("-"); } - + tOilsPosStr = tOilsPosStr.concat("P"); - + for( ; xOffRemain > 0; xOffRemain-- ) { tOilsPosStr = tOilsPosStr.concat("-"); } @@ -2444,11 +2445,11 @@ public class GT_Utility { + "Location is center of orevein\n\n" + "Check NEI to confirm orevein type"; tNBTList.appendTag(new NBTTagString(tPageText)); - + if (tOres != null) fillBookWithList(tNBTList, "Ores Found %s\n\n", "\n", 7, tOres); - + if (tOils != null) fillBookWithList(tNBTList, "Oils%s\n\n", "\n", 9, tOils); @@ -2466,7 +2467,7 @@ public class GT_Utility { tOilsPosStr + "\n" + "P - Prospector in 8x8 field"; tNBTList.appendTag(new NBTTagString(tPageText)); - + tNBT.setString("author", tPos.replace("\n"," ")); tNBT.setTag("pages", tNBTList); setNBT(aStack, tNBT); @@ -2606,11 +2607,11 @@ public class GT_Utility { } public static boolean isPartOfMaterials(ItemStack aStack, Materials aMaterials){ - return GT_OreDictUnificator.getAssociation(aStack) != null ? GT_OreDictUnificator.getAssociation(aStack).mMaterial.mMaterial.equals(aMaterials) : false; + return GT_OreDictUnificator.getAssociation(aStack) != null && GT_OreDictUnificator.getAssociation(aStack).mMaterial.mMaterial.equals(aMaterials); } public static boolean isPartOfOrePrefix(ItemStack aStack, OrePrefixes aPrefix){ - return GT_OreDictUnificator.getAssociation(aStack) != null ? GT_OreDictUnificator.getAssociation(aStack).mPrefix.equals(aPrefix) : false; + return GT_OreDictUnificator.getAssociation(aStack) != null && GT_OreDictUnificator.getAssociation(aStack).mPrefix.equals(aPrefix); } public static boolean isOre(ItemStack aStack) { for (int id: OreDictionary.getOreIDs(aStack)) { @@ -2620,4 +2621,152 @@ public class GT_Utility { return false; } + public static Optional reverseShapelessRecipe(ItemStack output, Object... aRecipe) { + if (output == null) { + return Optional.empty(); + } + + List inputs = new ArrayList<>(); + + for (Object o : aRecipe) { + if (o instanceof ItemStack) { + ItemStack toAdd = ((ItemStack) o).copy(); + inputs.add(toAdd); + } else if (o instanceof String) { + ItemStack stack = GT_OreDictUnificator.get(o, 1); + if (stack == null) { + Optional oStack = OreDictionary.getOres((String) o) + .stream() + .findAny(); + if (oStack.isPresent()) { + ItemStack copy = oStack.get().copy(); + inputs.add(copy); + } + } else { + ItemStack copy = stack.copy(); + inputs.add(copy); + } + } else if (o instanceof Item) + inputs.add(new ItemStack((Item) o)); + else if (o instanceof Block) + inputs.add(new ItemStack((Block) o)); + else + throw new IllegalStateException("A Recipe contains an invalid input! Output: " + output); + } + + inputs.removeIf(x -> x.getItem() instanceof GT_MetaGenerated_Tool); + + return Optional.of( + new GT_Recipe( + false, + new ItemStack[]{output}, + inputs.toArray(new ItemStack[0]), + null, null, + null, null, + 300, 30, 0 + ) + ); + } + + + public static Optional reverseShapedRecipe(ItemStack output, Object... aRecipe) { + if (output == null) { +// System.out.println("Null Recipe detected!"); + return Optional.empty(); + } +// System.out.println("Registering Reverse Recipe for: " + GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(output) + "|" + output.getUnlocalizedName())); +// for (Object o : aRecipe) { +// String toPrint; +// if (o instanceof String) { +// toPrint = (String) o; +// toPrint += " String"; +// } else if (o instanceof ItemStack) { +// toPrint = GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName((ItemStack) o)); +// toPrint += " ItemStack"; +// } else if (o instanceof List) { +// toPrint = String.join(", ", ((List) o)); +// toPrint += " List"; +// } else if (o instanceof Item) { +// toPrint = GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(new ItemStack((Item) o))); +// toPrint += " Item"; +// } else if (o instanceof Block) { +// toPrint = GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(new ItemStack((Block) o))); +// toPrint += " Block"; +// } else if (o != null) { +// toPrint = o.toString(); +// toPrint += " Other"; +// } else { +// toPrint = "NULL"; +// } +// System.out.println(toPrint); +// } + Map recipeAsMap = new HashMap<>(); + Map ingridients = new HashMap<>(); + Map amounts = new HashMap<>(); + boolean startFound = false; + for (int i = 0, aRecipeLength = aRecipe.length; i < aRecipeLength; i++) { + Object o = aRecipe[i]; + if (!startFound) { + if (o instanceof String) { + for (Character c : ((String) o).toCharArray()) + amounts.merge(c, 1, (a, b) -> ++a); + } else if (o instanceof Character) + startFound = true; + } else if (!(o instanceof Character)) + ingridients.put((Character) aRecipe[i - 1], o); + } + for (Map.Entry characterObjectEntry : ingridients.entrySet()) { + for (Map.Entry characterIntegerEntry : amounts.entrySet()) { + if (characterObjectEntry.getKey() != characterIntegerEntry.getKey()) + continue; + recipeAsMap.put(characterObjectEntry.getValue(), characterIntegerEntry.getValue()); + } + } + List inputs = new ArrayList<>(); + + for (Map.Entry o : recipeAsMap.entrySet()) { + if (o.getKey() instanceof ItemStack) { + ItemStack toAdd = ((ItemStack) o.getKey()).copy(); + toAdd.stackSize = o.getValue(); + inputs.add(toAdd); + } else if (o.getKey() instanceof String) { +// System.out.println("Found OreDictEntry: "+o.getKey()); + ItemStack stack = GT_OreDictUnificator.get(o.getKey(), o.getValue()); + if (stack == null) { + Optional oStack = OreDictionary.getOres((String) o.getKey()) + .stream() + .findAny(); + if (oStack.isPresent()) { + ItemStack copy = oStack.get().copy(); + copy.stackSize = o.getValue(); + inputs.add(copy); + } +// else +// System.out.println("OreDict Entry "+o.getKey()+" couldn't be found!"); + } else { + ItemStack copy = stack.copy(); + copy.stackSize = o.getValue(); + inputs.add(copy); + } + } else if (o.getKey() instanceof Item) + inputs.add(new ItemStack((Item) o.getKey(), o.getValue())); + else if (o.getKey() instanceof Block) + inputs.add(new ItemStack((Block) o.getKey(), o.getValue())); + else + throw new IllegalStateException("A Recipe contains an invalid input! Output: " + output); + } + + inputs.removeIf(x -> x.getItem() instanceof GT_MetaGenerated_Tool); + + return Optional.of( + new GT_Recipe( + false, + new ItemStack[]{output}, + inputs.toArray(new ItemStack[0]), + null, null, + null, null, + 300, 30, 0 + ) + ); + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java index 4589940a14..92ed054b05 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java @@ -120,6 +120,13 @@ public class GT_MetaTileEntity_Disassembler } private boolean process(){ + + GT_Recipe gt_recipe = GT_Recipe.GT_Recipe_Map.sDisassemblerRecipes.findRecipe(this.getBaseMetaTileEntity(), true, this.mEUt, null, this.getAllInputs()); + if (gt_recipe != null) { + gt_recipe.isRecipeInputEqual(true, null, this.getRealInventory()); + return setOutputsAndTime(gt_recipe.mOutputs, gt_recipe.mInputs[0].stackSize); + } + Collection recipes = this.findRecipeFromMachine(); if (recipes.isEmpty()) return false; @@ -131,6 +138,7 @@ public class GT_MetaTileEntity_Disassembler recipe.inputs[i] = null; recipe.inputs = GT_Utility.getArrayListWithoutNulls(recipe.inputs).toArray(new ItemStack[0]); + return setOutputsAndTime(recipe.inputs, recipe.stackSize); } @@ -160,12 +168,12 @@ public class GT_MetaTileEntity_Disassembler .map(x -> x.recipe) .collect(Collectors.toList()); - handleRecipeTranceformation(inputs, output, recipesColl); + handleRecipeTransformation(inputs, output, recipesColl); return new DissassembleReference(recipes.stream().mapToInt(x -> x.stackSize).min().orElseThrow(NumberFormatException::new), output, null); } - private static void handleRecipeTranceformation(ItemStack[] inputs, ItemStack[] output, List recipesColl) { + private static void handleRecipeTransformation(ItemStack[] inputs, ItemStack[] output, List recipesColl) { for (int i = 0, inputsLength = inputs.length; i < inputsLength; i++) { Set inputsStacks = null; if (recipesColl != null) @@ -183,6 +191,25 @@ public class GT_MetaTileEntity_Disassembler addOthersAndHandleAlwaysReplace(inputs, output); } + /** + * Public Interface for ReverseRecipes, do not call inside of this class. + * @param inputs + * @param output + * @param inputsStacks + */ + public static void handleRecipeTransformation(ItemStack[] inputs, ItemStack[] output, Set inputsStacks) { + for (int i = 0, inputsLength = inputs.length; i < inputsLength; i++) { + ItemStack input = inputs[i]; + ItemData data = GT_OreDictUnificator.getItemData(input); + if (data == null || data.mMaterial == null || data.mMaterial.mMaterial == null || data.mPrefix == null) { + output[i] = input; + continue; + } + handleReplacement(inputsStacks, data, output, input, i); + } + addOthersAndHandleAlwaysReplace(inputs, output); + } + private static void addOthersAndHandleAlwaysReplace(ItemStack[] inputs, ItemStack[] output){ for (int i = 0; i < inputs.length; i++) { //Adds rest of Items -- cgit