protected internal virtual void Func_28126_a(net.minecraft.src.ItemStack itemstack , int i, int j, bool flag) { int k = i; if (flag) { k = j - 1; } if (itemstack.Func_21132_c()) { while (itemstack.stackSize > 0 && (!flag && k < j || flag && k >= i)) { net.minecraft.src.Slot slot = (net.minecraft.src.Slot)inventorySlots[k]; net.minecraft.src.ItemStack itemstack1 = slot.GetStack(); if (itemstack1 != null && itemstack1.itemID == itemstack.itemID && (!itemstack.GetHasSubtypes () || itemstack.GetItemDamage() == itemstack1.GetItemDamage())) { int i1 = itemstack1.stackSize + itemstack.stackSize; if (i1 <= itemstack.GetMaxStackSize()) { itemstack.stackSize = 0; itemstack1.stackSize = i1; slot.OnSlotChanged(); } else { if (itemstack1.stackSize < itemstack.GetMaxStackSize()) { itemstack.stackSize -= itemstack.GetMaxStackSize() - itemstack1.stackSize; itemstack1.stackSize = itemstack.GetMaxStackSize(); slot.OnSlotChanged(); } } } if (flag) { k--; } else { k++; } } } if (itemstack.stackSize > 0) { int l; if (flag) { l = j - 1; } else { l = i; } do { if ((flag || l >= j) && (!flag || l < i)) { break; } net.minecraft.src.Slot slot1 = (net.minecraft.src.Slot)inventorySlots[l]; net.minecraft.src.ItemStack itemstack2 = slot1.GetStack(); if (itemstack2 == null) { slot1.PutStack(itemstack.Copy()); slot1.OnSlotChanged(); itemstack.stackSize = 0; break; } if (flag) { l--; } else { l++; } }while (true); } }