public virtual void onCraftGuiClosed(EntityPlayer entityplayer) { InventoryPlayer inventoryplayer = entityplayer.inventory; if (inventoryplayer.getItemStack() != null) { entityplayer.dropPlayerItem(inventoryplayer.getItemStack()); inventoryplayer.setItemStack(null); } }
public EntityPlayer(World world) : base(world) { inventory = new InventoryPlayer(this); field_9152_am = 0; score = 0; isSwinging = false; swingProgressInt = 0; damageRemainder = 0; fishEntity = null; personalCraftingInventory = new CraftingInventoryPlayerCB(inventory, !world.singleplayerWorld); currentCraftingInventory = personalCraftingInventory; yOffset = 1.62F; ChunkCoordinates chunkcoordinates = world.func_22078_l(); setLocationAndAngles(chunkcoordinates.posX + 0.5D, chunkcoordinates.posY + 1, chunkcoordinates.posZ + 0.5D, 0.0F, 0.0F); health = 20; entityType = "humanoid"; field_9117_aI = 180F; fireResistance = 20; texture = "/mob/char.png"; }
public ItemStack placeItem(int i, int j, EntityPlayer entityplayer) { ItemStack itemstack = null; if (j == 0 || j == 1) { 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 { var slot = (Slot)inventorySlots.get(i); if (slot != null) { slot.onSlotChanged(); ItemStack itemstack1 = slot.getStack(); ItemStack itemstack2 = inventoryplayer.getItemStack(); if (itemstack1 != null) { itemstack = itemstack1.copy(); } if (itemstack1 == null) { if (itemstack2 != null && slot.isItemValid(itemstack2)) { int k = j != 0 ? 1 : itemstack2.stackSize; if (k > slot.getSlotStackLimit()) { k = slot.getSlotStackLimit(); } slot.putStack(itemstack2.splitStack(k)); if (itemstack2.stackSize == 0) { inventoryplayer.setItemStack(null); } } } else if (itemstack2 == null) { int l = j != 0 ? (itemstack1.stackSize + 1) / 2 : itemstack1.stackSize; inventoryplayer.setItemStack(slot.decrStackSize(l)); if (itemstack1.stackSize == 0) { slot.putStack(null); } slot.onPickupFromSlot(); } else if (slot.isItemValid(itemstack2)) { if (itemstack1.itemID != itemstack2.itemID || itemstack1.getHasSubtypes() && itemstack1.getItemDamage() != itemstack2.getItemDamage()) { if (itemstack2.stackSize <= slot.getSlotStackLimit()) { ItemStack itemstack3 = itemstack1; slot.putStack(itemstack2); inventoryplayer.setItemStack(itemstack3); } } else { int i1 = j != 0 ? 1 : itemstack2.stackSize; if (i1 > slot.getSlotStackLimit() - itemstack1.stackSize) { i1 = slot.getSlotStackLimit() - itemstack1.stackSize; } if (i1 > itemstack2.getMaxStackSize() - itemstack1.stackSize) { i1 = itemstack2.getMaxStackSize() - itemstack1.stackSize; } itemstack2.splitStack(i1); if (itemstack2.stackSize == 0) { inventoryplayer.setItemStack(null); } itemstack1.stackSize += i1; } } else if (itemstack1.itemID == itemstack2.itemID && itemstack2.getMaxStackSize() > 1 && (!itemstack1.getHasSubtypes() || itemstack1.getItemDamage() == itemstack2.getItemDamage())) { int j1 = itemstack1.stackSize; if (j1 > 0 && j1 + itemstack2.stackSize <= itemstack2.getMaxStackSize()) { itemstack2.stackSize += j1; itemstack1.splitStack(j1); if (itemstack1.stackSize == 0) { slot.putStack(null); } slot.onPickupFromSlot(); } } } } } return(itemstack); }