int y = te.yCoord + side.offsetY;
int z = te.zCoord + side.offsetZ;
Block blk = w.getBlock( x, y, z );
IStorageGrid storage = proxy.getStorage();
IEnergyGrid energy = 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 ) && 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 )
{
if ( eatForReal )
{
energy.extractAEPower( total, Actionable.MODULATE, PowerMultiplier.CONFIG );
w.setBlock( x, y, z, Platform.air, 0, 3 );
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();
}
}
}
ServerHelper.proxy.sendToAllNearExcept( null, x, y, z, 64, w, new PacketTransitionEffect( x, y, z, side, true ) );
for (ItemStack snaggedItem : out)
{
IAEItemStack storedItem = AEItemStack.create( snaggedItem );
storedItem = Platform.poweredInsert( energy, storage.getItemInventory(), storedItem, mySrc );
if ( storedItem != null )
Buffer.add( storedItem );
}
return TickRateModulation.URGENT;