From 26f13d41092299681d634ce8f66973207c632a5e Mon Sep 17 00:00:00 2001 From: yueh Date: Tue, 8 Sep 2015 22:56:22 +0200 Subject: [PATCH] Fixes #1865: Spawn overflow items into the world --- .../automation/PartAnnihilationPlane.java | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/main/java/appeng/parts/automation/PartAnnihilationPlane.java b/src/main/java/appeng/parts/automation/PartAnnihilationPlane.java index f6d7eaa1..d56af452 100644 --- a/src/main/java/appeng/parts/automation/PartAnnihilationPlane.java +++ b/src/main/java/appeng/parts/automation/PartAnnihilationPlane.java @@ -87,7 +87,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab } @Override - public TickRateModulation call(World world) throws Exception + public TickRateModulation call( World world ) throws Exception { this.breaking = false; return this.breakBlock( true ); @@ -359,7 +359,36 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab entityItem.getEntityItem().stackSize = newStackSize; return changed; + } + /** + * Spawns an overflow item as new {@link EntityItem} into the {@link World} + * + * @param w the world to spawn it + * @param x x coordinate + * @param y y coordinate + * @param z coordinate + * @param overflow the item to spawn + */ + private void spawnOverflow( IAEItemStack overflow ) + { + if( overflow == null ) + { + return; + } + + final TileEntity te = this.getTile(); + final WorldServer w = (WorldServer) te.getWorldObj(); + final double x = te.xCoord + this.side.offsetX + .5d; + final double y = te.yCoord + this.side.offsetY + .5d; + final double z = te.zCoord + this.side.offsetZ + .5d; + + final EntityItem overflowEntity = new EntityItem( w, x, y, z, overflow.getItemStack() ); + overflowEntity.motionX = 0; + overflowEntity.motionY = 0; + overflowEntity.motionZ = 0; + + w.spawnEntityInWorld( overflowEntity ); } protected boolean isAnnihilationPlane( TileEntity blockTileEntity, ForgeDirection side ) @@ -545,7 +574,8 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab for( final ItemStack snaggedItem : items ) { - this.storeItemStack( snaggedItem ); + final IAEItemStack overflow = this.storeItemStack( snaggedItem ); + this.spawnOverflow( overflow ); } } }