public virtual void OnCraftGuiClosed(net.minecraft.src.EntityPlayer entityplayer) { net.minecraft.src.InventoryPlayer inventoryplayer = entityplayer.inventory; if (inventoryplayer.GetItemStack() != null) { entityplayer.DropPlayerItem(inventoryplayer.GetItemStack()); inventoryplayer.SetItemStack(null); } }
public virtual net.minecraft.src.ItemStack Func_27085_a(int i, int j, bool flag, net.minecraft.src.EntityPlayer entityplayer) { net.minecraft.src.ItemStack itemstack = null; if (j == 0 || j == 1) { net.minecraft.src.InventoryPlayer inventoryplayer = entityplayer.inventory; if (i == -999) { if (inventoryplayer.GetItemStack() != null && i == -999) { if (j == 0) { entityplayer.DropPlayerItem(inventoryplayer.GetItemStack()); inventoryplayer.SetItemStack(null); } if (j == 1) { entityplayer.DropPlayerItem(inventoryplayer.GetItemStack().SplitStack(1)); if (inventoryplayer.GetItemStack().stackSize == 0) { inventoryplayer.SetItemStack(null); } } } } else { if (flag) { net.minecraft.src.ItemStack itemstack1 = Func_27086_a(i); if (itemstack1 != null) { int k = itemstack1.stackSize; itemstack = itemstack1.Copy(); net.minecraft.src.Slot slot1 = (net.minecraft.src.Slot)inventorySlots[i]; if (slot1 != null && slot1.GetStack() != null) { int l = slot1.GetStack().stackSize; if (l < k) { Func_27085_a(i, j, flag, entityplayer); } } } } else { net.minecraft.src.Slot slot = (net.minecraft.src.Slot)inventorySlots[i]; if (slot != null) { slot.OnSlotChanged(); net.minecraft.src.ItemStack itemstack2 = slot.GetStack(); net.minecraft.src.ItemStack itemstack3 = inventoryplayer.GetItemStack(); if (itemstack2 != null) { itemstack = itemstack2.Copy(); } if (itemstack2 == null) { if (itemstack3 != null && slot.IsItemValid(itemstack3)) { int i1 = j != 0 ? 1 : itemstack3.stackSize; if (i1 > slot.GetSlotStackLimit()) { i1 = slot.GetSlotStackLimit(); } slot.PutStack(itemstack3.SplitStack(i1)); if (itemstack3.stackSize == 0) { inventoryplayer.SetItemStack(null); } } } else { if (itemstack3 == null) { int j1 = j != 0 ? (itemstack2.stackSize + 1) / 2 : itemstack2.stackSize; net.minecraft.src.ItemStack itemstack5 = slot.DecrStackSize(j1); inventoryplayer.SetItemStack(itemstack5); if (itemstack2.stackSize == 0) { slot.PutStack(null); } slot.OnPickupFromSlot(inventoryplayer.GetItemStack()); } else { if (slot.IsItemValid(itemstack3)) { if (itemstack2.itemID != itemstack3.itemID || itemstack2.GetHasSubtypes() && itemstack2 .GetItemDamage() != itemstack3.GetItemDamage()) { if (itemstack3.stackSize <= slot.GetSlotStackLimit()) { net.minecraft.src.ItemStack itemstack4 = itemstack2; slot.PutStack(itemstack3); inventoryplayer.SetItemStack(itemstack4); } } else { int k1 = j != 0 ? 1 : itemstack3.stackSize; if (k1 > slot.GetSlotStackLimit() - itemstack2.stackSize) { k1 = slot.GetSlotStackLimit() - itemstack2.stackSize; } if (k1 > itemstack3.GetMaxStackSize() - itemstack2.stackSize) { k1 = itemstack3.GetMaxStackSize() - itemstack2.stackSize; } itemstack3.SplitStack(k1); if (itemstack3.stackSize == 0) { inventoryplayer.SetItemStack(null); } itemstack2.stackSize += k1; } } else { if (itemstack2.itemID == itemstack3.itemID && itemstack3.GetMaxStackSize() > 1 && (!itemstack2.GetHasSubtypes() || itemstack2.GetItemDamage() == itemstack3.GetItemDamage ())) { int l1 = itemstack2.stackSize; if (l1 > 0 && l1 + itemstack3.stackSize <= itemstack3.GetMaxStackSize()) { itemstack3.stackSize += l1; itemstack2.SplitStack(l1); if (itemstack2.stackSize == 0) { slot.PutStack(null); } slot.OnPickupFromSlot(inventoryplayer.GetItemStack()); } } } } } } } } } return(itemstack); }