diff options
Diffstat (limited to 'src/main/java/gregtech/common/tileentities/machines')
2 files changed, 161 insertions, 95 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java index f79891b1d9..76628572da 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java @@ -9,6 +9,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; 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_Recipe; import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; @@ -23,7 +24,8 @@ import java.util.Arrays; public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_MultiBlockBase { - private static boolean controller; + private static final int CASING_INDEX = 49; + private short controllerY; public GT_MetaTileEntity_DistillationTower(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -40,20 +42,23 @@ public class GT_MetaTileEntity_DistillationTower public String[] getDescription() { return new String[]{ "Controller Block for the Distillation Tower", - "Size(WxHxD): 3x6x3 (Hollow), Controller (Front bottom)", + "Size(WxHxD): 3xhx3 (Hollow), with h ranging from 3 to 12", + "Controller (Front bottom)", "1x Input Hatch (Any bottom layer casing)", - "5x Output Hatch (Any casing besides bottom layer)", + "2-11x Output Hatch (One per layer except bottom layer)", "1x Output Bus (Any bottom layer casing)", "1x Maintenance Hatch (Any casing)", "1x Energy Hatch (Any casing)", - "Clean Stainless Steel Machine Casings for the rest (36 at least!)"}; + "Fluids are only put out at the correct height", + "The correct height equals the slot number in the NEI recipe", + "Clean Stainless Steel Machine Casings for the rest (7 x h - 5 at least!)"}; } public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[49], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER)}; + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[CASING_INDEX], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER)}; } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[49]}; + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[CASING_INDEX]}; } public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { @@ -108,7 +113,6 @@ public class GT_MetaTileEntity_DistillationTower this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; this.mOutputFluids = tRecipe.mFluidOutputs.clone(); - ArrayUtils.reverse(mOutputFluids); updateSlots(); return true; } @@ -120,62 +124,61 @@ public class GT_MetaTileEntity_DistillationTower } public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + controllerY = aBaseMetaTileEntity.getYCoord(); int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { - return false; - } - int tAmount = 0; - controller = false; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - for (int h = 0; h < 6; h++) { - if (!(i == 0 && j == 0 && (h > 0 && h < 5)))//((h > 0)&&(h<5)) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0))) - { - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - if ((!addMaintenanceToMachineList(tTileEntity, 49)) && (!addInputToMachineList(tTileEntity, 49)) && (!addOutputToMachineList(tTileEntity, 49)) && (!addEnergyInputToMachineList(tTileEntity, 49)) && (!ignoreController(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j)))) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != GregTech_API.sBlockCasings4) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 1) { - return false; - } - tAmount++; - } - } - } - } - } - if (this.mOutputBusses.size() != 1 || this.mInputBusses.size() != 0 || this.mOutputHatches.size() != 5) { - return false; - } - int height = this.getBaseMetaTileEntity().getYCoord(); - if (this.mInputHatches.get(0).getBaseMetaTileEntity().getYCoord() != height || this.mOutputBusses.get(0).getBaseMetaTileEntity().getYCoord() != height) { - return false; - } - GT_MetaTileEntity_Hatch_Output[] tmpHatches = new GT_MetaTileEntity_Hatch_Output[5]; - int mOutputHatches_sS=this.mOutputHatches.size(); - for (int i = 0; i < mOutputHatches_sS; i++) { - int hatchNumber = this.mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord() - 1 - height; - if (tmpHatches[hatchNumber] == null) { - tmpHatches[hatchNumber] = this.mOutputHatches.get(i); - } else { - return false; - } - } - this.mOutputHatches.clear(); - for (int i = 0; i < tmpHatches.length; i++) { - this.mOutputHatches.add(tmpHatches[i]); + int y = 0; //height + int casingAmount = 0; + boolean reachedTop = false; + + for (int x = xDir - 1; x <= xDir + 1; x++) { //x=width + for (int z = zDir - 1; z <= zDir + 1; z++) { //z=depth + if (x != 0 || z != 0) { + IGregTechTileEntity tileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(x, y, z); + Block block = aBaseMetaTileEntity.getBlockOffset(x, y, z); + if (!addInputToMachineList(tileEntity, CASING_INDEX) + && !addOutputToMachineList(tileEntity, CASING_INDEX) + && !addMaintenanceToMachineList(tileEntity, CASING_INDEX) + && !addEnergyInputToMachineList(tileEntity, CASING_INDEX)) { + if (block == GregTech_API.sBlockCasings4 && aBaseMetaTileEntity.getMetaIDOffset(x, y, z) == 1) { + casingAmount++; + } else { + return false; + } + } + } + } + } + y++; + + while (y < 12 && !reachedTop) { + for (int x = xDir - 1; x <= xDir + 1; x++) { //x=width + for (int z = zDir - 1; z <= zDir + 1; z++) { //z=depth + IGregTechTileEntity tileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(x, y, z); + Block block = aBaseMetaTileEntity.getBlockOffset(x, y, z); + if (aBaseMetaTileEntity.getAirOffset(x, y, z)) { + if (x != xDir || z != zDir) { + return false; + } + } else { + if (x == xDir && z == zDir) { + reachedTop = true; + } + if (!addOutputToMachineList(tileEntity, CASING_INDEX) + && !addMaintenanceToMachineList(tileEntity, CASING_INDEX) + && !addEnergyInputToMachineList(tileEntity, CASING_INDEX)) { + if (block == GregTech_API.sBlockCasings4 && aBaseMetaTileEntity.getMetaIDOffset(x, y, z) == 1) { + casingAmount++; + } else { + return false; + } + } + } + } + } + y++; } - if(this.mMaintenanceHatches.size()!=1)return false; - return tAmount >= 36; - } - - public boolean ignoreController(Block tTileEntity) { - if (!controller && tTileEntity == GregTech_API.sBlockMachines) { - return true; - } - return false; + return casingAmount >= 7 * y - 5 && y >= 3 && y <= 12 && reachedTop; } public int getMaxEfficiency(ItemStack aStack) { @@ -194,4 +197,35 @@ public class GT_MetaTileEntity_DistillationTower public boolean explodesOnComponentBreak(ItemStack aStack) { return false; } -} + +@Override + public boolean addOutput(FluidStack aLiquid) { + if (aLiquid == null) return false; + FluidStack tLiquid = aLiquid.copy(); + for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { + if (isValidMetaTileEntity(tHatch) && GT_ModHandler.isSteam(aLiquid) ? tHatch.outputsSteam() : tHatch.outputsLiquids()) { + if (tHatch.getBaseMetaTileEntity().getYCoord() == this.controllerY + 1) { + 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; + } + + @Override + protected void addFluidOutputs(FluidStack[] mOutputFluids2) { + for (int i = 0; i < mOutputFluids2.length; i++) { + if (mOutputHatches.size() > i && mOutputHatches.get(i) != null && mOutputFluids2[i] != null && isValidMetaTileEntity(mOutputHatches.get(i))) { + if (mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord() == this.controllerY + 1 + i) { + mOutputHatches.get(i).fill(mOutputFluids2[i], true); + } + } + } + + } +}
\ No newline at end of file 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 199e419b76..0d0094e535 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,5 +1,7 @@ package gregtech.common.tileentities.machines.multi; +import java.util.ArrayList; + import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.enums.Textures; @@ -7,6 +9,7 @@ import gregtech.api.gui.GT_GUIContainer_MultiMachine; 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_Input; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; @@ -17,12 +20,9 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import java.util.ArrayList; - public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBase { - private static final FluidStack fluidToDecreaseEu = GT_ModHandler.getSteam(128); - private static final FluidStack fluidToIncreaseOutput = Materials.Hydrogen.getGas(64); - + private ForgeDirection orientation; + private int controllerX, controllerZ; public GT_MetaTileEntity_OilCracker(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -35,16 +35,15 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa public String[] getDescription() { return new String[]{ "Controller Block for the Oil Cracking Unit", - "Cracks heavy oil into lighter parts", + "Thermally cracks heavy hydrocarbons into lighter fractions", "Size(WxHxD): 5x3x3 (Hollow), Controller (Front center)", "Ring of 8 Cupronickel Coils (Each side of Controller)", - "1x Input Hatch (Any left side casing)", - "1x Input Hatch (Any middle ring casing)", - "1x Output Hatch (Any right side casing)", + "1x Hydrocarbon Input Bus/Hatch (Any left side casing)", + "1x Steam/Hydrogen Input Hatch (Any middle ring casing)", + "1x Cracked Hydrocarbon Output Hatch (Any right side casing)", "1x Maintenance Hatch (Any middle ring casing)", "1x Energy Hatch (Any middle ring casing)", - "Clean Stainless Steel Machine Casings for the rest (18 at least!)", - "Optional Steam(50% less EU/t) or Hydrogen(30% more output)"}; + "Clean Stainless Steel Machine Casings for the rest (18 at least!)"}; } public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { @@ -62,34 +61,38 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa @Override public boolean checkRecipe(ItemStack aStack) { ArrayList<FluidStack> tInputList = getStoredFluids(); - for (FluidStack tInput : tInputList) { - 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], new FluidStack[]{tInput}, new ItemStack[]{}); - if (tRecipe != null) { - if (tRecipe.isRecipeInputEqual(true, new FluidStack[]{tInput}, new ItemStack[]{})) { - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - calculateOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, 1, getMaxInputVoltage()); - //In case recipe is too OP for that machine - if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) - return false; - if (depleteInput(fluidToDecreaseEu)) this.mEUt = this.mEUt / 2; - if (this.mEUt > 0) this.mEUt = (-this.mEUt); - this.mOutputFluids = new FluidStack[]{tRecipe.getFluidOutput(0)}; - if (depleteInput(fluidToIncreaseOutput)) this.mOutputFluids[0].amount = this.mOutputFluids[0].amount * 130 / 100; - return true; - } + FluidStack[] tFluidInputs = tInputList.toArray(new FluidStack[tInputList.size()]); + 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]})) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + this.mOutputFluids = new FluidStack[]{tRecipe.getFluidOutput(0)}; + return true; } return false; } @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + 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; replaceDeprecatedCoils(aBaseMetaTileEntity); if (xDir != 0) { @@ -231,7 +234,7 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa continue; } if (aBaseMetaTileEntity.getBlock(xPos, yPos, zPos) == GregTech_API.sBlockCasings1 && - aBaseMetaTileEntity.getMetaID(xPos, yPos, zPos) == 12) + aBaseMetaTileEntity.getMetaID(xPos, yPos, zPos) == 12) { aBaseMetaTileEntity.getWorld().setBlock(xPos, yPos, zPos, GregTech_API.sBlockCasings5, 0, 3); } @@ -239,4 +242,33 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa } } } -} + + @Override + public ArrayList<FluidStack> getStoredFluids() { + ArrayList<FluidStack> rList = new ArrayList<FluidStack>(); + 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)) { + rList.add(tStack); + } + } + } + } + return rList; + } + + private boolean isHatchInMiddleRing(GT_MetaTileEntity_Hatch_Input inputHatch){ + if (orientation == ForgeDirection.NORTH || orientation == ForgeDirection.SOUTH) { + return inputHatch.getBaseMetaTileEntity().getXCoord() == this.controllerX; + } else { + return inputHatch.getBaseMetaTileEntity().getZCoord() == this.controllerZ; + } + } +}
\ No newline at end of file |