diff --git a/src/main/java/appeng/parts/automation/PartAnnihilationPlane.java b/src/main/java/appeng/parts/automation/PartAnnihilationPlane.java index 4cef94dac11..1011c9ef390 100644 --- a/src/main/java/appeng/parts/automation/PartAnnihilationPlane.java +++ b/src/main/java/appeng/parts/automation/PartAnnihilationPlane.java @@ -56,8 +56,10 @@ import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.server.MinecraftServer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.IIcon; @@ -79,6 +81,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab private static final int MAX_CACHE_TIME = 60; private final BaseActionSource mySrc = new MachineSource( this ); + private EntityPlayer owner = null; private boolean isAccepting = true; private boolean breaking = false; private YesNo permissionCache = YesNo.UNDECIDED; @@ -89,6 +92,13 @@ public PartAnnihilationPlane( final ItemStack is ) super( is ); } + @Override + public void onPlacement( EntityPlayer player, ItemStack held, ForgeDirection side ) + { + super.onPlacement( player, held, side ); + this.owner = player; + } + @Override public TickRateModulation call( final World world ) throws Exception { @@ -500,13 +510,14 @@ private boolean canHandleBlock( final WorldServer w, final int x, final int y, f final float hardness = block.getBlockHardness( w, x, y, z ); final boolean ignoreMaterials = material == Material.air || material == Material.lava || material == Material.water || material.isLiquid(); final boolean ignoreBlocks = block == Blocks.bedrock || block == Blocks.end_portal || block == Blocks.end_portal_frame || block == Blocks.command_block; + final EntityPlayer player = owner == null ? Platform.getPlayer( w ) : owner; if( permissionCache == YesNo.UNDECIDED ) { - BlockEvent.BreakEvent event = new BlockEvent.BreakEvent( x, y, z, w, block, w.getBlockMetadata( x, y, z ), Platform.getPlayer( w ) ); + BlockEvent.BreakEvent event = new BlockEvent.BreakEvent( x, y, z, w, block, w.getBlockMetadata( x, y, z ), player ); MinecraftForge.EVENT_BUS.post( event ); permissionCache = ( event.isCanceled() ) ? YesNo.NO : YesNo.YES; } - return permissionCache == YesNo.YES && !ignoreMaterials && !ignoreBlocks && !w.isAirBlock( x, y, z ) && w.blockExists( x, y, z ) && w.canMineBlock( Platform.getPlayer( w ), x, y, z ) && hardness >= 0f; + return permissionCache == YesNo.YES && !ignoreMaterials && !ignoreBlocks && !w.isAirBlock( x, y, z ) && w.blockExists( x, y, z ) && w.canMineBlock( player , x, y, z ) && hardness >= 0f; } protected List obtainBlockDrops( final WorldServer w, final int x, final int y, final int z ) diff --git a/src/main/java/appeng/parts/automation/PartFormationPlane.java b/src/main/java/appeng/parts/automation/PartFormationPlane.java index 799eeff1b23..dca450b2220 100644 --- a/src/main/java/appeng/parts/automation/PartFormationPlane.java +++ b/src/main/java/appeng/parts/automation/PartFormationPlane.java @@ -74,10 +74,10 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine { private final MEInventoryHandler myHandler = new MEInventoryHandler( this, StorageChannel.ITEMS ); private final AppEngInternalAEInventory Config = new AppEngInternalAEInventory( this, 63 ); + private EntityPlayer owner = null; private int priority = 0; private boolean wasActive = false; private boolean blocked = false; - public PartFormationPlane( final ItemStack is ) { super( is ); @@ -87,6 +87,13 @@ public PartFormationPlane( final ItemStack is ) this.updateHandler(); } + @Override + public void onPlacement( EntityPlayer player, ItemStack held, ForgeDirection side ) + { + super.onPlacement( player, held, side ); + this.owner = player; + } + private void updateHandler() { this.myHandler.setBaseAccess( AccessRestriction.WRITE ); @@ -472,7 +479,7 @@ public IAEItemStack injectItems( final IAEItemStack input, final Actionable type { player.setCurrentItemOrArmor( 0, is.copy() ); BlockSnapshot blockSnapshot = new BlockSnapshot( w, x, y, z, ( (ItemBlock) i ).field_150939_a, i.getMetadata( is.getItemDamage() ) ); - BlockEvent.PlaceEvent event = new BlockEvent.PlaceEvent( blockSnapshot, w.getBlock( x, y, z ), player ); + BlockEvent.PlaceEvent event = new BlockEvent.PlaceEvent( blockSnapshot, w.getBlock( x, y, z ), owner == null ? player : owner ); MinecraftForge.EVENT_BUS.post( event ); if( !event.isCanceled() ) {