From ec8d393403ad8d92b1a618631368ddb3cb1078aa Mon Sep 17 00:00:00 2001 From: yueh Date: Thu, 26 Feb 2015 22:33:23 +0100 Subject: [PATCH] Fixes #943 readded callable for simultaneous block breaking --- .../automation/PartAnnihilationPlane.java | 63 ++++++++++++------- 1 file changed, 42 insertions(+), 21 deletions(-) diff --git a/src/main/java/appeng/parts/automation/PartAnnihilationPlane.java b/src/main/java/appeng/parts/automation/PartAnnihilationPlane.java index aafb4680..cf4856b9 100644 --- a/src/main/java/appeng/parts/automation/PartAnnihilationPlane.java +++ b/src/main/java/appeng/parts/automation/PartAnnihilationPlane.java @@ -19,6 +19,8 @@ package appeng.parts.automation; +import java.util.concurrent.Callable; + import com.google.common.collect.Lists; import net.minecraft.block.Block; @@ -57,6 +59,7 @@ import appeng.api.storage.data.IAEItemStack; import appeng.client.texture.CableBusTextures; import appeng.core.settings.TickRates; import appeng.core.sync.packets.PacketTransitionEffect; +import appeng.hooks.TickHandler; import appeng.me.GridAccessException; import appeng.parts.PartBasicState; import appeng.server.ServerHelper; @@ -64,17 +67,25 @@ import appeng.util.Platform; import appeng.util.item.AEItemStack; -public class PartAnnihilationPlane extends PartBasicState implements IGridTickable +public class PartAnnihilationPlane extends PartBasicState implements IGridTickable, Callable { private boolean isAccepting = true; private final BaseActionSource mySrc = new MachineSource( this ); + private boolean breaking = false; public PartAnnihilationPlane( ItemStack is ) { super( PartAnnihilationPlane.class, is ); } + @Override + public TickRateModulation call() throws Exception + { + this.breaking = false; + return this.breakblock( true ); + } + @Override @SideOnly( Side.CLIENT ) public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer ) @@ -233,7 +244,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab this.getHost().markForUpdate(); } - public TickRateModulation breakblock() + public TickRateModulation breakblock( boolean modulate ) { if ( this.isAccepting() && this.proxy.isActive() ) { @@ -273,29 +284,34 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab if ( hasPower && canStore ) { - w.setBlock( x, y, z, Platform.AIR, 0, 3 ); - energy.extractAEPower( total, Actionable.MODULATE, PowerMultiplier.CONFIG ); - - final AxisAlignedBB box = AxisAlignedBB.getBoundingBox( x - 0.2, y - 0.2, z - 0.2, x + 1.2, y + 1.2, z + 1.2 ); - for ( final Object ei : w.getEntitiesWithinAABB( EntityItem.class, box ) ) + if ( modulate ) { - if ( ei instanceof EntityItem ) - { - final EntityItem entityItem = ( EntityItem ) ei; - this.storeEntityItem( entityItem ); - } - } + w.setBlock( x, y, z, Platform.AIR, 0, 3 ); + energy.extractAEPower( total, Actionable.MODULATE, PowerMultiplier.CONFIG ); - for ( final ItemStack snaggedItem : out ) + final AxisAlignedBB box = AxisAlignedBB.getBoundingBox( x - 0.2, y - 0.2, z - 0.2, x + 1.2, y + 1.2, z + 1.2 ); + for ( final Object ei : w.getEntitiesWithinAABB( EntityItem.class, box ) ) + { + if ( ei instanceof EntityItem ) + { + final EntityItem entityItem = ( EntityItem ) ei; + this.storeEntityItem( entityItem ); + } + } + + for ( final ItemStack snaggedItem : out ) + { + this.storeItemStack( snaggedItem ); + } + + ServerHelper.proxy.sendToAllNearExcept( null, x, y, z, 64, w, new PacketTransitionEffect( x, y, z, this.side, true ) ); + } + else { - if ( this.storeItemStack( snaggedItem ) ) - { - ServerHelper.proxy.sendToAllNearExcept( null, x, y, z, 64, w, new PacketTransitionEffect( x, y, z, this.side, true ) ); - } + this.breaking = true; + TickHandler.INSTANCE.addCallable( this.tile.getWorldObj(), this ); } - return TickRateModulation.URGENT; - } } } @@ -397,8 +413,13 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab @Override public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall ) { + if ( this.breaking ) + { + return TickRateModulation.URGENT; + } + this.isAccepting = true; - return this.breakblock(); + return this.breakblock( false ); } /**