/// <summary> /// Callback for when the crafting gui is closed. /// </summary> public virtual void OnCraftGuiClosed(EntityPlayer par1EntityPlayer) { InventoryPlayer inventoryplayer = par1EntityPlayer.Inventory; if (inventoryplayer.GetItemStack() != null) { par1EntityPlayer.DropPlayerItem(inventoryplayer.GetItemStack()); inventoryplayer.SetItemStack(null); } }
public virtual ItemStack SlotClick(int par1, int par2, bool par3, EntityPlayer par4EntityPlayer) { ItemStack itemstack = null; if (par2 > 1) { return(null); } if (par2 == 0 || par2 == 1) { InventoryPlayer inventoryplayer = par4EntityPlayer.Inventory; if (par1 == -999) { if (inventoryplayer.GetItemStack() != null && par1 == -999) { if (par2 == 0) { par4EntityPlayer.DropPlayerItem(inventoryplayer.GetItemStack()); inventoryplayer.SetItemStack(null); } if (par2 == 1) { par4EntityPlayer.DropPlayerItem(inventoryplayer.GetItemStack().SplitStack(1)); if (inventoryplayer.GetItemStack().StackSize == 0) { inventoryplayer.SetItemStack(null); } } } } else if (par3) { ItemStack itemstack1 = TransferStackInSlot(par1); if (itemstack1 != null) { int i = itemstack1.ItemID; itemstack = itemstack1.Copy(); Slot slot1 = InventorySlots[par1]; if (slot1 != null && slot1.GetStack() != null && slot1.GetStack().ItemID == i) { RetrySlotClick(par1, par2, par3, par4EntityPlayer); } } } else { if (par1 < 0) { return(null); } Slot slot = InventorySlots[par1]; if (slot != null) { slot.OnSlotChanged(); ItemStack itemstack2 = slot.GetStack(); ItemStack itemstack4 = inventoryplayer.GetItemStack(); if (itemstack2 != null) { itemstack = itemstack2.Copy(); } if (itemstack2 == null) { if (itemstack4 != null && slot.IsItemValid(itemstack4)) { int j = par2 != 0 ? 1 : itemstack4.StackSize; if (j > slot.GetSlotStackLimit()) { j = slot.GetSlotStackLimit(); } slot.PutStack(itemstack4.SplitStack(j)); if (itemstack4.StackSize == 0) { inventoryplayer.SetItemStack(null); } } } else if (itemstack4 == null) { int k = par2 != 0 ? (itemstack2.StackSize + 1) / 2 : itemstack2.StackSize; ItemStack itemstack6 = slot.DecrStackSize(k); inventoryplayer.SetItemStack(itemstack6); if (itemstack2.StackSize == 0) { slot.PutStack(null); } slot.OnPickupFromSlot(inventoryplayer.GetItemStack()); } else if (slot.IsItemValid(itemstack4)) { if (itemstack2.ItemID != itemstack4.ItemID || itemstack2.GetHasSubtypes() && itemstack2.GetItemDamage() != itemstack4.GetItemDamage() || !ItemStack.Func_46154_a(itemstack2, itemstack4)) { if (itemstack4.StackSize <= slot.GetSlotStackLimit()) { ItemStack itemstack5 = itemstack2; slot.PutStack(itemstack4); inventoryplayer.SetItemStack(itemstack5); } } else { int l = par2 != 0 ? 1 : itemstack4.StackSize; if (l > slot.GetSlotStackLimit() - itemstack2.StackSize) { l = slot.GetSlotStackLimit() - itemstack2.StackSize; } if (l > itemstack4.GetMaxStackSize() - itemstack2.StackSize) { l = itemstack4.GetMaxStackSize() - itemstack2.StackSize; } itemstack4.SplitStack(l); if (itemstack4.StackSize == 0) { inventoryplayer.SetItemStack(null); } itemstack2.StackSize += l; } } else if (itemstack2.ItemID == itemstack4.ItemID && itemstack4.GetMaxStackSize() > 1 && (!itemstack2.GetHasSubtypes() || itemstack2.GetItemDamage() == itemstack4.GetItemDamage()) && ItemStack.Func_46154_a(itemstack2, itemstack4)) { int i1 = itemstack2.StackSize; if (i1 > 0 && i1 + itemstack4.StackSize <= itemstack4.GetMaxStackSize()) { itemstack4.StackSize += i1; ItemStack itemstack3 = slot.DecrStackSize(i1); if (itemstack3.StackSize == 0) { slot.PutStack(null); } slot.OnPickupFromSlot(inventoryplayer.GetItemStack()); } } } } } return(itemstack); }
protected override void HandleMouseClick(Slot par1Slot, int par2, int par3, bool par4) { if (par1Slot != null) { if (par1Slot.Inventory == Inventory) { InventoryPlayer inventoryplayer = Mc.ThePlayer.Inventory; ItemStack itemstack1 = inventoryplayer.GetItemStack(); ItemStack itemstack4 = par1Slot.GetStack(); if (itemstack1 != null && itemstack4 != null && itemstack1.ItemID == itemstack4.ItemID) { if (par3 == 0) { if (par4) { itemstack1.StackSize = itemstack1.GetMaxStackSize(); } else if (itemstack1.StackSize < itemstack1.GetMaxStackSize()) { itemstack1.StackSize++; } } else if (itemstack1.StackSize <= 1) { inventoryplayer.SetItemStack(null); } else { itemstack1.StackSize--; } } else if (itemstack1 != null) { inventoryplayer.SetItemStack(null); } else if (itemstack4 == null) { inventoryplayer.SetItemStack(null); } else if (itemstack1 == null || itemstack1.ItemID != itemstack4.ItemID) { inventoryplayer.SetItemStack(ItemStack.CopyItemStack(itemstack4)); ItemStack itemstack2 = inventoryplayer.GetItemStack(); if (par4) { itemstack2.StackSize = itemstack2.GetMaxStackSize(); } } } else { InventorySlots.SlotClick(par1Slot.SlotNumber, par3, par4, Mc.ThePlayer); ItemStack itemstack = InventorySlots.GetSlot(par1Slot.SlotNumber).GetStack(); Mc.PlayerController.SendSlotPacket(itemstack, (par1Slot.SlotNumber - InventorySlots.InventorySlots.Count) + 9 + 36); } } else { InventoryPlayer inventoryplayer1 = Mc.ThePlayer.Inventory; if (inventoryplayer1.GetItemStack() != null) { if (par3 == 0) { Mc.ThePlayer.DropPlayerItem(inventoryplayer1.GetItemStack()); Mc.PlayerController.Func_35639_a(inventoryplayer1.GetItemStack()); inventoryplayer1.SetItemStack(null); } if (par3 == 1) { ItemStack itemstack3 = inventoryplayer1.GetItemStack().SplitStack(1); Mc.ThePlayer.DropPlayerItem(itemstack3); Mc.PlayerController.Func_35639_a(itemstack3); if (inventoryplayer1.GetItemStack().StackSize == 0) { inventoryplayer1.SetItemStack(null); } } } } }
/// <summary> /// Draws the screen and all the components in it. /// </summary> public override void DrawScreen(int par1, int par2, float par3) { DrawDefaultBackground(); int i = GuiLeft; int j = GuiTop; DrawGuiContainerBackgroundLayer(par3, par1, par2); RenderHelper.EnableGUIStandardItemLighting(); //GL.PushMatrix(); //GL.Translate(i, j, 0.0F); //GL.Color4(1.0F, 1.0F, 1.0F, 1.0F); //GL.Enable(EnableCap.RescaleNormal); Slot slot = null; int k = 240; int i1 = 240; OpenGlHelper.SetLightmapTextureCoords(OpenGlHelper.LightmapTexUnit, (float)k / 1.0F, (float)i1 / 1.0F); //GL.Color4(1.0F, 1.0F, 1.0F, 1.0F); for (int l = 0; l < InventorySlots.InventorySlots.Count; l++) { Slot slot1 = (Slot)InventorySlots.InventorySlots[l]; DrawSlotInventory(slot1); if (IsMouseOverSlot(slot1, par1, par2)) { slot = slot1; //GL.Disable(EnableCap.Lighting); //GL.Disable(EnableCap.DepthTest); int j1 = slot1.XDisplayPosition; int k1 = slot1.YDisplayPosition; DrawGradientRect(j1, k1, j1 + 16, k1 + 16, 0x80fffff, 0x80fffff); //GL.Enable(EnableCap.Lighting); //GL.Enable(EnableCap.DepthTest); } } DrawGuiContainerForegroundLayer(); InventoryPlayer inventoryplayer = Mc.ThePlayer.Inventory; if (inventoryplayer.GetItemStack() != null) { //GL.Translate(0.0F, 0.0F, 32F); ZLevel = 200F; ItemRenderer.ZLevel = 200F; ItemRenderer.RenderItemIntoGUI(FontRenderer, Mc.RenderEngineOld, inventoryplayer.GetItemStack(), par1 - i - 8, par2 - j - 8); ItemRenderer.RenderItemOverlayIntoGUI(FontRenderer, Mc.RenderEngineOld, inventoryplayer.GetItemStack(), par1 - i - 8, par2 - j - 8); ZLevel = 0.0F; ItemRenderer.ZLevel = 0.0F; } //GL.Disable(EnableCap.RescaleNormal); RenderHelper.DisableStandardItemLighting(); //GL.Disable(EnableCap.Lighting); //GL.Disable(EnableCap.DepthTest); if (inventoryplayer.GetItemStack() == null && slot != null && slot.GetHasStack()) { ItemStack itemstack = slot.GetStack(); List <string> list = itemstack.GetItemNameandInformation(); if (list.Count > 0) { int l1 = 0; for (int i2 = 0; i2 < list.Count; i2++) { int k2 = FontRenderer.GetStringWidth(list[i2]); if (k2 > l1) { l1 = k2; } } int j2 = (par1 - i) + 12; int l2 = par2 - j - 12; int i3 = l1; int j3 = 8; if (list.Count > 1) { j3 += 2 + (list.Count - 1) * 10; } ZLevel = 300F; ItemRenderer.ZLevel = 300F; int k3 = 0xf010001; DrawGradientRect(j2 - 3, l2 - 4, j2 + i3 + 3, l2 - 3, k3, k3); DrawGradientRect(j2 - 3, l2 + j3 + 3, j2 + i3 + 3, l2 + j3 + 4, k3, k3); DrawGradientRect(j2 - 3, l2 - 3, j2 + i3 + 3, l2 + j3 + 3, k3, k3); DrawGradientRect(j2 - 4, l2 - 3, j2 - 3, l2 + j3 + 3, k3, k3); DrawGradientRect(j2 + i3 + 3, l2 - 3, j2 + i3 + 4, l2 + j3 + 3, k3, k3); int l3 = 0x505000ff; int i4 = (l3 & 0xfefefe) >> 1 | l3 & 0xff00000; DrawGradientRect(j2 - 3, (l2 - 3) + 1, (j2 - 3) + 1, (l2 + j3 + 3) - 1, l3, i4); DrawGradientRect(j2 + i3 + 2, (l2 - 3) + 1, j2 + i3 + 3, (l2 + j3 + 3) - 1, l3, i4); DrawGradientRect(j2 - 3, l2 - 3, j2 + i3 + 3, (l2 - 3) + 1, l3, l3); DrawGradientRect(j2 - 3, l2 + j3 + 2, j2 + i3 + 3, l2 + j3 + 3, i4, i4); for (int j4 = 0; j4 < list.Count; j4++) { string s = list[j4]; if (j4 == 0) { //s = (new StringBuilder()).Append((char)0xa7).Append(int.ToHexString(itemstack.GetRarity().NameColor)).Append(s).ToString(); } else { s = (new StringBuilder()).Append((char)0xa7).Append(s).ToString(); } FontRenderer.DrawStringWithShadow(s, j2, l2, -1); if (j4 == 0) { l2 += 2; } l2 += 10; } ZLevel = 0.0F; ItemRenderer.ZLevel = 0.0F; } } //GL.PopMatrix(); base.DrawScreen(par1, par2, par3); //GL.Enable(EnableCap.Lighting); //GL.Enable(EnableCap.DepthTest); }