@Override public ItemStack decrStackSize (int slot, int amount) { if (contents[slot] != null) { ItemStack ret; if (contents[slot].stackSize <= amount) { //not enough items ret = contents[slot]; contents[slot] = null; } else { //enough items ret = contents[slot].splitStack(amount); if (contents[slot].stackSize == 0) contents[slot] = null; } this.markDirty(); return ret; } return null; }