2013-12-27 23:59:59 +01:00
|
|
|
package appeng.parts.automation;
|
|
|
|
|
2014-02-14 05:27:15 +01:00
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.LinkedList;
|
2014-05-27 22:47:36 +02:00
|
|
|
import java.util.List;
|
2014-02-14 07:15:04 +01:00
|
|
|
import java.util.concurrent.Callable;
|
2014-02-14 05:27:15 +01:00
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.material.Material;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.client.renderer.RenderBlocks;
|
2014-02-14 05:27:15 +01:00
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.item.EntityItem;
|
|
|
|
import net.minecraft.init.Blocks;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2014-02-14 05:27:15 +01:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2014-03-15 07:58:21 +01:00
|
|
|
import net.minecraft.util.AxisAlignedBB;
|
2014-02-14 05:27:15 +01:00
|
|
|
import net.minecraft.world.WorldServer;
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2014-02-14 05:27:15 +01:00
|
|
|
import appeng.api.config.Actionable;
|
|
|
|
import appeng.api.config.PowerMultiplier;
|
|
|
|
import appeng.api.networking.IGridNode;
|
|
|
|
import appeng.api.networking.energy.IEnergyGrid;
|
2014-02-14 07:15:04 +01:00
|
|
|
import appeng.api.networking.events.MENetworkChannelsChanged;
|
|
|
|
import appeng.api.networking.events.MENetworkEventSubscribe;
|
|
|
|
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
2014-02-14 05:27:15 +01:00
|
|
|
import appeng.api.networking.security.BaseActionSource;
|
|
|
|
import appeng.api.networking.security.MachineSource;
|
|
|
|
import appeng.api.networking.storage.IStorageGrid;
|
|
|
|
import appeng.api.networking.ticking.IGridTickable;
|
|
|
|
import appeng.api.networking.ticking.TickRateModulation;
|
|
|
|
import appeng.api.networking.ticking.TickingRequest;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.parts.IPart;
|
|
|
|
import appeng.api.parts.IPartCollsionHelper;
|
|
|
|
import appeng.api.parts.IPartHost;
|
|
|
|
import appeng.api.parts.IPartRenderHelper;
|
2014-02-14 05:27:15 +01:00
|
|
|
import appeng.api.storage.data.IAEItemStack;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.client.texture.CableBusTextures;
|
2014-02-14 05:27:15 +01:00
|
|
|
import appeng.core.AELog;
|
2014-03-17 20:59:50 +01:00
|
|
|
import appeng.core.settings.TickRates;
|
2014-02-14 05:27:15 +01:00
|
|
|
import appeng.core.sync.packets.PacketTransitionEffect;
|
2014-03-02 09:35:11 +01:00
|
|
|
import appeng.hooks.TickHandler;
|
2014-02-14 05:27:15 +01:00
|
|
|
import appeng.me.GridAccessException;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.parts.PartBasicState;
|
2014-02-14 05:27:15 +01:00
|
|
|
import appeng.server.ServerHelper;
|
|
|
|
import appeng.util.Platform;
|
|
|
|
import appeng.util.item.AEItemStack;
|
2014-02-07 06:51:19 +01:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-02-14 07:15:04 +01:00
|
|
|
public class PartAnnihilationPlane extends PartBasicState implements IGridTickable, Callable
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
public PartAnnihilationPlane(ItemStack is) {
|
|
|
|
super( PartAnnihilationPlane.class, is );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-07 06:51:19 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2013-12-27 23:59:59 +01:00
|
|
|
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
|
|
|
|
{
|
2014-04-04 06:31:10 +02:00
|
|
|
rh.setTexture( CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon(),
|
|
|
|
CableBusTextures.PartTransitionPlaneBack.getIcon(), is.getIconIndex(), CableBusTextures.PartPlaneSides.getIcon(),
|
|
|
|
CableBusTextures.PartPlaneSides.getIcon() );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
rh.setBounds( 1, 1, 15, 15, 15, 16 );
|
|
|
|
rh.renderInventoryBox( renderer );
|
|
|
|
|
|
|
|
rh.setBounds( 5, 5, 14, 11, 11, 15 );
|
|
|
|
rh.renderInventoryBox( renderer );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-07 06:51:19 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2013-12-27 23:59:59 +01:00
|
|
|
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
|
|
|
{
|
|
|
|
int minX = 1;
|
|
|
|
int minY = 1;
|
|
|
|
int maxX = 15;
|
|
|
|
int maxY = 15;
|
|
|
|
|
|
|
|
ForgeDirection e = rh.getWorldX();
|
|
|
|
ForgeDirection u = rh.getWorldY();
|
|
|
|
|
|
|
|
TileEntity te = getHost().getTile();
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
if ( isTransitionPlane( te.getWorldObj().getTileEntity( x - e.offsetX, y - e.offsetY, z - e.offsetZ ), side ) )
|
2013-12-27 23:59:59 +01:00
|
|
|
minX = 0;
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
if ( isTransitionPlane( te.getWorldObj().getTileEntity( x + e.offsetX, y + e.offsetY, z + e.offsetZ ), side ) )
|
2013-12-27 23:59:59 +01:00
|
|
|
maxX = 16;
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
if ( isTransitionPlane( te.getWorldObj().getTileEntity( x - u.offsetX, y - u.offsetY, z - u.offsetZ ), side ) )
|
2013-12-27 23:59:59 +01:00
|
|
|
minY = 0;
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
if ( isTransitionPlane( te.getWorldObj().getTileEntity( x + u.offsetX, y + u.offsetY, z + u.offsetZ ), side ) )
|
2013-12-27 23:59:59 +01:00
|
|
|
maxY = 16;
|
|
|
|
|
|
|
|
boolean isActive = (clientFlags & (POWERED_FLAG | CHANNEL_FLAG)) == (POWERED_FLAG | CHANNEL_FLAG);
|
|
|
|
|
2014-02-15 07:30:06 +01:00
|
|
|
renderCache = rh.useSimpliedRendering( x, y, z, this, renderCache );
|
2014-04-04 06:31:10 +02:00
|
|
|
rh.setTexture( CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon(),
|
2013-12-27 23:59:59 +01:00
|
|
|
CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockAnnihilationPlaneOn.getIcon() : is.getIconIndex(),
|
2014-04-04 06:31:10 +02:00
|
|
|
CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon() );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
rh.setBounds( minX, minY, 15, maxX, maxY, 16 );
|
|
|
|
rh.renderBlock( x, y, z, renderer );
|
|
|
|
|
|
|
|
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
|
|
|
CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockAnnihilationPlaneOn.getIcon() : is.getIconIndex(),
|
|
|
|
CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
|
|
|
|
|
|
|
rh.setBounds( 5, 5, 14, 11, 11, 15 );
|
|
|
|
rh.renderBlock( x, y, z, renderer );
|
|
|
|
|
|
|
|
renderLights( x, y, z, rh, renderer );
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean isTransitionPlane(TileEntity blockTileEntity, ForgeDirection side)
|
|
|
|
{
|
|
|
|
if ( blockTileEntity instanceof IPartHost )
|
|
|
|
{
|
|
|
|
IPart p = ((IPartHost) blockTileEntity).getPart( side );
|
|
|
|
return p instanceof PartAnnihilationPlane;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void getBoxes(IPartCollsionHelper bch)
|
|
|
|
{
|
|
|
|
int minX = 1;
|
|
|
|
int minY = 1;
|
|
|
|
int maxX = 15;
|
|
|
|
int maxY = 15;
|
|
|
|
|
2014-06-10 04:22:35 +02:00
|
|
|
IPartHost host = getHost();
|
|
|
|
if ( host != null )
|
|
|
|
{
|
|
|
|
TileEntity te = host.getTile();
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-06-10 04:22:35 +02:00
|
|
|
int x = te.xCoord;
|
|
|
|
int y = te.yCoord;
|
|
|
|
int z = te.zCoord;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-06-10 04:22:35 +02:00
|
|
|
ForgeDirection e = bch.getWorldX();
|
|
|
|
ForgeDirection u = bch.getWorldY();
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-06-10 04:22:35 +02:00
|
|
|
if ( isTransitionPlane( te.getWorldObj().getTileEntity( x - e.offsetX, y - e.offsetY, z - e.offsetZ ), side ) )
|
|
|
|
minX = 0;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-06-10 04:22:35 +02:00
|
|
|
if ( isTransitionPlane( te.getWorldObj().getTileEntity( x + e.offsetX, y + e.offsetY, z + e.offsetZ ), side ) )
|
|
|
|
maxX = 16;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-06-10 04:22:35 +02:00
|
|
|
if ( isTransitionPlane( te.getWorldObj().getTileEntity( x - u.offsetX, y - u.offsetY, z - u.offsetZ ), side ) )
|
|
|
|
minY = 0;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-06-10 04:22:35 +02:00
|
|
|
if ( isTransitionPlane( te.getWorldObj().getTileEntity( x + u.offsetX, y + u.offsetY, z + u.offsetZ ), side ) )
|
|
|
|
maxY = 16;
|
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
bch.addBox( 5, 5, 14, 11, 11, 15 );
|
2014-02-14 05:27:15 +01:00
|
|
|
bch.addBox( minX, minY, 15, maxX, maxY, bch.isBBCollision() ? 15 : 16 );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int cableConnectionRenderTo()
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-02-14 07:15:04 +01:00
|
|
|
boolean breaking = false;
|
2014-02-14 05:27:15 +01:00
|
|
|
LinkedList<IAEItemStack> Buffer = new LinkedList();
|
|
|
|
BaseActionSource mySrc = new MachineSource( this );
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void writeToNBT(NBTTagCompound data)
|
|
|
|
{
|
|
|
|
super.writeToNBT( data );
|
|
|
|
|
|
|
|
data.setInteger( "bufferSize", Buffer.size() );
|
|
|
|
for (int x = 0; x < Buffer.size(); x++)
|
|
|
|
{
|
|
|
|
NBTTagCompound pack = new NBTTagCompound();
|
|
|
|
Buffer.get( x ).writeToNBT( pack );
|
|
|
|
data.setTag( "buffer" + x, pack );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void readFromNBT(NBTTagCompound data)
|
|
|
|
{
|
|
|
|
super.readFromNBT( data );
|
|
|
|
|
|
|
|
int size = data.getInteger( "bufferSize" );
|
|
|
|
Buffer.clear();
|
|
|
|
for (int x = 0; x < size; x++)
|
|
|
|
{
|
|
|
|
NBTTagCompound pack = (NBTTagCompound) data.getTag( "buffer" + x );
|
|
|
|
IAEItemStack ais = AEItemStack.loadItemStackFromNBT( pack );
|
|
|
|
if ( ais != null )
|
|
|
|
Buffer.add( ais );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean isAccepting()
|
|
|
|
{
|
|
|
|
return Buffer.isEmpty();
|
|
|
|
}
|
|
|
|
|
2014-05-27 22:47:36 +02:00
|
|
|
@Override
|
|
|
|
public void getDrops(List<ItemStack> drops, boolean wrenched)
|
|
|
|
{
|
|
|
|
for (IAEItemStack is : Buffer)
|
|
|
|
if ( is != null )
|
|
|
|
drops.add( is.getItemStack() );
|
|
|
|
}
|
|
|
|
|
2014-02-14 07:15:04 +01:00
|
|
|
@MENetworkEventSubscribe
|
|
|
|
public void chanRender(MENetworkChannelsChanged c)
|
|
|
|
{
|
|
|
|
onNeighborChanged();
|
2014-05-03 21:25:37 +02:00
|
|
|
getHost().markForUpdate();
|
2014-02-14 07:15:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@MENetworkEventSubscribe
|
|
|
|
public void powerRender(MENetworkPowerStatusChange c)
|
|
|
|
{
|
|
|
|
onNeighborChanged();
|
2014-05-03 21:25:37 +02:00
|
|
|
getHost().markForUpdate();
|
2014-02-14 07:15:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public TickRateModulation EatBlock(boolean eatForReal)
|
2014-02-14 05:27:15 +01:00
|
|
|
{
|
|
|
|
if ( isAccepting() && proxy.isActive() )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
TileEntity te = getTile();
|
|
|
|
WorldServer w = (WorldServer) te.getWorldObj();
|
|
|
|
|
|
|
|
int x = te.xCoord + side.offsetX;
|
|
|
|
int y = te.yCoord + side.offsetY;
|
|
|
|
int z = te.zCoord + side.offsetZ;
|
|
|
|
|
|
|
|
Block blk = w.getBlock( x, y, z );
|
|
|
|
|
|
|
|
IStorageGrid storage = (IStorageGrid) proxy.getStorage();
|
|
|
|
IEnergyGrid energy = (IEnergyGrid) proxy.getEnergy();
|
|
|
|
|
|
|
|
Material mat = blk.getMaterial();
|
|
|
|
boolean ignore = mat == Material.air || mat == Material.lava || mat == Material.water || mat.isLiquid() || blk == Blocks.bedrock
|
|
|
|
|| blk == Blocks.end_portal || blk == Blocks.end_portal_frame || blk == Blocks.command_block;
|
|
|
|
|
|
|
|
if ( !ignore )
|
|
|
|
{
|
|
|
|
if ( !w.isAirBlock( x, y, z ) && w.blockExists( x, y, z ) && blk != null && w.canMineBlock( Platform.getPlayer( w ), x, y, z ) )
|
|
|
|
{
|
|
|
|
float hardness = blk.getBlockHardness( w, x, y, z );
|
|
|
|
if ( hardness >= 0.0 )
|
|
|
|
{
|
|
|
|
ItemStack[] out = Platform.getBlockDrops( w, x, y, z );
|
|
|
|
float total = 1 + hardness;
|
|
|
|
for (ItemStack is : out)
|
|
|
|
total += is.stackSize;
|
|
|
|
|
|
|
|
boolean hasPower = energy.extractAEPower( total, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > total - 0.1;
|
|
|
|
if ( hasPower )
|
|
|
|
{
|
2014-02-14 07:15:04 +01:00
|
|
|
if ( eatForReal )
|
2014-02-14 05:27:15 +01:00
|
|
|
{
|
2014-02-14 07:15:04 +01:00
|
|
|
energy.extractAEPower( total, Actionable.MODULATE, PowerMultiplier.CONFIG );
|
|
|
|
w.setBlock( x, y, z, Platform.air, 0, 3 );
|
|
|
|
|
2014-03-15 07:58:21 +01:00
|
|
|
AxisAlignedBB box = AxisAlignedBB.getBoundingBox( x - 0.2, y - 0.2, z - 0.2, x + 1.2, y + 1.2, z + 1.2 );
|
|
|
|
for (Object ei : w.getEntitiesWithinAABB( EntityItem.class, box ))
|
|
|
|
{
|
|
|
|
if ( ei instanceof EntityItem )
|
|
|
|
{
|
|
|
|
EntityItem item = (EntityItem) ei;
|
|
|
|
if ( !item.isDead )
|
|
|
|
{
|
|
|
|
IAEItemStack storedItem = AEItemStack.create( item.getEntityItem() );
|
|
|
|
storedItem = Platform.poweredInsert( energy, storage.getItemInventory(), storedItem, mySrc );
|
|
|
|
if ( storedItem != null )
|
|
|
|
Buffer.add( storedItem );
|
|
|
|
|
|
|
|
item.setDead();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-14 07:15:04 +01:00
|
|
|
try
|
|
|
|
{
|
|
|
|
ServerHelper.proxy.sendToAllNearExcept( null, x, y, z, 64, w, new PacketTransitionEffect( x, y, z, side, true ) );
|
|
|
|
}
|
|
|
|
catch (IOException e)
|
|
|
|
{
|
|
|
|
AELog.error( e );
|
|
|
|
}
|
|
|
|
|
2014-03-15 07:58:21 +01:00
|
|
|
for (ItemStack snaggedItem : out)
|
2014-02-14 07:15:04 +01:00
|
|
|
{
|
2014-03-15 07:58:21 +01:00
|
|
|
IAEItemStack storedItem = AEItemStack.create( snaggedItem );
|
2014-02-14 07:15:04 +01:00
|
|
|
storedItem = Platform.poweredInsert( energy, storage.getItemInventory(), storedItem, mySrc );
|
|
|
|
if ( storedItem != null )
|
|
|
|
Buffer.add( storedItem );
|
|
|
|
}
|
|
|
|
|
|
|
|
return TickRateModulation.URGENT;
|
2014-02-14 05:27:15 +01:00
|
|
|
}
|
2014-02-14 07:15:04 +01:00
|
|
|
else
|
2014-02-14 05:27:15 +01:00
|
|
|
{
|
2014-02-14 07:15:04 +01:00
|
|
|
breaking = true;
|
2014-07-08 06:54:28 +02:00
|
|
|
TickHandler.instance.addCallable( this.tile.getWorldObj(), this );
|
2014-02-14 07:15:04 +01:00
|
|
|
return TickRateModulation.URGENT;
|
2014-02-14 05:27:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (GridAccessException e1)
|
|
|
|
{
|
|
|
|
// :P
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// nothing to do here :)
|
|
|
|
return TickRateModulation.SLEEP;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TickingRequest getTickingRequest(IGridNode node)
|
|
|
|
{
|
2014-03-17 20:59:50 +01:00
|
|
|
return new TickingRequest( TickRates.AnnihilationPlane.min, TickRates.AnnihilationPlane.max, false, true );
|
2014-02-14 05:27:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onNeighborChanged()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
proxy.getTick().alertDevice( proxy.getNode() );
|
|
|
|
}
|
|
|
|
catch (GridAccessException e)
|
|
|
|
{
|
|
|
|
// :P
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onEntityCollision(Entity entity)
|
|
|
|
{
|
|
|
|
if ( entity instanceof EntityItem && !entity.isDead && isAccepting() )
|
|
|
|
{
|
|
|
|
boolean capture = false;
|
|
|
|
|
|
|
|
switch (side)
|
|
|
|
{
|
|
|
|
case DOWN:
|
|
|
|
case UP:
|
|
|
|
if ( entity.posX > tile.xCoord && entity.posX < tile.xCoord + 1 )
|
|
|
|
if ( entity.posZ > tile.zCoord && entity.posZ < tile.zCoord + 1 )
|
|
|
|
if ( (entity.posY > tile.yCoord + 0.9 && side == ForgeDirection.UP) || (entity.posY < tile.yCoord + 0.1 && side == ForgeDirection.DOWN) )
|
|
|
|
capture = true;
|
|
|
|
break;
|
|
|
|
case SOUTH:
|
|
|
|
case NORTH:
|
|
|
|
if ( entity.posX > tile.xCoord && entity.posX < tile.xCoord + 1 )
|
|
|
|
if ( entity.posY > tile.yCoord && entity.posY < tile.yCoord + 1 )
|
|
|
|
if ( (entity.posZ > tile.zCoord + 0.9 && side == ForgeDirection.SOUTH)
|
|
|
|
|| (entity.posZ < tile.zCoord + 0.1 && side == ForgeDirection.NORTH) )
|
|
|
|
capture = true;
|
|
|
|
break;
|
|
|
|
case EAST:
|
|
|
|
case WEST:
|
|
|
|
if ( entity.posZ > tile.zCoord && entity.posZ < tile.zCoord + 1 )
|
|
|
|
if ( entity.posY > tile.yCoord && entity.posY < tile.yCoord + 1 )
|
|
|
|
if ( (entity.posX > tile.xCoord + 0.9 && side == ForgeDirection.EAST)
|
|
|
|
|| (entity.posX < tile.xCoord + 0.1 && side == ForgeDirection.WEST) )
|
|
|
|
capture = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// umm?
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-02-14 07:25:49 +01:00
|
|
|
if ( capture && Platform.isServer() && proxy.isActive() )
|
2014-02-14 05:27:15 +01:00
|
|
|
{
|
|
|
|
IAEItemStack stack = AEItemStack.create( ((EntityItem) entity).getEntityItem() );
|
|
|
|
if ( stack != null )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
ServerHelper.proxy.sendToAllNearExcept( null, tile.xCoord, tile.yCoord, tile.zCoord, 64, tile.getWorldObj(),
|
|
|
|
new PacketTransitionEffect( entity.posX, entity.posY, entity.posZ, side, false ) );
|
|
|
|
}
|
|
|
|
catch (IOException e)
|
|
|
|
{
|
|
|
|
AELog.error( e );
|
|
|
|
}
|
|
|
|
|
|
|
|
Buffer.add( stack );
|
|
|
|
storeBuffer();
|
|
|
|
entity.setDead();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall)
|
|
|
|
{
|
2014-02-14 07:15:04 +01:00
|
|
|
if ( breaking )
|
|
|
|
return TickRateModulation.URGENT;
|
|
|
|
|
2014-02-14 05:27:15 +01:00
|
|
|
if ( isAccepting() )
|
2014-02-14 07:15:04 +01:00
|
|
|
return EatBlock( false );
|
2014-02-14 05:27:15 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
storeBuffer();
|
|
|
|
return TickRateModulation.IDLE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void storeBuffer()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
IStorageGrid storage = (IStorageGrid) proxy.getStorage();
|
|
|
|
IEnergyGrid energy = (IEnergyGrid) proxy.getEnergy();
|
|
|
|
|
|
|
|
while (!Buffer.isEmpty())
|
|
|
|
{
|
|
|
|
IAEItemStack storedItem = Buffer.pop();
|
|
|
|
storedItem = Platform.poweredInsert( energy, storage.getItemInventory(), storedItem, mySrc );
|
|
|
|
if ( storedItem != null )
|
|
|
|
{
|
|
|
|
Buffer.add( storedItem );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (GridAccessException e1)
|
|
|
|
{
|
|
|
|
// :P
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-14 07:15:04 +01:00
|
|
|
@Override
|
|
|
|
public Object call() throws Exception
|
|
|
|
{
|
|
|
|
breaking = false;
|
|
|
|
return EatBlock( true );
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|