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).
|
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 |
add(int p_191971_1_,
ItemStack p_191971_2_) |
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.
|
void |
fillStackedContents(RecipeItemHelper helper,
boolean p_194016_2_) |
int |
findSlotMatchingUnusedItem(ItemStack p_194014_1_) |
int |
getBestHotbarSlot() |
ItemStack |
getCurrentItem()
Returns the item stack currently held by the player.
|
float |
getDestroySpeed(IBlockState state) |
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.
|
int |
getTimesChanged() |
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 |
placeItemBackInInventory(World p_191975_1_,
ItemStack p_191975_2_) |
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) |
int |
storeItemStack(ItemStack itemStackIn)
stores an itemstack in the users inventory
|
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 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 findSlotMatchingUnusedItem(ItemStack p_194014_1_)
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 int storeItemStack(ItemStack itemStackIn)
public void decrementAnimations()
public boolean addItemStackToInventory(ItemStack itemStackIn)
public boolean add(int p_191971_1_, ItemStack p_191971_2_)
public void placeItemBackInInventory(World p_191975_1_, ItemStack p_191975_2_)
public ItemStack decrStackSize(int index, int count)
decrStackSize
in interface IInventory
public void deleteStack(ItemStack stack)
public ItemStack removeStackFromSlot(int index)
removeStackFromSlot
in interface IInventory
public void setInventorySlotContents(int index, ItemStack stack)
setInventorySlotContents
in interface IInventory
public float getDestroySpeed(IBlockState state)
public NBTTagList writeToNBT(NBTTagList nbtTagListIn)
public void readFromNBT(NBTTagList nbtTagListIn)
public int getSizeInventory()
getSizeInventory
in interface IInventory
public boolean isEmpty()
isEmpty
in interface IInventory
public ItemStack getStackInSlot(int index)
getStackInSlot
in interface IInventory
public java.lang.String getName()
getName
in interface IWorldNameable
public boolean hasCustomName()
hasCustomName
in interface IWorldNameable
public ITextComponent getDisplayName()
getDisplayName
in interface IWorldNameable
public int getInventoryStackLimit()
getInventoryStackLimit
in interface IInventory
public boolean canHarvestBlock(IBlockState state)
public ItemStack armorItemInSlot(int slotIn)
public void damageArmor(float damage)
public void dropAllItems()
public void markDirty()
markDirty
in interface IInventory
public int getTimesChanged()
public void setItemStack(ItemStack itemStackIn)
public ItemStack getItemStack()
public boolean isUsableByPlayer(EntityPlayer player)
isUsableByPlayer
in interface IInventory
public boolean hasItemStack(ItemStack itemStackIn)
public void openInventory(EntityPlayer player)
openInventory
in interface IInventory
public void closeInventory(EntityPlayer player)
closeInventory
in interface IInventory
public boolean isItemValidForSlot(int index, ItemStack stack)
isItemValidForSlot
in interface IInventory
public void copyInventory(InventoryPlayer playerInventory)
public int getField(int id)
getField
in interface IInventory
public void setField(int id, int value)
setField
in interface IInventory
public int getFieldCount()
getFieldCount
in interface IInventory
public void clear()
clear
in interface IInventory
public void fillStackedContents(RecipeItemHelper helper, boolean p_194016_2_)