From 2356b7ce57fb7bc6ba753e24950743267fadf8b1 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Thu, 4 Sep 2014 22:42:48 -0500 Subject: [PATCH] Fixed Bug: #0620 - Breaks parts now is consistent with breaking blocks. --- block/AEBaseBlock.java | 14 +++++++------- block/networking/BlockCableBus.java | 2 +- parts/CableBusContainer.java | 14 ++++++++++++++ tile/AEBaseTile.java | 25 +++++++++++++++++++++---- tile/networking/TileCableBus.java | 5 +++++ 5 files changed, 48 insertions(+), 12 deletions(-) diff --git a/block/AEBaseBlock.java b/block/AEBaseBlock.java index d88e66c30..4401f4d33 100644 --- a/block/AEBaseBlock.java +++ b/block/AEBaseBlock.java @@ -441,14 +441,14 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature AEBaseTile te = getTileEntity( w, x, y, z ); if ( te != null ) { - if ( te.dropItems ) - { - ArrayList drops = new ArrayList(); + ArrayList drops = new ArrayList(); + if ( te.dropItems() ) te.getDrops( w, x, y, z, drops ); + else + te.getNoDrops( w, x, y, z, drops ); - // Cry ;_; ... - Platform.spawnDrops( w, x, y, z, drops ); - } + // Cry ;_; ... + Platform.spawnDrops( w, x, y, z, drops ); } super.breakBlock( w, x, y, z, a, b ); @@ -532,7 +532,7 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature if ( Platform.isClient() ) { EntityPlayer player = Minecraft.getMinecraft().thePlayer; - LookDirection ld = Platform.getPlayerRay( player, Platform.getEyeOffset(player ) ); + LookDirection ld = Platform.getPlayerRay( player, Platform.getEyeOffset( player ) ); Iterable bbs = collisionHandler.getSelectedBoundingBoxsFromPool( w, x, y, z, Minecraft.getMinecraft().thePlayer, true ); AxisAlignedBB br = null; diff --git a/block/networking/BlockCableBus.java b/block/networking/BlockCableBus.java index fc938db7a..97b5e1b8e 100644 --- a/block/networking/BlockCableBus.java +++ b/block/networking/BlockCableBus.java @@ -282,7 +282,7 @@ public class BlockCableBus extends AEBaseBlock implements IRedNetConnection { AEBaseTile tile = getTileEntity( world, x, y, z ); if ( tile != null ) - tile.dropItems = false; + tile.disableDrops(); // maybe ray trace? } return super.removedByPlayer( world, player, x, y, z ); diff --git a/parts/CableBusContainer.java b/parts/CableBusContainer.java index 7f5038da4..0ad38c3de 100644 --- a/parts/CableBusContainer.java +++ b/parts/CableBusContainer.java @@ -731,6 +731,20 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I return drops; } + public List getNoDrops(List drops) + { + for (ForgeDirection s : ForgeDirection.values()) + { + IPart part = getPart( s ); + if ( part != null ) + { + part.getDrops( drops, false ); + } + } + + return drops; + } + @Override public void markForUpdate() { diff --git a/tile/AEBaseTile.java b/tile/AEBaseTile.java index 33cf86eba..db4a7126d 100644 --- a/tile/AEBaseTile.java +++ b/tile/AEBaseTile.java @@ -3,6 +3,7 @@ package appeng.tile; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; +import java.lang.ref.WeakReference; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.EnumMap; @@ -44,7 +45,19 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, private ForgeDirection forward = ForgeDirection.UNKNOWN; private ForgeDirection up = ForgeDirection.UNKNOWN; - public boolean dropItems = true; + public static ThreadLocal> dropNoItems = new ThreadLocal(); + + public void disableDrops() + { + dropNoItems.set( new WeakReference( this ) ); + } + + public boolean dropItems() + { + WeakReference what = dropNoItems.get(); + return what == null || what.get() != this; + } + public int renderFragment = 0; public String customName; @@ -366,6 +379,11 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, } + public void getNoDrops(World w, int x, int y, int z, ArrayList drops) + { + + } + public void onReady() { @@ -450,9 +468,8 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, public void securityBreak() { - worldObj.func_147480_a( xCoord, yCoord, zCoord, true ); // worldObj.destroyBlock( xCoord, yCoord, zCoord, true - // ); - dropItems = false; + worldObj.func_147480_a( xCoord, yCoord, zCoord, true ); + disableDrops(); } public void saveChanges() diff --git a/tile/networking/TileCableBus.java b/tile/networking/TileCableBus.java index 6fc238f59..c23f2a817 100644 --- a/tile/networking/TileCableBus.java +++ b/tile/networking/TileCableBus.java @@ -162,6 +162,11 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl cb.getDrops( drops ); } + public void getNoDrops(World w, int x, int y, int z, ArrayList drops) + { + cb.getNoDrops( drops ); + } + @Override public IGridNode getGridNode(ForgeDirection dir) {