From cdcba63c2d35560392ab1977a3add9715f37d9af 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 1cc6e836..944ea415 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 ); @@ -358,7 +358,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, AEPartLocation side ) @@ -542,7 +571,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 ); } } }