Fixes #943 readded callable for simultaneous block breaking

This commit is contained in:
yueh 2015-02-26 22:33:23 +01:00
parent 3e90f354c5
commit ec8d393403

View file

@ -19,6 +19,8 @@
package appeng.parts.automation; package appeng.parts.automation;
import java.util.concurrent.Callable;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -57,6 +59,7 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.client.texture.CableBusTextures; import appeng.client.texture.CableBusTextures;
import appeng.core.settings.TickRates; import appeng.core.settings.TickRates;
import appeng.core.sync.packets.PacketTransitionEffect; import appeng.core.sync.packets.PacketTransitionEffect;
import appeng.hooks.TickHandler;
import appeng.me.GridAccessException; import appeng.me.GridAccessException;
import appeng.parts.PartBasicState; import appeng.parts.PartBasicState;
import appeng.server.ServerHelper; import appeng.server.ServerHelper;
@ -64,17 +67,25 @@ import appeng.util.Platform;
import appeng.util.item.AEItemStack; import appeng.util.item.AEItemStack;
public class PartAnnihilationPlane extends PartBasicState implements IGridTickable public class PartAnnihilationPlane extends PartBasicState implements IGridTickable, Callable<TickRateModulation>
{ {
private boolean isAccepting = true; private boolean isAccepting = true;
private final BaseActionSource mySrc = new MachineSource( this ); private final BaseActionSource mySrc = new MachineSource( this );
private boolean breaking = false;
public PartAnnihilationPlane( ItemStack is ) public PartAnnihilationPlane( ItemStack is )
{ {
super( PartAnnihilationPlane.class, is ); super( PartAnnihilationPlane.class, is );
} }
@Override
public TickRateModulation call() throws Exception
{
this.breaking = false;
return this.breakblock( true );
}
@Override @Override
@SideOnly( Side.CLIENT ) @SideOnly( Side.CLIENT )
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer ) public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
@ -233,7 +244,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
this.getHost().markForUpdate(); this.getHost().markForUpdate();
} }
public TickRateModulation breakblock() public TickRateModulation breakblock( boolean modulate )
{ {
if ( this.isAccepting() && this.proxy.isActive() ) if ( this.isAccepting() && this.proxy.isActive() )
{ {
@ -272,6 +283,8 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
final boolean canStore = this.canStoreItemStacks( out ); final boolean canStore = this.canStoreItemStacks( out );
if ( hasPower && canStore ) if ( hasPower && canStore )
{
if ( modulate )
{ {
w.setBlock( x, y, z, Platform.AIR, 0, 3 ); w.setBlock( x, y, z, Platform.AIR, 0, 3 );
energy.extractAEPower( total, Actionable.MODULATE, PowerMultiplier.CONFIG ); energy.extractAEPower( total, Actionable.MODULATE, PowerMultiplier.CONFIG );
@ -288,14 +301,17 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
for ( final ItemStack snaggedItem : out ) for ( final ItemStack snaggedItem : out )
{ {
if ( this.storeItemStack( snaggedItem ) ) this.storeItemStack( snaggedItem );
{ }
ServerHelper.proxy.sendToAllNearExcept( null, x, y, z, 64, w, new PacketTransitionEffect( x, y, z, this.side, true ) ); ServerHelper.proxy.sendToAllNearExcept( null, x, y, z, 64, w, new PacketTransitionEffect( x, y, z, this.side, true ) );
} }
else
{
this.breaking = true;
TickHandler.INSTANCE.addCallable( this.tile.getWorldObj(), this );
} }
return TickRateModulation.URGENT; return TickRateModulation.URGENT;
} }
} }
} }
@ -397,8 +413,13 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
@Override @Override
public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall ) public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall )
{ {
if ( this.breaking )
{
return TickRateModulation.URGENT;
}
this.isAccepting = true; this.isAccepting = true;
return this.breakblock(); return this.breakblock( false );
} }
/** /**