net.minecraft.entity.player

## Class InventoryPlayer

- java.lang.Object
- - net.minecraft.entity.player.InventoryPlayer

- All Implemented Interfaces:
    IInventory

      public class InventoryPlayer
      extends Object
      implements IInventory

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `ItemStack[]` | `armorInventory` An array of 4 item stacks containing the currently worn armor pieces.
    `int` | `currentItem` The index of the currently held item (0-8).
    `boolean` | `inventoryChanged` Set true whenever the inventory changes.
    `ItemStack[]` | `mainInventory` An array of 36 item stacks indicating the main player inventory (including the visible bar).
    `EntityPlayer` | `player` The player whose inventory this is.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `InventoryPlayer(EntityPlayer par1EntityPlayer)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `addItemStackToInventory(ItemStack par1ItemStack)` Adds the item stack to the inventory, returns false if it is impossible.
    `ItemStack` | `armorItemInSlot(int par1)` returns a player armor item (as itemstack) contained in specified armor slot.
    `boolean` | `canHarvestBlock(Block par1Block)` Returns whether the current item (tool) can harvest from the specified block (actually get a result).
    `void` | `changeCurrentItem(int par1)`
    `int` | `clearInventory(int par1, int par2)` Clear this player's inventory, using the specified ID and metadata as filters or -1 for no filter.
    `void` | `closeChest()`
    `boolean` | `consumeInventoryItem(int par1)` removed one item of specified itemID from inventory (if it is in a stack, the stack size will reduce with 1)
    `void` | `copyInventory(InventoryPlayer par1InventoryPlayer)` Copy the ItemStack contents from another InventoryPlayer instance
    `void` | `damageArmor(float par1)` Damages armor in each slot by the specified amount.
    `void` | `decrementAnimations()` Decrement the number of animations remaining.
    `ItemStack` | `decrStackSize(int par1, int par2)` Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a new stack.
    `void` | `dropAllItems()` Drop all armor and main inventory items.
    `void` | `func_70439_a(Item par1Item, int par2)`
    `ItemStack` | `getCurrentItem()` Returns the item stack currently held by the player.
    `int` | `getFirstEmptyStack()` Returns the first item stack that is empty.
    `static int` | `getHotbarSize()` Get the size of the player hotbar inventory
    `int` | `getInventoryStackLimit()` Returns the maximum stack size for a inventory slot.
    `String` | `getInvName()` Returns the name of the inventory.
    `ItemStack` | `getItemStack()`
    `int` | `getSizeInventory()` Returns the number of slots in the inventory.
    `ItemStack` | `getStackInSlot(int par1)` Returns the stack in slot i
    `ItemStack` | `getStackInSlotOnClosing(int par1)` When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem - like when you close a workbench GUI.
    `float` | `getStrVsBlock(Block par1Block)` Gets the strength of the current item (tool) against the specified block, 1.0f if not holding anything.
    `int` | `getTotalArmorValue()` Based on the damage values and maximum damage values of each armor item, returns the current armor value.
    `boolean` | `hasItem(int par1)` Get if a specifiied item id is inside the inventory.
    `boolean` | `hasItemStack(ItemStack par1ItemStack)` Returns true if the specified ItemStack exists in the inventory.
    `boolean` | `isInvNameLocalized()` If this returns false, the inventory name will be used as an unlocalized name, and translated into the player's language.
    `boolean` | `isItemValidForSlot(int par1, ItemStack par2ItemStack)` Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot.
    `boolean` | `isUseableByPlayer(EntityPlayer par1EntityPlayer)` Do not make give this method the name canInteractWith because it clashes with Container
    `void` | `onInventoryChanged()` Called when an the contents of an Inventory change, usually
    `void` | `openChest()`
    `void` | `readFromNBT(NBTTagList par1NBTTagList)` Reads from the given tag list and fills the slots in the inventory with the correct items.
    `void` | `setCurrentItem(int par1, int par2, boolean par3, boolean par4)`
    `void` | `setInventorySlotContents(int par1, ItemStack par2ItemStack)` Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
    `void` | `setItemStack(ItemStack par1ItemStack)`
    `NBTTagList` | `writeToNBT(NBTTagList par1NBTTagList)` Writes the inventory out as a list of compound tags.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### mainInventory

          public ItemStack[] mainInventory

      An array of 36 item stacks indicating the main player inventory (including the visible bar).

    - #### armorInventory

          public ItemStack[] armorInventory

      An array of 4 item stacks containing the currently worn armor pieces.

    - #### currentItem

          public int currentItem

      The index of the currently held item (0-8).

    - #### player

          public EntityPlayer player

      The player whose inventory this is.

    - #### inventoryChanged

          public boolean inventoryChanged

      Set true whenever the inventory changes. Nothing sets it false so you will have to write your own code to check it and reset the value.

  - ### Constructor Detail

    - #### InventoryPlayer

          public InventoryPlayer(EntityPlayer par1EntityPlayer)

  - ### Method Detail

    - #### getCurrentItem

          public ItemStack getCurrentItem()

      Returns the item stack currently held by the player.

    - #### getHotbarSize

          public static int getHotbarSize()

      Get the size of the player hotbar inventory

    - #### getFirstEmptyStack

          public int getFirstEmptyStack()

      Returns the first item stack that is empty.

    - #### setCurrentItem

          public void setCurrentItem(int par1,
                            int par2,
                            boolean par3,
                            boolean par4)

    - #### changeCurrentItem

          public void changeCurrentItem(int par1)

    - #### clearInventory

          public int clearInventory(int par1,
                           int par2)

      Clear this player's inventory, using the specified ID and metadata as filters or -1 for no filter.

    - #### func_70439_a

          public void func_70439_a(Item par1Item,
                          int par2)

    - #### decrementAnimations

          public void decrementAnimations()

      Decrement the number of animations remaining. Only called on client side. This is used to handle the animation of receiving a block.

    - #### consumeInventoryItem

          public boolean consumeInventoryItem(int par1)

      removed one item of specified itemID from inventory (if it is in a stack, the stack size will reduce with 1)

    - #### hasItem

          public boolean hasItem(int par1)

      Get if a specifiied item id is inside the inventory.

    - #### addItemStackToInventory

          public boolean addItemStackToInventory(ItemStack par1ItemStack)

      Adds the item stack to the inventory, returns false if it is impossible.

    - #### decrStackSize

          public ItemStack decrStackSize(int par1,
                                int par2)

      Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a new stack.
      Specified by:
        `decrStackSize` in interface `IInventory`

    - #### getStackInSlotOnClosing

          public ItemStack getStackInSlotOnClosing(int par1)

      When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem - like when you close a workbench GUI.
      Specified by:
        `getStackInSlotOnClosing` in interface `IInventory`

    - #### setInventorySlotContents

          public void setInventorySlotContents(int par1,
                                      ItemStack par2ItemStack)

      Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
      Specified by:
        `setInventorySlotContents` in interface `IInventory`

    - #### getStrVsBlock

          public float getStrVsBlock(Block par1Block)

      Gets the strength of the current item (tool) against the specified block, 1.0f if not holding anything.

    - #### writeToNBT

          public NBTTagList writeToNBT(NBTTagList par1NBTTagList)

      Writes the inventory out as a list of compound tags. This is where the slot indices are used (+100 for armor, +80 for crafting).

    - #### readFromNBT

          public void readFromNBT(NBTTagList par1NBTTagList)

      Reads from the given tag list and fills the slots in the inventory with the correct items.

    - #### getSizeInventory

          public int getSizeInventory()

      Returns the number of slots in the inventory.
      Specified by:
        `getSizeInventory` in interface `IInventory`

    - #### getStackInSlot

          public ItemStack getStackInSlot(int par1)

      Returns the stack in slot i
      Specified by:
        `getStackInSlot` in interface `IInventory`

    - #### getInvName

          public String getInvName()

      Returns the name of the inventory.
      Specified by:
        `getInvName` in interface `IInventory`

    - #### isInvNameLocalized

          public boolean isInvNameLocalized()

      If this returns false, the inventory name will be used as an unlocalized name, and translated into the player's language. Otherwise it will be used directly.
      Specified by:
        `isInvNameLocalized` in interface `IInventory`

    - #### getInventoryStackLimit

          public int getInventoryStackLimit()

      Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. *Isn't this more of a set than a get?*
      Specified by:
        `getInventoryStackLimit` in interface `IInventory`

    - #### canHarvestBlock

          public boolean canHarvestBlock(Block par1Block)

      Returns whether the current item (tool) can harvest from the specified block (actually get a result).

    - #### armorItemInSlot

          public ItemStack armorItemInSlot(int par1)

      returns a player armor item (as itemstack) contained in specified armor slot.

    - #### getTotalArmorValue

          public int getTotalArmorValue()

      Based on the damage values and maximum damage values of each armor item, returns the current armor value.

    - #### damageArmor

          public void damageArmor(float par1)

      Damages armor in each slot by the specified amount.

    - #### dropAllItems

          public void dropAllItems()

      Drop all armor and main inventory items.

    - #### onInventoryChanged

          public void onInventoryChanged()

      Called when an the contents of an Inventory change, usually
      Specified by:
        `onInventoryChanged` in interface `IInventory`

    - #### setItemStack

          public void setItemStack(ItemStack par1ItemStack)

    - #### getItemStack

          public ItemStack getItemStack()

    - #### isUseableByPlayer

          public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)

      Do not make give this method the name canInteractWith because it clashes with Container
      Specified by:
        `isUseableByPlayer` in interface `IInventory`

    - #### hasItemStack

          public boolean hasItemStack(ItemStack par1ItemStack)

      Returns true if the specified ItemStack exists in the inventory.

    - #### openChest

          public void openChest()

      Specified by:
        `openChest` in interface `IInventory`

    - #### closeChest

          public void closeChest()

      Specified by:
        `closeChest` in interface `IInventory`

    - #### isItemValidForSlot

          public boolean isItemValidForSlot(int par1,
                                   ItemStack par2ItemStack)

      Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot.
      Specified by:
        `isItemValidForSlot` in interface `IInventory`

    - #### copyInventory

          public void copyInventory(InventoryPlayer par1InventoryPlayer)

      Copy the ItemStack contents from another InventoryPlayer instance