Annihilation Plane no longer CME's on breaking network components.

Annihilation Plane properly breaks things when power is restored.
This commit is contained in:
AlgorithmX2 2014-02-14 00:15:04 -06:00
parent 480f4b8180
commit 7f99e281f0

View file

@ -2,6 +2,7 @@ package appeng.parts.automation;
import java.io.IOException;
import java.util.LinkedList;
import java.util.concurrent.Callable;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
@ -18,6 +19,9 @@ import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.networking.IGridNode;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.events.MENetworkChannelsChanged;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.storage.IStorageGrid;
@ -32,6 +36,7 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.client.texture.CableBusTextures;
import appeng.core.AELog;
import appeng.core.sync.packets.PacketTransitionEffect;
import appeng.helpers.TickHandler;
import appeng.me.GridAccessException;
import appeng.parts.PartBasicState;
import appeng.server.ServerHelper;
@ -40,7 +45,7 @@ import appeng.util.item.AEItemStack;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class PartAnnihilationPlane extends PartBasicState implements IGridTickable
public class PartAnnihilationPlane extends PartBasicState implements IGridTickable, Callable
{
public PartAnnihilationPlane(ItemStack is) {
@ -156,6 +161,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
return 1;
}
boolean breaking = false;
LinkedList<IAEItemStack> Buffer = new LinkedList();
BaseActionSource mySrc = new MachineSource( this );
@ -194,7 +200,19 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
return Buffer.isEmpty();
}
public TickRateModulation EatBlock()
@MENetworkEventSubscribe
public void chanRender(MENetworkChannelsChanged c)
{
onNeighborChanged();
}
@MENetworkEventSubscribe
public void powerRender(MENetworkPowerStatusChange c)
{
onNeighborChanged();
}
public TickRateModulation EatBlock(boolean eatForReal)
{
if ( isAccepting() && proxy.isActive() )
{
@ -231,6 +249,9 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
boolean hasPower = energy.extractAEPower( total, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > total - 0.1;
if ( hasPower )
{
if ( eatForReal )
{
energy.extractAEPower( total, Actionable.MODULATE, PowerMultiplier.CONFIG );
w.setBlock( x, y, z, Platform.air, 0, 3 );
try
@ -250,10 +271,14 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
Buffer.add( storedItem );
}
if ( isAccepting() )
return TickRateModulation.URGENT; // tick again in a sec..
return TickRateModulation.IDLE;
return TickRateModulation.URGENT;
}
else
{
breaking = true;
TickHandler.instance.addCallable( this );
return TickRateModulation.URGENT;
}
}
}
}
@ -351,8 +376,11 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
@Override
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall)
{
if ( breaking )
return TickRateModulation.URGENT;
if ( isAccepting() )
return EatBlock();
return EatBlock( false );
else
{
storeBuffer();
@ -384,4 +412,11 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
}
}
@Override
public Object call() throws Exception
{
breaking = false;
return EatBlock( true );
}
}