protected boolean a(ItemStack itemstack, int i, int j, boolean flag) { boolean flag1 = false; int k = i; if (flag) { k = j - 1; } Slot slot; ItemStack itemstack1; if (itemstack.isStackable()) { while (itemstack.count > 0 && (!flag && k < j || flag && k >= i)) { slot = (Slot) this.c.get(k); itemstack1 = slot.getItem(); if (itemstack1 != null && itemstack1.id == itemstack.id && (!itemstack.usesData() || itemstack.getData() == itemstack1.getData()) && ItemStack.equals(itemstack, itemstack1)) { int l = itemstack1.count + itemstack.count; if (l <= itemstack.getMaxStackSize()) { itemstack.count = 0; itemstack1.count = l; slot.e(); flag1 = true; } else if (itemstack1.count < itemstack.getMaxStackSize()) { itemstack.count -= itemstack.getMaxStackSize() - itemstack1.count; itemstack1.count = itemstack.getMaxStackSize(); slot.e(); flag1 = true; } } if (flag) { --k; } else { ++k; } } } if (itemstack.count > 0) { if (flag) { k = j - 1; } else { k = i; } while (!flag && k < j || flag && k >= i) { slot = (Slot) this.c.get(k); itemstack1 = slot.getItem(); if (itemstack1 == null) { slot.set(itemstack.cloneItemStack()); slot.e(); itemstack.count = 0; flag1 = true; break; } if (flag) { --k; } else { ++k; } } } return flag1; }