diff options
author | Martin Robertz <dream-master@gmx.net> | 2021-03-19 17:34:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-19 17:34:45 +0100 |
commit | b20358888b73f044a57a0a5ec148a987ae41f50b (patch) | |
tree | 30f00d8468a27ee8f0e8d062d0d37e7898034ebb /src/main/java | |
parent | 49d201accb39af30ede9169077f21e07aef22243 (diff) | |
parent | 0179def9d47aa693df7451fbc22c854f63a64861 (diff) | |
download | GT5-Unofficial-b20358888b73f044a57a0a5ec148a987ae41f50b.tar.gz GT5-Unofficial-b20358888b73f044a57a0a5ec148a987ae41f50b.tar.bz2 GT5-Unofficial-b20358888b73f044a57a0a5ec148a987ae41f50b.zip |
Merge pull request #463 from repo-alt/experimental
Allow several miners in one chunk
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java | 47 |
1 files changed, 28 insertions, 19 deletions
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 787c3c0d76..35cc78d162 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 @@ -175,10 +175,19 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine { if (drillY == 0 || oreBlockPositions.isEmpty()) { moveOneDown(aBaseMetaTileEntity); } else { - ChunkPosition oreBlockPos = oreBlockPositions.remove(0); - mineBlock(aBaseMetaTileEntity, oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ); - if (debugBlockMiner) { - GT_Log.out.println("MINER: Mining GT ore block at " + oreBlockPos.chunkPosX + " " + drillY + " " + oreBlockPos.chunkPosZ); + ChunkPosition oreBlockPos; + Block block; + do { + oreBlockPos = oreBlockPositions.remove(0); + block = aBaseMetaTileEntity.getBlockOffset(oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ); + } // someone else might have removed the block + while (block == Blocks.air && !oreBlockPositions.isEmpty()); + + if (block != Blocks.air) { + mineBlock(aBaseMetaTileEntity, block, + aBaseMetaTileEntity.getXCoord() + oreBlockPos.chunkPosX, + aBaseMetaTileEntity.getYCoord() + oreBlockPos.chunkPosY, + aBaseMetaTileEntity.getZCoord() + oreBlockPos.chunkPosZ); } } } @@ -236,11 +245,9 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine { waitMiningPipe = true; return false; } - if (aBaseMetaTileEntity.getBlockOffset(0, drillY - 1, 0) != Blocks.air) { - mineBlock(aBaseMetaTileEntity, 0, drillY - 1, 0); - if (debugBlockMiner) { - GT_Log.out.println("MINER: Removed block to replace with pipe" ); - } + Block block = aBaseMetaTileEntity.getBlockOffset(0, drillY - 1, 0); + if (block != Blocks.air) { + mineBlock(aBaseMetaTileEntity, block, xCoord, yCoord + drillY - 1, zCoord); } aBaseMetaTileEntity.getWorld().setBlock(xCoord, yCoord + drillY - 1, zCoord, MINING_PIPE_TIP_BLOCK); drillY--; @@ -248,18 +255,20 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine { return true; } - public void mineBlock(IGregTechTileEntity aBaseMetaTileEntity, int x, int y, int z) { - if (!GT_Utility.eraseBlockByFakePlayer(getFakePlayer(aBaseMetaTileEntity), aBaseMetaTileEntity.getXCoord() + x, aBaseMetaTileEntity.getYCoord() + y, aBaseMetaTileEntity.getZCoord() + z, true)) { + public void mineBlock(IGregTechTileEntity aBaseMetaTileEntity, Block block, int x, int y, int z) { + if (!GT_Utility.eraseBlockByFakePlayer(getFakePlayer(aBaseMetaTileEntity), x, y, z, true)) { if (debugBlockMiner) - GT_Log.out.println("MINER: FakePlayer cannot mine block at " + (aBaseMetaTileEntity.getXCoord() + x) + ", " + (aBaseMetaTileEntity.getYCoord() + y) + ", " + (aBaseMetaTileEntity.getZCoord() + z)); - return; + GT_Log.out.println("MINER: FakePlayer cannot mine block at " + x + ", " + y + ", " + z); + } else { + ArrayList<ItemStack> drops = getBlockDrops(block, x, y, z); + if (drops.size() > 0) + mOutputItems[0] = drops.get(0); + if (drops.size() > 1) + mOutputItems[1] = drops.get(1); + aBaseMetaTileEntity.getWorld().setBlockToAir(x, y, z); + if (debugBlockMiner) + GT_Log.out.println("MINER: Mining GT ore block at " + x + " " + y + " " + z); } - ArrayList<ItemStack> drops = getBlockDrops(aBaseMetaTileEntity.getBlockOffset(x, y, z), aBaseMetaTileEntity.getXCoord() + x, aBaseMetaTileEntity.getYCoord() + y, aBaseMetaTileEntity.getZCoord() + z); - if (drops.size() > 0) - mOutputItems[0] = drops.get(0); - if (drops.size() > 1) - mOutputItems[1] = drops.get(1); - aBaseMetaTileEntity.getWorld().setBlockToAir(aBaseMetaTileEntity.getXCoord() + x, aBaseMetaTileEntity.getYCoord() + y, aBaseMetaTileEntity.getZCoord() + z); } private ArrayList<ItemStack> getBlockDrops(final Block oreBlock, int posX, int posY, int posZ) { |