From 74302fc91f16d48fbdbaf20b2446242cbf6b4928 Mon Sep 17 00:00:00 2001 From: simeonradivoev Date: Mon, 6 Apr 2015 11:04:48 +0300 Subject: [PATCH] Fixed stack splitting. --- .../MO/MatterOverdrive/data/Inventory.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/MO/MatterOverdrive/data/Inventory.java b/src/main/java/com/MO/MatterOverdrive/data/Inventory.java index 69e6c32b..cb6f9372 100644 --- a/src/main/java/com/MO/MatterOverdrive/data/Inventory.java +++ b/src/main/java/com/MO/MatterOverdrive/data/Inventory.java @@ -107,29 +107,35 @@ public ItemStack getStackInSlot(int slot) @Override public ItemStack decrStackSize(int slot, int size) { - if(this.slots.get(slot) != null) + if (this.slots.get(slot) != null && this.slots.get(slot).getItem() != null) { ItemStack itemstack; - if(this.slots.get(slot).getItem().stackSize <= size) + if (this.slots.get(slot).getItem().stackSize <= size) { itemstack = this.slots.get(slot).getItem(); this.slots.get(slot).setItem(null); + + entity.updateContainingBlockInfo(); return itemstack; - }else + } + else { - this.slots.get(slot).getItem().splitStack(size); + itemstack = this.slots.get(slot).getItem().splitStack(size); - if(this.slots.get(slot).getItem().stackSize == 0) + if (this.slots.get(slot).getItem().stackSize == 0) { this.slots.get(slot).setItem(null); } + + entity.updateContainingBlockInfo(); + return itemstack; } } - - entity.updateContainingBlockInfo(); - - return null; + else + { + return null; + } } @Override