public class InventoryPlayer extends java.lang.Object implements IInventory
| Modifier and Type | Field and Description | 
|---|---|
NonNullList<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. 
 | 
NonNullList<ItemStack> | 
mainInventory
An array of 36 item stacks indicating the main player inventory (including the visible bar). 
 | 
NonNullList<ItemStack> | 
offHandInventory  | 
EntityPlayer | 
player
The player whose inventory this is. 
 | 
| Constructor and Description | 
|---|
InventoryPlayer(EntityPlayer playerIn)  | 
| Modifier and Type | Method and Description | 
|---|---|
boolean | 
addItemStackToInventory(ItemStack itemStackIn)
Adds the item stack to the inventory, returns false if it is impossible. 
 | 
ItemStack | 
armorItemInSlot(int slotIn)
returns a player armor item (as itemstack) contained in specified armor slot. 
 | 
boolean | 
canHarvestBlock(IBlockState state)  | 
void | 
changeCurrentItem(int direction)
Switch the current item to the next one or the previous one 
 | 
void | 
clear()  | 
int | 
clearMatchingItems(Item itemIn,
                  int metadataIn,
                  int removeCount,
                  NBTTagCompound itemNBT)
Removes matching items from the inventory. 
 | 
void | 
closeInventory(EntityPlayer player)  | 
void | 
copyInventory(InventoryPlayer playerInventory)
Copy the ItemStack contents from another InventoryPlayer instance 
 | 
void | 
damageArmor(float damage)
Damages armor in each slot by the specified amount. 
 | 
void | 
decrementAnimations()
Decrement the number of animations remaining. 
 | 
ItemStack | 
decrStackSize(int index,
             int count)
Removes up to a specified number of items from an inventory slot and returns them in a new stack. 
 | 
void | 
deleteStack(ItemStack stack)  | 
void | 
dropAllItems()
Drop all armor and main inventory items. 
 | 
int | 
getBestHotbarSlot()  | 
ItemStack | 
getCurrentItem()
Returns the item stack currently held by the player. 
 | 
ITextComponent | 
getDisplayName()
Get the formatted ChatComponent that will be used for the sender's username in chat 
 | 
int | 
getField(int id)  | 
int | 
getFieldCount()  | 
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. 
 | 
ItemStack | 
getItemStack()
Stack helds by mouse, used in GUI and Containers 
 | 
java.lang.String | 
getName()
Get the name of this object. 
 | 
int | 
getSizeInventory()
Returns the number of slots in the inventory. 
 | 
int | 
getSlotFor(ItemStack stack)
Finds the stack or an equivalent one in the main inventory 
 | 
ItemStack | 
getStackInSlot(int index)
Returns the stack in the given slot. 
 | 
float | 
getStrVsBlock(IBlockState state)  | 
boolean | 
hasCustomName()
Returns true if this thing is named 
 | 
boolean | 
hasItemStack(ItemStack itemStackIn)
Returns true if the specified ItemStack exists in the inventory. 
 | 
boolean | 
isEmpty()  | 
static boolean | 
isHotbar(int index)  | 
boolean | 
isItemValidForSlot(int index,
                  ItemStack stack)
Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot. 
 | 
boolean | 
isUsableByPlayer(EntityPlayer player)
Don't rename this method to canInteractWith due to conflicts with Container 
 | 
void | 
markDirty()
For tile entities, ensures the chunk containing the tile entity is saved to disk later - the game won't think it
 hasn't changed and skip it. 
 | 
void | 
openInventory(EntityPlayer player)  | 
void | 
pickItem(int index)  | 
void | 
readFromNBT(NBTTagList nbtTagListIn)
Reads from the given tag list and fills the slots in the inventory with the correct items. 
 | 
ItemStack | 
removeStackFromSlot(int index)
Removes a stack from the given slot and returns it. 
 | 
void | 
setField(int id,
        int value)  | 
void | 
setInventorySlotContents(int index,
                        ItemStack stack)
Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections). 
 | 
void | 
setItemStack(ItemStack itemStackIn)
Set the stack helds by mouse, used in GUI/Container 
 | 
void | 
setPickedItemStack(ItemStack stack)  | 
NBTTagList | 
writeToNBT(NBTTagList nbtTagListIn)
Writes the inventory out as a list of compound tags. 
 | 
public final NonNullList<ItemStack> mainInventory
public final NonNullList<ItemStack> armorInventory
public final NonNullList<ItemStack> offHandInventory
public int currentItem
public EntityPlayer player
public boolean inventoryChanged
public InventoryPlayer(EntityPlayer playerIn)
public ItemStack getCurrentItem()
public static int getHotbarSize()
public int getFirstEmptyStack()
public void setPickedItemStack(ItemStack stack)
public void pickItem(int index)
public static boolean isHotbar(int index)
public int getSlotFor(ItemStack stack)
public int getBestHotbarSlot()
public void changeCurrentItem(int direction)
public int clearMatchingItems(Item itemIn, int metadataIn, int removeCount, NBTTagCompound itemNBT)
itemIn - The item to match, null ignores.metadataIn - The metadata to match, -1 ignores.removeCount - The number of items to remove. If less than 1, removes all matching items.itemNBT - The NBT data to match, null ignores.public void decrementAnimations()
public boolean addItemStackToInventory(ItemStack itemStackIn)
public ItemStack decrStackSize(int index, int count)
decrStackSize in interface IInventorypublic void deleteStack(ItemStack stack)
public ItemStack removeStackFromSlot(int index)
removeStackFromSlot in interface IInventorypublic void setInventorySlotContents(int index,
                                     ItemStack stack)
setInventorySlotContents in interface IInventorypublic float getStrVsBlock(IBlockState state)
public NBTTagList writeToNBT(NBTTagList nbtTagListIn)
public void readFromNBT(NBTTagList nbtTagListIn)
public int getSizeInventory()
getSizeInventory in interface IInventorypublic boolean isEmpty()
isEmpty in interface IInventorypublic ItemStack getStackInSlot(int index)
getStackInSlot in interface IInventorypublic java.lang.String getName()
getName in interface IWorldNameablepublic boolean hasCustomName()
hasCustomName in interface IWorldNameablepublic ITextComponent getDisplayName()
getDisplayName in interface IWorldNameablepublic int getInventoryStackLimit()
getInventoryStackLimit in interface IInventorypublic boolean canHarvestBlock(IBlockState state)
public ItemStack armorItemInSlot(int slotIn)
public void damageArmor(float damage)
public void dropAllItems()
public void markDirty()
markDirty in interface IInventorypublic void setItemStack(ItemStack itemStackIn)
public ItemStack getItemStack()
public boolean isUsableByPlayer(EntityPlayer player)
isUsableByPlayer in interface IInventorypublic boolean hasItemStack(ItemStack itemStackIn)
public void openInventory(EntityPlayer player)
openInventory in interface IInventorypublic void closeInventory(EntityPlayer player)
closeInventory in interface IInventorypublic boolean isItemValidForSlot(int index,
                                  ItemStack stack)
isItemValidForSlot in interface IInventorypublic void copyInventory(InventoryPlayer playerInventory)
public int getField(int id)
getField in interface IInventorypublic void setField(int id,
                     int value)
setField in interface IInventorypublic int getFieldCount()
getFieldCount in interface IInventorypublic void clear()
clear in interface IInventory