From 763e5d543ff9495f38d0930fafbf33d32e96ea1a Mon Sep 17 00:00:00 2001 From: Dimach Date: Thu, 16 Nov 2017 15:39:25 +0200 Subject: cherry pick Commit: eed72ede969a408a9668281de90ea91e13d92d9f [eed72ed] Added info to small miners tooltip. --- .../machines/basic/GT_MetaTileEntity_Miner.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/main/java/gregtech/common/tileentities') diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java index f16ad5a744..ff114ffb4c 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java @@ -31,20 +31,32 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine { int drillX, drillY, drillZ; boolean isPickingPipes; boolean waitMiningPipe; + private String[] description; final static int[] RADIUS = new int[]{8, 8, 16, 24, 32}; //Miner radius per tier final static int[] SPEED = new int[]{160, 160, 80, 40, 20}; //Miner cycle time per tier final static int[] ENERGY = new int[]{8, 8, 32, 128, 512}; //Miner energy consumption per tier public GT_MetaTileEntity_Miner(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 1, "Digging ore instead of you", 2, 2, "Miner.png", "", new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_SIDE_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_SIDE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_FRONT_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_FRONT")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_TOP_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_TOP")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_BOTTOM_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_BOTTOM"))); + super(aID, aName, aNameRegional, aTier, 1, "", 2, 2, "Miner.png", "", new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_SIDE_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_SIDE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_FRONT_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_FRONT")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_TOP_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_TOP")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_BOTTOM_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_BOTTOM"))); + description = new String[]{"Digging ore instead of you", ENERGY[mTier] + " eU/t, " + SPEED[mTier] / 20 + " sec per block", + "Work area " + (RADIUS[mTier] * 2 + 1) + "x" + (RADIUS[mTier] * 2 + 1)}; } public GT_MetaTileEntity_Miner(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); + description = new String[]{"Digging ore instead of you", ENERGY[mTier] + " eU/t, " + SPEED[mTier] / 20 + " sec per block", + "Work area " + (RADIUS[mTier] * 2 + 1) + "x" + (RADIUS[mTier] * 2 + 1)}; } public GT_MetaTileEntity_Miner(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { super(aName, aTier, 1, aDescription, aTextures, 2, 2, aGUIName, aNEIName); + description = new String[]{"Digging ore instead of you", ENERGY[mTier] + " eU/t, " + SPEED[mTier] / 20 + " sec per block", + "Work area " + (RADIUS[mTier] * 2 + 1) + "x" + (RADIUS[mTier] * 2 + 1)}; + } + + public String[] getDescription() { + return description; + } @Override -- cgit From f6d4eb5c1a75832cc354fae4b81dfaf237c56d20 Mon Sep 17 00:00:00 2001 From: Dream-MasterXXL Date: Wed, 22 Nov 2017 19:30:46 +0700 Subject: cherry pick Commit: 09978a0225bbbd1832e123c7d6df1ef7fdc09d5f [09978a0] Refined --- .../GT_MetaTileEntity_BasicMachine.java | 9 ++++++++- .../machines/basic/GT_MetaTileEntity_Miner.java | 18 ++++-------------- 2 files changed, 12 insertions(+), 15 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 07aca039af..ade5d98528 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 @@ -84,7 +84,14 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B mGUIName = aGUIName; mNEIName = aNEIName; } - + public GT_MetaTileEntity_BasicMachine(int aID, String aName, String aNameRegional, int aTier, int aAmperage, String[] aDescription, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName, ITexture... aOverlays) { + super(aID, aName, aNameRegional, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aOverlays); + mInputSlotCount = Math.max(0, aInputSlotCount); + mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; + mAmperage = aAmperage; + mGUIName = aGUIName; + mNEIName = aNEIName; + } public GT_MetaTileEntity_BasicMachine(String aName, int aTier, int aAmperage, String aDescription, ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName) { super(aName, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aTextures); mInputSlotCount = Math.max(0, aInputSlotCount); diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java index ff114ffb4c..4bd5a15af8 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java @@ -31,31 +31,21 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine { int drillX, drillY, drillZ; boolean isPickingPipes; boolean waitMiningPipe; - private String[] description; final static int[] RADIUS = new int[]{8, 8, 16, 24, 32}; //Miner radius per tier final static int[] SPEED = new int[]{160, 160, 80, 40, 20}; //Miner cycle time per tier final static int[] ENERGY = new int[]{8, 8, 32, 128, 512}; //Miner energy consumption per tier public GT_MetaTileEntity_Miner(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 1, "", 2, 2, "Miner.png", "", new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_SIDE_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_SIDE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_FRONT_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_FRONT")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_TOP_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_TOP")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_BOTTOM_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_BOTTOM"))); - description = new String[]{"Digging ore instead of you", ENERGY[mTier] + " eU/t, " + SPEED[mTier] / 20 + " sec per block", - "Work area " + (RADIUS[mTier] * 2 + 1) + "x" + (RADIUS[mTier] * 2 + 1)}; - } + super(aID, aName, aNameRegional, aTier, 1, new String[]{"Digging ore instead of you", ENERGY[aTier] + " EU/t, " + SPEED[aTier] / 20 + " sec per block", + "Work area " + (RADIUS[aTier] * 2 + 1) + "x" + (RADIUS[aTier] * 2 + 1)}, 2, 2, "Miner.png", "", new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_SIDE_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_SIDE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_FRONT_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_FRONT")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_TOP_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_TOP")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_BOTTOM_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_BOTTOM"))); +} public GT_MetaTileEntity_Miner(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); - description = new String[]{"Digging ore instead of you", ENERGY[mTier] + " eU/t, " + SPEED[mTier] / 20 + " sec per block", - "Work area " + (RADIUS[mTier] * 2 + 1) + "x" + (RADIUS[mTier] * 2 + 1)}; - } +} public GT_MetaTileEntity_Miner(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { super(aName, aTier, 1, aDescription, aTextures, 2, 2, aGUIName, aNEIName); - description = new String[]{"Digging ore instead of you", ENERGY[mTier] + " eU/t, " + SPEED[mTier] / 20 + " sec per block", - "Work area " + (RADIUS[mTier] * 2 + 1) + "x" + (RADIUS[mTier] * 2 + 1)}; - } - - public String[] getDescription() { - return description; } -- cgit From 154ed26096429658374a9a5c7786337d1cdd2a63 Mon Sep 17 00:00:00 2001 From: Jason Mitchell Date: Thu, 23 Nov 2017 16:47:49 -0800 Subject: Single block pump refactor & bugfix: 1) Pump will properly save it's state and reload with chunk load/reload. It remembers that it was pumping and doesn't immediately move down. Additionally, corrected saving of fluid type so it will properly look it up when it reloads 2) Fixed getYHeadOfPump() so it doesn't punch through bedrock if you destroy the pump head. If you break a gap into an existing pipe line, it will move down through the broken spots until it finds an existing set of pipes - in which case it will continue from the bottom. If you break the pump head, it will replace the last pipe with a new Head and carry on about it's business. --- .../machines/basic/GT_MetaTileEntity_Pump.java | 405 ++++++++++++++------- 1 file changed, 265 insertions(+), 140 deletions(-) (limited to 'src/main/java/gregtech/common/tileentities') diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java index 73c7d07720..eab1070984 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java @@ -1,5 +1,7 @@ package gregtech.common.tileentities.machines.basic; +import cpw.mods.fml.common.registry.GameRegistry; + import gregtech.api.enums.Textures; import gregtech.api.gui.GT_Container_BasicTank; import gregtech.api.gui.GT_GUIContainer_BasicTank; @@ -9,6 +11,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.BaseTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; @@ -24,9 +27,12 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fluids.IFluidHandler; -import java.util.ArrayList; +import java.util.ArrayDeque; import java.util.Iterator; +import java.util.HashSet; +import java.util.Set; +import static gregtech.api.enums.GT_Values.D1; import static gregtech.api.enums.GT_Values.V; import static gregtech.api.util.GT_Utility.getFakePlayer; @@ -35,15 +41,26 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch { private static final Block MINING_PIPE_BLOCK = GT_Utility.getBlockFromStack(MINING_PIPE); private static final Block MINING_PIPE_TIP_BLOCK = GT_Utility.getBlockFromStack(GT_ModHandler.getIC2Item("miningPipeTip", 0)); + public static int getMaxDistanceForTier(byte aTier) { + return (10 * ((int) Math.pow(1.6D, aTier))); + } + + public static long getEuUsagePerTier(byte aTier) { + return (16 * ((long) Math.pow(4, aTier))); + } - public ArrayList mPumpList = new ArrayList(); + public ArrayDeque mPumpList = new ArrayDeque(); + public boolean wasPumping = false; public int mPumpTimer = 0; public int mPumpCountBelow = 0; - public Block mPumpedBlock1 = null; - public Block mPumpedBlock2 = null; + public Block mPrimaryPumpedBlock = null; + public Block mSecondaryPumpedBlock = null; public GT_MetaTileEntity_Pump(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 3, new String[]{"The best way to empty Oceans! Outputs on top", "Pumping Area: " + ((10 * ((int) Math.pow(1.6, aTier))) * 2 + 1) + "x" + ((10 * ((int) Math.pow(1.6, aTier))) * 2 + 1)}); + super(aID, aName, aNameRegional, aTier, 3, + new String[]{"The best way to empty Oceans! Outputs on top", + "Pumping Area: " + (GT_MetaTileEntity_Pump.getMaxDistanceForTier((byte)aTier) * 2 + 1) + "x" + + (GT_MetaTileEntity_Pump.getMaxDistanceForTier((byte)aTier) * 2 + 1)}); } public GT_MetaTileEntity_Pump(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { @@ -60,15 +77,26 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch { } public void saveNBTData(NBTTagCompound aNBT) { + boolean wasPumping = this.wasPumping || !this.mPumpList.isEmpty(); + if (D1) { + GT_Log.out.println("PUMP: NBT:Save - WasPumping - " + wasPumping + " blocks (" + this.mPrimaryPumpedBlock + ", " + this.mSecondaryPumpedBlock + ")"); + } super.saveNBTData(aNBT); - aNBT.setString("mPumpedBlock1", this.mPumpedBlock1 == null ? "" : this.mPumpedBlock1.getUnlocalizedName()); - aNBT.setString("mPumpedBlock2", this.mPumpedBlock2 == null ? "" : this.mPumpedBlock2.getUnlocalizedName()); + aNBT.setString("mPumpedBlock1", this.mPrimaryPumpedBlock == null ? "" : Block.blockRegistry.getNameForObject(this.mPrimaryPumpedBlock)); + aNBT.setString("mPumpedBlock2", this.mSecondaryPumpedBlock == null ? "" : Block.blockRegistry.getNameForObject(this.mSecondaryPumpedBlock)); + aNBT.setBoolean("wasPumping", wasPumping); } public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); - this.mPumpedBlock1 = Block.getBlockFromName(aNBT.getString("mPumpedBlock1")); - this.mPumpedBlock2 = Block.getBlockFromName(aNBT.getString("mPumpedBlock2")); + this.wasPumping = aNBT.getBoolean("wasPumping"); + this.mPrimaryPumpedBlock = Block.getBlockFromName(aNBT.getString("mPumpedBlock1")); + this.mSecondaryPumpedBlock = Block.getBlockFromName(aNBT.getString("mPumpedBlock2")); + + if (D1) { + GT_Log.out.println("PUMP: NBT:Load - WasPumping - " + this.wasPumping + "(" + aNBT.getString("mPumpedBlock1") + ") " + this.mPrimaryPumpedBlock); + } + } @Override @@ -126,60 +154,105 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch { } this.doTickProfilingInThisTick = true; this.mPumpCountBelow = 0; + IGregTechTileEntity tTileEntity; - for (int i = 1; (i < 21) && ((tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance((byte) 0, i)) != null) - && ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Pump)); i++) { + for (int i = 1 ; + (i < 21) && ((tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance((byte) 0, i)) != null) + && ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Pump)) ; i++) + { + // Apparently someone might stack 21 pumps on top of each other, so let's check for that getBaseMetaTileEntity().setActive(tTileEntity.isActive()); this.mPumpCountBelow += 1; + // The more pumps we have stacked, the faster the ones below go ((GT_MetaTileEntity_Pump) tTileEntity.getMetaTileEntity()).mPumpTimer -= 1; } if (this.mPumpCountBelow <= 0) { - if ((getBaseMetaTileEntity().isAllowedToWork()) && (getBaseMetaTileEntity().isUniversalEnergyStored(16 * ((long) Math.pow(4, this.mTier)))) + // Only the bottom most pump does anything + if ((getBaseMetaTileEntity().isAllowedToWork()) && (getBaseMetaTileEntity().isUniversalEnergyStored(this.getEuUsagePerAction())) && ((this.mFluid == null) || (this.mFluid.amount + 1000 <= getCapacity()))) { boolean tMovedOneDown = false; if ((this.mPumpList.isEmpty()) && (getBaseMetaTileEntity().getTimer() % 100L == 0L)) { - tMovedOneDown = moveOneDown(); - } - if ((GT_Utility.isBlockInvalid(this.mPumpedBlock1)) || (GT_Utility.isBlockInvalid(this.mPumpedBlock2))) { - getFluidAt(getBaseMetaTileEntity().getXCoord(), getYOfPumpHead() - 1, getBaseMetaTileEntity().getZCoord()); - if ((GT_Utility.isBlockInvalid(this.mPumpedBlock1)) || (GT_Utility.isBlockInvalid(this.mPumpedBlock2))) { - getFluidAt(getBaseMetaTileEntity().getXCoord(), getYOfPumpHead(), getBaseMetaTileEntity().getZCoord() + 1); - } - if ((GT_Utility.isBlockInvalid(this.mPumpedBlock1)) || (GT_Utility.isBlockInvalid(this.mPumpedBlock2))) { - getFluidAt(getBaseMetaTileEntity().getXCoord(), getYOfPumpHead(), getBaseMetaTileEntity().getZCoord() - 1); + if (!this.wasPumping){ + tMovedOneDown = moveOneDown(); + if (D1) { + GT_Log.out.println("PUMP: Moved down"); + } + } else if (D1) { + GT_Log.out.println("PUMP: Was pumping, didn't move down"); } - if ((GT_Utility.isBlockInvalid(this.mPumpedBlock1)) || (GT_Utility.isBlockInvalid(this.mPumpedBlock2))) { - getFluidAt(getBaseMetaTileEntity().getXCoord() + 1, getYOfPumpHead(), getBaseMetaTileEntity().getZCoord()); + } + int x = getBaseMetaTileEntity().getXCoord(), z = getBaseMetaTileEntity().getZCoord(); + + if (!this.hasValidFluid()) { + // We don't have a valid block, let's try to find one + int y = getYOfPumpHead(); + + if (D1 && this.mPrimaryPumpedBlock != null) { + GT_Log.out.println("PUMP: Had an invalid pump block. Trying to find a fluid at Y: " + y + + " Previous blocks 1: " + this.mPrimaryPumpedBlock + " 2: " + this.mSecondaryPumpedBlock); } - if ((GT_Utility.isBlockInvalid(this.mPumpedBlock1)) || (GT_Utility.isBlockInvalid(this.mPumpedBlock2))) { - getFluidAt(getBaseMetaTileEntity().getXCoord() - 1, getYOfPumpHead(), getBaseMetaTileEntity().getZCoord()); + // First look down + checkForFluidToPump(x, y - 1, z ); + + // Then look all around + checkForFluidToPump(x, y, z + 1); + checkForFluidToPump(x, y, z - 1); + checkForFluidToPump(x + 1, y, z ); + checkForFluidToPump(x - 1, y, z ); + this.clearQueue(false); + + if(this.hasValidFluid()) { + // Don't move down and rebuild the queue if we now have a valid fluid + this.wasPumping = true; } + } else if (getYOfPumpHead() < getBaseMetaTileEntity().getYCoord()) { - if ((tMovedOneDown) || ((this.mPumpList.isEmpty()) && (getBaseMetaTileEntity().getTimer() % 200L == 100L)) || (getBaseMetaTileEntity().getTimer() % 72000L == 100L)) { - this.mPumpList.clear(); - int y = getBaseMetaTileEntity().getYCoord() - 1; - for (int yHead = getYOfPumpHead(); (this.mPumpList.isEmpty()) && (y >= yHead); y--) { - scanForFluid(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord(), this.mPumpList, getBaseMetaTileEntity().getXCoord(), getBaseMetaTileEntity().getZCoord(), 10 * ((int) Math.pow(1.6D, this.mTier))); + // We didn't just look for a block, and the pump head is below the pump + if ((tMovedOneDown) || this.wasPumping || + ((this.mPumpList.isEmpty()) && (getBaseMetaTileEntity().getTimer() % 200L == 100L)) || + (getBaseMetaTileEntity().getTimer() % 72000L == 100L)) + { + // Rebuild the list to pump if any of the following conditions are true: + // 1) We just moved down + // 2) We were previously pumping (and possibly just reloaded) + // 3) We have an empty queue and enough time has passed + // 4) A long while has has passed + if (D1) { + GT_Log.out.println("PUMP: Rebuilding pump list - Size " + + this.mPumpList.size() + " WasPumping: " + this.wasPumping + " Timer " + getBaseMetaTileEntity().getTimer()); + } + int yPump = getBaseMetaTileEntity().getYCoord() - 1, yHead = getYOfPumpHead(); + + this.rebuildPumpQueue(x, yPump, z, yHead); + + if (D1) { + GT_Log.out.println("PUMP: Rebuilt pump list - Size " + this.mPumpList.size()); } + } if ((!tMovedOneDown) && (this.mPumpTimer <= 0)) { - while ((!this.mPumpList.isEmpty()) - && (!consumeFluid(((ChunkPosition) this.mPumpList.get(this.mPumpList.size() - 1)).chunkPosX, - ((ChunkPosition) this.mPumpList.get(this.mPumpList.size() - 1)).chunkPosY, - ((ChunkPosition) this.mPumpList.remove(this.mPumpList.size() - 1)).chunkPosZ))) { - //Should this be empty? + while ((!this.mPumpList.isEmpty())) { + ChunkPosition pos = this.mPumpList.pollLast(); + if (consumeFluid(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ)) { + // Keep trying until we consume something, or the list is empty + break; + } } this.mPumpTimer = GT_Utility.safeInt(160 / (long)Math.pow(2, this.mTier) ); this.mPumpTimer = mPumpTimer==0 ? 1 : mPumpTimer; } + } else { + // We somehow have a valid fluid, but the head of the pump isn't below the pump. Perhaps someone broke some pipes + // -- Clear the queue and we should try to move down until we can find a valid fluid + this.clearQueue(false); } } getBaseMetaTileEntity().setActive(!this.mPumpList.isEmpty()); } - //auto outputs on top if (this.mFluid != null && (aTick % 20 == 0)) { - IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide((byte)1);//1 is up. + // auto outputs on top every second or so + IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide((byte)1); //1 is up. if (tTank != null) { FluidStack tDrained = drain(1000, false); if (tDrained != null) { @@ -192,161 +265,213 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch { } } + private int getMaxPumpableDistance() { + return GT_MetaTileEntity_Pump.getMaxDistanceForTier(this.mTier); + } + + private long getEuUsagePerAction() { + return GT_MetaTileEntity_Pump.getEuUsagePerTier(this.mTier); + } + + private boolean hasValidFluid() { + return (!GT_Utility.isBlockInvalid(this.mPrimaryPumpedBlock) && !GT_Utility.isBlockInvalid(this.mSecondaryPumpedBlock)); + } + private boolean moveOneDown() { - if ((this.mInventory[0] == null) || (this.mInventory[0].stackSize < 1) - || (!GT_Utility.areStacksEqual(this.mInventory[0], MINING_PIPE))) { + if ((this.mInventory[0] == null) || (this.mInventory[0].stackSize < 1) || (!GT_Utility.areStacksEqual(this.mInventory[0], MINING_PIPE))) { + // No mining pipes return false; } + int yHead = getYOfPumpHead(); - if (yHead <= 0) { + if (yHead <= 1) { + // Let's not punch through bedrock return false; } - if ((!consumeFluid(getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord())) && (!getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord()).isAir(getBaseMetaTileEntity().getWorld(), getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord()))) { + int x = getBaseMetaTileEntity().getXCoord(), z = getBaseMetaTileEntity().getZCoord(); + + if ((!consumeFluid(x, yHead - 1, z)) && (!getBaseMetaTileEntity().getBlock(x, yHead - 1, z).isAir(getBaseMetaTileEntity().getWorld(), x, yHead - 1, z))) { + // Either we didn't consume a fluid, or it's a non Air block return false; } - if (!GT_Utility.setBlockByFakePlayer(getFakePlayer(getBaseMetaTileEntity()), getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord(), MINING_PIPE_TIP_BLOCK, 0, false)) { + // Try to set the block below us to a a tip + if (!GT_Utility.setBlockByFakePlayer(getFakePlayer(getBaseMetaTileEntity()), x, yHead - 1, z, MINING_PIPE_TIP_BLOCK, 0, false)) { return false; } + // And change the previous block to a pipe -- as long as it isn't the pump itself! if (yHead != getBaseMetaTileEntity().getYCoord()) { - getBaseMetaTileEntity().getWorld().setBlock(getBaseMetaTileEntity().getXCoord(), yHead, getBaseMetaTileEntity().getZCoord(), MINING_PIPE_BLOCK); + getBaseMetaTileEntity().getWorld().setBlock(x, yHead, z, MINING_PIPE_BLOCK); } getBaseMetaTileEntity().decrStackSize(0, 1); return true; } private int getYOfPumpHead() { - int y = getBaseMetaTileEntity().getYCoord() - 1; - while (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord()) == MINING_PIPE_BLOCK) { - y--; + // Let's play find the pump head! + + // TODO: Handle pipe|pipe|head|pipe|pipe + int y = getBaseMetaTileEntity().getYCoord() - 1, x = getBaseMetaTileEntity().getXCoord(), z = getBaseMetaTileEntity().getZCoord(); + + while(y > 0) { + Block curBlock = getBaseMetaTileEntity().getBlock(x, y, z); + if(curBlock == MINING_PIPE_BLOCK) { + y--; + } else if (curBlock == MINING_PIPE_TIP_BLOCK) { + Block nextBlock = getBaseMetaTileEntity().getBlock(x, y - 1 , z); + if (nextBlock == MINING_PIPE_BLOCK || nextBlock == MINING_PIPE_TIP_BLOCK) { + // We're running into an existing set of pipes -- Turn this block into a pipe and keep going + this.clearQueue(true); + getBaseMetaTileEntity().getWorld().setBlock(x, y, z, MINING_PIPE_BLOCK); + } + y--; + + } else { + break; + } } - if (y == getBaseMetaTileEntity().getYCoord() - 1) { - if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord()) != MINING_PIPE_TIP_BLOCK) { - return y + 1; + + if (getBaseMetaTileEntity().getBlock(x, y, z) != MINING_PIPE_TIP_BLOCK) { + if (y != getBaseMetaTileEntity().getYCoord() - 1 && getBaseMetaTileEntity().getBlock(x, y + 1, z) == MINING_PIPE_BLOCK) { + // We're below the pump at the bottom of the pipes, we haven't found a tip; make the previous pipe a tip! + this.clearQueue(true); + getBaseMetaTileEntity().getWorld().setBlock(x, y + 1, z, MINING_PIPE_TIP_BLOCK); } - } else if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord()) != MINING_PIPE_TIP_BLOCK - && this.mInventory[0] != null && this.mInventory[0].stackSize > 0 && GT_Utility.areStacksEqual(this.mInventory[0], MINING_PIPE)) { - getBaseMetaTileEntity().getWorld().setBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord(), MINING_PIPE_BLOCK); - getBaseMetaTileEntity().decrStackSize(0, 1); + return y + 1; } return y; } - private void scanForFluid(int aX, int aY, int aZ, ArrayList aList, int mX, int mZ, int mDist) { + private void clearQueue(boolean checkPumping) { + if(checkPumping) { + this.wasPumping = !this.mPumpList.isEmpty(); + } else { + this.wasPumping = false; + } + this.mPumpList.clear(); + } + + private void rebuildPumpQueue(int aX, int yStart, int aZ, int yEnd) { + int mDist = this.getMaxPumpableDistance(); doTickProfilingInThisTick = false; - ArrayList tList1 = new ArrayList(); - ArrayList tList2 = new ArrayList(); - tList1.add(new ChunkPosition(aX, aY, aZ)); - while (!tList1.isEmpty()) { - Iterator i$ = tList1.iterator(); - do { - if (!i$.hasNext()) - break; - ChunkPosition tPos = (ChunkPosition) i$.next(); - if (tPos.chunkPosX < mX + mDist) - addToFirstListIfFluidAndNotAlreadyAddedToAnyOfTheLists(tPos.chunkPosX + 1, tPos.chunkPosY, tPos.chunkPosZ, tList2, aList); - if (tPos.chunkPosX > mX - mDist) - addToFirstListIfFluidAndNotAlreadyAddedToAnyOfTheLists(tPos.chunkPosX - 1, tPos.chunkPosY, tPos.chunkPosZ, tList2, aList); - if (tPos.chunkPosZ < mZ + mDist) - addToFirstListIfFluidAndNotAlreadyAddedToAnyOfTheLists(tPos.chunkPosX, tPos.chunkPosY, tPos.chunkPosZ + 1, tList2, aList); - if (tPos.chunkPosZ > mZ - mDist) - addToFirstListIfFluidAndNotAlreadyAddedToAnyOfTheLists(tPos.chunkPosX, tPos.chunkPosY, tPos.chunkPosZ - 1, tList2, aList); - addToFirstListIfFluidAndNotAlreadyAddedToAnyOfTheLists(tPos.chunkPosX, tPos.chunkPosY + 1, tPos.chunkPosZ, tList2, aList); - ChunkPosition tCoordinate = new ChunkPosition(aX, aY + 1, aZ); - if (tPos.chunkPosX == mX && tPos.chunkPosZ == mZ && tPos.chunkPosY < getBaseMetaTileEntity().getYCoord() && !aList.contains(tCoordinate) && !tList2.contains(tCoordinate)) - tList2.add(tCoordinate); - } while (true); - aList.addAll(tList2); - tList1 = tList2; - tList2 = new ArrayList(); + ArrayDeque fluidsToSearch = new ArrayDeque(); + ArrayDeque fluidsFound = new ArrayDeque(); + Set checked = new HashSet(); + this.clearQueue(false); + + for (int aY = yStart ; this.mPumpList.isEmpty() && aY >= yEnd ; aY--) { + // Start at the top (presumably the block below the pump), and work our way down to the end (presumably the location of the pump Head) + // and build up a queue of fluids to pump + fluidsToSearch.add(new ChunkPosition(aX, aY, aZ)); + + while (!fluidsToSearch.isEmpty()) { + Iterator i$ = fluidsToSearch.iterator(); + while(i$.hasNext()) { + ChunkPosition tPos = i$.next(); + + // Look all around + if (tPos.chunkPosX < aX + mDist) queueFluid(tPos.chunkPosX + 1, tPos.chunkPosY, tPos.chunkPosZ, fluidsFound, checked); + if (tPos.chunkPosX > aX - mDist) queueFluid(tPos.chunkPosX - 1, tPos.chunkPosY, tPos.chunkPosZ, fluidsFound, checked); + if (tPos.chunkPosZ < aZ + mDist) queueFluid(tPos.chunkPosX, tPos.chunkPosY, tPos.chunkPosZ + 1, fluidsFound, checked); + if (tPos.chunkPosZ > aZ - mDist) queueFluid(tPos.chunkPosX, tPos.chunkPosY, tPos.chunkPosZ - 1, fluidsFound, checked); + + // And then look up + queueFluid(tPos.chunkPosX, tPos.chunkPosY + 1, tPos.chunkPosZ, this.mPumpList, checked); + } + this.mPumpList.addAll(fluidsFound); + fluidsToSearch = fluidsFound; + fluidsFound = new ArrayDeque(); + } + + // Make sure we don't have the pipe location in the queue + this.mPumpList.remove(new ChunkPosition(aX, aY, aZ)); } - for (int y = getBaseMetaTileEntity().getYCoord(); y >= aY; y--) - aList.remove(new ChunkPosition(aX, y, aZ)); } - private boolean addToFirstListIfFluidAndNotAlreadyAddedToAnyOfTheLists(int aX, int aY, int aZ, ArrayList aList1, - ArrayList aList2) { + private boolean queueFluid(int aX, int aY, int aZ, ArrayDeque fluidsFound, Set checked) { + // If we haven't already looked at this coordinate set, and it's not already in the list of fluids found, see if there is + // a valid fluid and add it to the fluids found ChunkPosition tCoordinate = new ChunkPosition(aX, aY, aZ); - if ((!aList1.contains(tCoordinate)) && (!aList2.contains(tCoordinate))) { + if (checked.add(tCoordinate) && !fluidsFound.contains(tCoordinate)) { Block aBlock = getBaseMetaTileEntity().getBlock(aX, aY, aZ); - if ((this.mPumpedBlock1 == aBlock) || (this.mPumpedBlock2 == aBlock)) { - aList1.add(tCoordinate); + if ((this.mPrimaryPumpedBlock == aBlock) || (this.mSecondaryPumpedBlock == aBlock)) { + fluidsFound.addFirst(tCoordinate); return true; } } return false; } - private void getFluidAt(int aX, int aY, int aZ) { + private void checkForFluidToPump(int aX, int aY, int aZ) { + // If we don't currently have a valid fluid to pump, try pumping the fluid at the given coordinates + if(this.hasValidFluid()) + return; + Block aBlock = getBaseMetaTileEntity().getBlock(aX, aY, aZ); if (GT_Utility.isBlockValid(aBlock)) { if ((aBlock == Blocks.water) || (aBlock == Blocks.flowing_water)) { - this.mPumpedBlock1 = Blocks.water; - this.mPumpedBlock2 = Blocks.flowing_water; + this.mPrimaryPumpedBlock = Blocks.water; + this.mSecondaryPumpedBlock = Blocks.flowing_water; return; } if ((aBlock == Blocks.lava) || (aBlock == Blocks.flowing_lava)) { - this.mPumpedBlock1 = Blocks.lava; - this.mPumpedBlock2 = Blocks.flowing_lava; + this.mPrimaryPumpedBlock = Blocks.lava; + this.mSecondaryPumpedBlock = Blocks.flowing_lava; return; } if ((aBlock instanceof IFluidBlock)) { - this.mPumpedBlock1 = aBlock; - this.mPumpedBlock2 = aBlock; + this.mPrimaryPumpedBlock = aBlock; + this.mSecondaryPumpedBlock = aBlock; return; } } - this.mPumpedBlock1 = null; - this.mPumpedBlock2 = null; + this.mPrimaryPumpedBlock = null; + this.mSecondaryPumpedBlock = null; } private boolean consumeFluid(int aX, int aY, int aZ) { + // Try to consume a fluid at a location + // Returns true if something was consumed, otherwise false if (!GT_Utility.eraseBlockByFakePlayer(getFakePlayer(getBaseMetaTileEntity()), aX, aY, aZ, true)) return false; + Block aBlock = getBaseMetaTileEntity().getBlock(aX, aY, aZ); - int aMeta = getBaseMetaTileEntity().getMetaID(aX, aY, aZ); - if ((GT_Utility.isBlockValid(aBlock)) && ((this.mPumpedBlock1 == aBlock) || (this.mPumpedBlock2 == aBlock))) { - if ((aBlock == Blocks.water) || (aBlock == Blocks.flowing_water)) { - if (aMeta == 0) { - if (this.mFluid == null) { - getBaseMetaTileEntity().decreaseStoredEnergyUnits(16 * ((long) Math.pow(4, this.mTier)), true); - this.mFluid = GT_ModHandler.getWater(1000L); - } else if (GT_ModHandler.isWater(this.mFluid)) { - getBaseMetaTileEntity().decreaseStoredEnergyUnits(16 * ((long) Math.pow(4, this.mTier)), true); - this.mFluid.amount += 1000; - } else { - return false; - } - } else { - getBaseMetaTileEntity().decreaseStoredEnergyUnits(4 * ((long) Math.pow(4, this.mTier)), true); - } - } - if ((aBlock == Blocks.lava) || (aBlock == Blocks.flowing_lava)) { - if (aMeta == 0) { - if (this.mFluid == null) { - getBaseMetaTileEntity().decreaseStoredEnergyUnits(16 * ((long) Math.pow(4, this.mTier)), true); - this.mFluid = GT_ModHandler.getLava(1000L); - } else if (GT_ModHandler.isLava(this.mFluid)) { - getBaseMetaTileEntity().decreaseStoredEnergyUnits(16 * ((long) Math.pow(4, this.mTier)), true); - this.mFluid.amount += 1000; - } else { - return false; - } - } else { - getBaseMetaTileEntity().decreaseStoredEnergyUnits(4 * ((long) Math.pow(4, this.mTier)), true); + + if ((GT_Utility.isBlockValid(aBlock)) && ((this.mPrimaryPumpedBlock == aBlock) || (this.mSecondaryPumpedBlock == aBlock))) { + boolean isWaterOrLava = ((this.mPrimaryPumpedBlock == Blocks.water || this.mPrimaryPumpedBlock == Blocks.lava)); + + if (isWaterOrLava && getBaseMetaTileEntity().getMetaID(aX, aY, aZ) != 0) { + // Water/Lava that isn't a source block - do nothing here, but set the block to air and consume energy below + if (D1) { + GT_Log.out.println("PUMP: Water/Lava - Not a source block"); } - } - if ((aBlock instanceof IFluidBlock)) { - if (this.mFluid == null) { + } else if (this.mFluid == null) { + // The pump has no internal fluid + if (this.mPrimaryPumpedBlock == Blocks.water) + this.mFluid = GT_ModHandler.getWater(1000L); + else if (this.mPrimaryPumpedBlock == Blocks.lava) + this.mFluid = GT_ModHandler.getLava(1000L); + else { + // Not water or lava; try to drain and set to air this.mFluid = ((IFluidBlock) aBlock).drain(getBaseMetaTileEntity().getWorld(), aX, aY, aZ, true); - getBaseMetaTileEntity().decreaseStoredEnergyUnits(this.mFluid == null ? 1000 : this.mFluid.amount, true); - } else if (this.mFluid.isFluidEqual(((IFluidBlock) aBlock).drain(getBaseMetaTileEntity().getWorld(), aX, aY, aZ, false))) { + } + } else if (GT_ModHandler.isWater(this.mFluid) || GT_ModHandler.isLava(this.mFluid) || + this.mFluid.isFluidEqual(((IFluidBlock) aBlock).drain(getBaseMetaTileEntity().getWorld(), aX, aY, aZ, false))) + { + if (!isWaterOrLava) { + // Only set Block to Air for non lava/water fluids this.getBaseMetaTileEntity().getWorld().setBlockToAir(aX, aY, aZ); - this.mFluid.amount += 1000; - getBaseMetaTileEntity().decreaseStoredEnergyUnits(16 * ((long) Math.pow(4, this.mTier)), true); - } else { - return false; } + this.mFluid.amount += 1000; + + } else { + if (D1) { + GT_Log.out.println("PUMP: Couldn't consume " + aBlock); + } + // We didn't do anything + return false; } + + getBaseMetaTileEntity().decreaseStoredEnergyUnits(this.getEuUsagePerAction(), true); getBaseMetaTileEntity().getWorld().setBlock(aX, aY, aZ, Blocks.air, 0, 2); return true; } @@ -470,10 +595,10 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch { } private FakePlayer mFakePlayer = null; - protected FakePlayer getFakePlayer(IGregTechTileEntity aBaseTile) { - if (mFakePlayer == null) mFakePlayer = GT_Utility.getFakePlayer(aBaseTile); - mFakePlayer.setWorld(aBaseTile.getWorld()); - mFakePlayer.setPosition(aBaseTile.getXCoord(), aBaseTile.getYCoord(), aBaseTile.getZCoord()); - return mFakePlayer; - } + protected FakePlayer getFakePlayer(IGregTechTileEntity aBaseTile) { + if (mFakePlayer == null) mFakePlayer = GT_Utility.getFakePlayer(aBaseTile); + mFakePlayer.setWorld(aBaseTile.getWorld()); + mFakePlayer.setPosition(aBaseTile.getXCoord(), aBaseTile.getYCoord(), aBaseTile.getZCoord()); + return mFakePlayer; + } } -- cgit From a68f6ce22f6b47ebdde62e51bfa90fff63cb8db1 Mon Sep 17 00:00:00 2001 From: Johannes Gäßler Date: Wed, 22 Nov 2017 22:43:11 +0100 Subject: The Large Chemical Reactor can now have its Cupronickel Coil on any side Conflicts: src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java --- .../GT_MetaTileEntity_LargeChemicalReactor.java | 34 ++++++++++++++++------ 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'src/main/java/gregtech/common/tileentities') diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java index 955d873da6..a82a538876 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java @@ -45,8 +45,8 @@ public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_Mu "Size(WxHxD): 3x3x3", "3x3x3 of Chemically Inert Machine Casings (hollow, min 8!)", "Controller (Front centered)", - "1x Cupronickel Coil Block (Bottom centered)", "1x PTFE Pipe Machine Casing (inside the hollow casings)", + "1x Cupronickel Coil Block (next to PTFE Pipe Machine Casing)", "1x Input Bus/Hatch (Any inert casing)", "1x Output Bus/Hatch (Any inert casing)", "1x Maintenance Hatch (Any inert casing)", @@ -151,20 +151,37 @@ public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_Mu int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; int casingAmount = 0; + boolean hasHeatingCoil = false; // x=width, z=depth, y=height for (int x = -1 + xDir; x <= xDir + 1; x++) { for (int z = -1 + zDir; z <= zDir + 1; z++) { for (int y = -1; y <= 1; y++) { + if (x == 0 && y == 0 && z == 0) { + continue; + } IGregTechTileEntity tileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(x, y, z); Block block = aBaseMetaTileEntity.getBlockOffset(x, y, z); - if (x == xDir && z == zDir && y <= 0) { - if ((y == -1) - && (block != GregTech_API.sBlockCasings5 || aBaseMetaTileEntity.getMetaIDOffset(x, y, z) != 0)) { - return false; - } else if (y == 0 && (block != GregTech_API.sBlockCasings8 || aBaseMetaTileEntity.getMetaIDOffset(x, y, z) != 1)) { + int centerCoords = 0; + if (x == xDir) { + centerCoords++; + } + if (y == 0) { + centerCoords++; + } + if (z == zDir) { + centerCoords++; + } + if (centerCoords == 3) { + if (block == GregTech_API.sBlockCasings8 && aBaseMetaTileEntity.getMetaIDOffset(x, y, z) == 1) { + continue; + } else { return false; } - } else if (x != 0 || y != 0 || z != 0) { + } + if (centerCoords == 2 && block == GregTech_API.sBlockCasings5 && aBaseMetaTileEntity.getMetaIDOffset(x, y, z) == 0) { + hasHeatingCoil = true; + continue; + } if (!addInputToMachineList(tileEntity, CASING_INDEX) && !addOutputToMachineList(tileEntity, CASING_INDEX) && !addMaintenanceToMachineList(tileEntity, CASING_INDEX) && !addEnergyInputToMachineList(tileEntity, CASING_INDEX)) { @@ -174,13 +191,12 @@ public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_Mu return false; } } - } } } } - return casingAmount >= 8; + return casingAmount >= 8 && hasHeatingCoil; } @Override -- cgit From 22a07a05b1d8bb72805cd322e5c2ed8893f698fd Mon Sep 17 00:00:00 2001 From: Johannes Gäßler Date: Wed, 22 Nov 2017 19:37:39 +0100 Subject: Oil Cracker can now also works right -> left, EU/Maint Hatches anywhere The Oil Cracker now also accepts Input Hatches on the right side and Output Hatches on the left side. Input/Output Hatches must be on opposite sides of one another. Also, Energy/Maintenance Hatches no longer need to be on the middle ring but can also be put on the sides. --- .../multi/GT_MetaTileEntity_OilCracker.java | 46 +++++++++++++++++----- 1 file changed, 37 insertions(+), 9 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 282e8417b0..9b26e22d54 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 @@ -38,12 +38,13 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa "Thermally cracks heavy hydrocarbons into lighter fractions", "Size(WxHxD): 5x3x3 (Hollow), Controller (Front center)", "Ring of 8 Cupronickel Coils (Each side of Controller)", - "1x Hydrocarbon Input Bus/Hatch (Any left side casing)", + "1x Hydrocarbon Input Bus/Hatch (Any left/right 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!)"}; + "1x Cracked Hydrocarbon Output Hatch (Any left/right side casing)", + "1x Maintenance Hatch (Any casing)", + "1x Energy Hatch (Any casing)", + "Clean Stainless Steel Machine Casings for the rest (18 at least!)", + "Input/output Hatches must be on opposite sides"}; } public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { @@ -95,6 +96,7 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa int zDir = this.orientation.offsetZ; int amount = 0; replaceDeprecatedCoils(aBaseMetaTileEntity); + boolean negSideInput = false, negSideOutput = false, posSideInput = false, posSideOutput = false; if (xDir != 0) { for (int i = -1; i < 2; i++) {// xDirection for (int j = -1; j < 2; j++) {// height @@ -110,8 +112,19 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa } if (h == 2 || h == -2) { IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, j, h + zDir); - boolean tSide = ((aBaseMetaTileEntity.getBackFacing() == 4 && 2 == h) || (aBaseMetaTileEntity.getBackFacing() == 5 && -2 == h)); - if (tSide ? !addInputToMachineList(tTileEntity, 49) : !addOutputToMachineList(tTileEntity, 49)) { + if (addInputToMachineList(tTileEntity, 49)) { + if (h == -2) { + negSideInput = true; + } else { + posSideInput = true; + } + } else if (addOutputToMachineList(tTileEntity, 49)) { + if (h == -2) { + negSideOutput = true; + } else { + posSideOutput = true; + } + } else if (!addEnergyInputToMachineList(tTileEntity, 49) && !addMaintenanceToMachineList(tTileEntity, 49)){ if (aBaseMetaTileEntity.getBlockOffset(xDir + i, j, h + zDir) != GregTech_API.sBlockCasings4) { return false; } @@ -156,8 +169,19 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa } if (h == 2 || h == -2) { IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + h, j, i + zDir); - boolean tSide = (aBaseMetaTileEntity.getBackFacing() == h || (aBaseMetaTileEntity.getBackFacing() == 3 && -2 == h)); - if (tSide ? !addOutputToMachineList(tTileEntity, 49) : !addInputToMachineList(tTileEntity, 49)) { + if (addInputToMachineList(tTileEntity, 49)) { + if (h == -2) { + negSideInput = true; + } else { + posSideInput = true; + } + } else if (addOutputToMachineList(tTileEntity, 49)) { + if (h == -2) { + negSideOutput = true; + } else { + posSideOutput = true; + } + } else if (!addEnergyInputToMachineList(tTileEntity, 49) && !addMaintenanceToMachineList(tTileEntity, 49)){ if (aBaseMetaTileEntity.getBlockOffset(xDir + h, j, i + zDir) != GregTech_API.sBlockCasings4) { return false; } @@ -188,6 +212,10 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa } } } + if ((negSideInput && negSideOutput) || (posSideInput && posSideOutput) + || (negSideInput && posSideInput) || (negSideOutput && posSideOutput)) { + return false; + } if (amount < 18) return false; return true; } -- cgit From d793a2397b3b1dc2e18c63893d641c4f54aa9490 Mon Sep 17 00:00:00 2001 From: Johannes Gäßler Date: Wed, 22 Nov 2017 19:59:30 +0100 Subject: Fixed Oil Cracker description typo --- .../tileentities/machines/multi/GT_MetaTileEntity_OilCracker.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_OilCracker.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java index 9b26e22d54..057ba9e0cc 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 @@ -44,7 +44,7 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa "1x Maintenance Hatch (Any casing)", "1x Energy Hatch (Any casing)", "Clean Stainless Steel Machine Casings for the rest (18 at least!)", - "Input/output Hatches must be on opposite sides"}; + "Input/Output Hatches must be on opposite sides"}; } public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { -- cgit From 9993cdcf5ec80b4d82e70af2ab33a67575ee82f5 Mon Sep 17 00:00:00 2001 From: Dream-Master Date: Sat, 2 Dec 2017 08:21:56 +0100 Subject: cherry pick Commit: af7e1d800d76d485608e74105b438c9775debc96 [af7e1d8] Merge pull request #1272 from SuperCoder7979/Magic-Fix Magic fix --- .../GT_MetaTileEntity_MagicalEnergyAbsorber.java | 37 ++++++++++------------ 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'src/main/java/gregtech/common/tileentities') diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicalEnergyAbsorber.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicalEnergyAbsorber.java index 6adde2638d..3bc2731d4a 100644 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicalEnergyAbsorber.java +++ b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicalEnergyAbsorber.java @@ -38,7 +38,7 @@ public class GT_MetaTileEntity_MagicalEnergyAbsorber extends GT_MetaTileEntity_B public static boolean sAllowMultipleEggs = true; public static GT_MetaTileEntity_MagicalEnergyAbsorber mActiveSiphon = null; public static int sEnergyPerEnderCrystal = 32; - public static int sEnergyFromVis = 12800; + public static int sEnergyFromVis = 512; public static int sDragonEggEnergyPerTick = 128; public static boolean isThaumcraftLoaded; public int mEfficiency; @@ -53,7 +53,7 @@ public class GT_MetaTileEntity_MagicalEnergyAbsorber extends GT_MetaTileEntity_B super(aName, aTier, aDescription, aTextures); onConfigLoad(); } - + public GT_MetaTileEntity_MagicalEnergyAbsorber(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { super(aName, aTier, aDescription, aTextures); onConfigLoad(); @@ -109,34 +109,31 @@ public class GT_MetaTileEntity_MagicalEnergyAbsorber extends GT_MetaTileEntity_B // Energyzed node if (isThaumcraftLoaded) { try { + int multFactor = 2; World tmpWorld = this.getBaseMetaTileEntity().getWorld(); int tmpX = this.getBaseMetaTileEntity().getXCoord(); int tmpY = this.getBaseMetaTileEntity().getYCoord(); int tmpZ = this.getBaseMetaTileEntity().getZCoord(); - int fire = VisNetHandler.drainVis(tmpWorld, tmpX, tmpY, tmpZ, Aspect.FIRE, 1000); + int fire = VisNetHandler.drainVis(tmpWorld, tmpX, tmpY, tmpZ, Aspect.FIRE, 1000); // all of these should be 1000 int earth = VisNetHandler.drainVis(tmpWorld, tmpX, tmpY, tmpZ, Aspect.EARTH, 1000); int air = VisNetHandler.drainVis(tmpWorld, tmpX, tmpY, tmpZ, Aspect.AIR, 1000); - int destruction = VisNetHandler.drainVis(tmpWorld, tmpX, tmpY, tmpZ, Aspect.ENTROPY, 1000); + int entropy = VisNetHandler.drainVis(tmpWorld, tmpX, tmpY, tmpZ, Aspect.ENTROPY, 1000); int order = VisNetHandler.drainVis(tmpWorld, tmpX, tmpY, tmpZ, Aspect.ORDER, 1000); int water = VisNetHandler.drainVis(tmpWorld, tmpX, tmpY, tmpZ, Aspect.WATER, 1000); - int visEU = (int) (Math.pow(fire, 4) + Math.pow(earth, 4) + Math.pow(air, 4) + Math.pow(destruction, 4) + Math.pow(order, 4) + Math.pow( - water, 4)); - int mult = 85; - if (fire > 4) - mult += 15; - if (earth > 4) - mult += 15; - if (air > 4) - mult += 15; - if (destruction > 4) - mult += 15; - if (order > 4) - mult += 15; - if (water > 4) - mult += 15; + int visEU = (int) (Math.pow(fire, 2) + Math.pow(earth, 2) + Math.pow(air, 2) + Math.pow(entropy, 2) + Math.pow(order, 2) + Math.pow(water, 2)); + int mult = 0; //this should make it more dependant on how big your node is + mult += fire * multFactor; + mult += earth * multFactor; + mult += air * multFactor; + mult += entropy * multFactor; + mult += order * multFactor; + mult += water * multFactor; visEU = (visEU * mult) / 100; - getBaseMetaTileEntity().increaseStoredEnergyUnits(Math.min(maxEUOutput(), visEU * getEfficiency() / this.sEnergyFromVis), false); + + getBaseMetaTileEntity().increaseStoredEnergyUnits(Math.min(maxEUOutput(), visEU * getEfficiency() / sEnergyFromVis), false); + } catch (Throwable e) { + } } // EnderCrystal -- cgit