From 6af11eb66cbab5394e821bb556d78e1afd2af0d2 Mon Sep 17 00:00:00 2001 From: Justin Aquadro Date: Sat, 2 Apr 2016 15:52:16 -0400 Subject: [PATCH] Attempt to place items directly in inventory, otherwise drop from front of drawer --- .../minecraft/storagedrawers/block/BlockDrawers.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/com/jaquadro/minecraft/storagedrawers/block/BlockDrawers.java b/src/com/jaquadro/minecraft/storagedrawers/block/BlockDrawers.java index abfff33..dc94ab7 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/block/BlockDrawers.java +++ b/src/com/jaquadro/minecraft/storagedrawers/block/BlockDrawers.java @@ -478,8 +478,11 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, (item == null) ? " null item" : " " + item.toString()); if (item != null && item.stackSize > 0) { - dropItemStack(world, x, y, z, player, item); - world.markBlockForUpdate(x, y, z); + if (!player.inventory.addItemStackToInventory(item)) { + ForgeDirection dir = ForgeDirection.getOrientation(side); + dropItemStack(world, x + dir.offsetX, y, z + dir.offsetZ, player, item); + world.markBlockForUpdate(x, y, z); + } } } @@ -528,7 +531,8 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH } private void dropItemStack (World world, int x, int y, int z, EntityPlayer player, ItemStack stack) { - EntityItem entity = new EntityItem(world, player.posX, player.posY, player.posZ, stack); + EntityItem entity = new EntityItem(world, x + .5f, y + .1f, z + .5f, stack); + entity.addVelocity(-entity.motionX, -entity.motionY, -entity.motionZ); world.spawnEntityInWorld(entity); }