From fd6a4564345a76ebdcaadf53ba4752c1c2492383 Mon Sep 17 00:00:00 2001 From: asiekierka Date: Fri, 24 Oct 2014 20:11:05 +0200 Subject: [PATCH] add buildcraft quarry frame cleanup, close #2005 --- common/buildcraft/factory/BlockFrame.java | 23 +++++++++++- common/buildcraft/factory/BlockQuarry.java | 43 ++-------------------- 2 files changed, 24 insertions(+), 42 deletions(-) diff --git a/common/buildcraft/factory/BlockFrame.java b/common/buildcraft/factory/BlockFrame.java index 8565a57f..f2cd9598 100644 --- a/common/buildcraft/factory/BlockFrame.java +++ b/common/buildcraft/factory/BlockFrame.java @@ -8,6 +8,7 @@ */ package buildcraft.factory; +import java.util.ArrayList; import java.util.List; import java.util.Random; @@ -23,11 +24,11 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; - +import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import buildcraft.BuildCraftCore; +import buildcraft.BuildCraftFactory; import buildcraft.core.CoreConstants; import buildcraft.core.IFramePipeConnection; import buildcraft.core.utils.Utils; @@ -39,6 +40,19 @@ public class BlockFrame extends Block implements IFramePipeConnection { setHardness(0.5F); } + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + if (world.isRemote) { + return; + } + + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + Block nBlock = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ); + if (nBlock == this) { + world.setBlockToAir(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ); + } + } + } @Override public boolean isOpaqueCube() { return false; @@ -54,6 +68,11 @@ public class BlockFrame extends Block implements IFramePipeConnection { return null; } + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + return new ArrayList(); + } + @Override public int getRenderType() { return BuildCraftCore.legacyPipeModel; diff --git a/common/buildcraft/factory/BlockQuarry.java b/common/buildcraft/factory/BlockQuarry.java index d2b57b77..21462ba6 100644 --- a/common/buildcraft/factory/BlockQuarry.java +++ b/common/buildcraft/factory/BlockQuarry.java @@ -132,12 +132,6 @@ public class BlockQuarry extends BlockBuildCraft { } } - private void markFrameForDecay(World world, int x, int y, int z) { - if (world.getBlock(x, y, z) == BuildCraftFactory.frameBlock) { - world.setBlockMetadataWithNotify(x, y, z, 1, 0); - } - } - @Override public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { if (BuildCraftFactory.quarryOneTimeUse) { @@ -147,45 +141,14 @@ public class BlockQuarry extends BlockBuildCraft { } @Override - public void breakBlock(World world, int i, int j, int k, Block block, int par6) { + public void breakBlock(World world, int i, int j, int k, Block block, int metadata) { if (world.isRemote) { return; } - TileEntity tile = world.getTileEntity(i, j, k); - if (tile instanceof TileQuarry) { - TileQuarry quarry = (TileQuarry) tile; - Box box = quarry.box; - if (box.isInitialized() && Integer.MAX_VALUE != box.xMax) { - // X - Axis - for (int x = box.xMin; x <= box.xMax; x++) { - markFrameForDecay(world, x, box.yMin, box.zMin); - markFrameForDecay(world, x, box.yMax, box.zMin); - markFrameForDecay(world, x, box.yMin, box.zMax); - markFrameForDecay(world, x, box.yMax, box.zMax); - } + BuildCraftFactory.frameBlock.breakBlock(world, i, j, k, block, metadata); - // Z - Axis - for (int z = box.zMin + 1; z <= box.zMax - 1; z++) { - markFrameForDecay(world, box.xMin, box.yMin, z); - markFrameForDecay(world, box.xMax, box.yMin, z); - markFrameForDecay(world, box.xMin, box.yMax, z); - markFrameForDecay(world, box.xMax, box.yMax, z); - } - - // Y - Axis - for (int y = box.yMin + 1; y <= box.yMax - 1; y++) { - - markFrameForDecay(world, box.xMin, y, box.zMin); - markFrameForDecay(world, box.xMax, y, box.zMin); - markFrameForDecay(world, box.xMin, y, box.zMax); - markFrameForDecay(world, box.xMax, y, box.zMax); - } - } - quarry.destroy(); - } - - super.breakBlock(world, i, j, k, block, par6); + super.breakBlock(world, i, j, k, block, metadata); } @Override