Package net.minecraft.src
Class InventoryPlayer
java.lang.Object
net.minecraft.src.InventoryPlayer
- All Implemented Interfaces:
IInventory
-
Field Summary
FieldsModifier and TypeFieldDescriptionAn array of 4 item stacks containing the currently worn armor pieces.intThe index of the currently held item (0-8).booleanSet true whenever the inventory changes.An array of 36 item stacks indicating the main player inventory (including the visible bar).The player whose inventory this is. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddItemStackToInventory(ItemStack par1ItemStack) Adds the item stack to the inventory, returns false if it is impossible.armorItemInSlot(int par1) returns a player armor item (as itemstack) contained in specified armor slot.booleancanHarvestBlock(World world, Block par1Block, int i, int j, int k) Returns whether the current item (tool) can harvest from the specified block (actually get a result).voidchangeCurrentItem(int par1) Switch the current item to the next one or the previous oneintclearInventory(int par1, int par2) Clear this player's inventory, using the specified ID and metadata as filters or -1 for no filter.voidbooleanconsumeInventoryItem(int par1) removed one item of specified itemID from inventory (if it is in a stack, the stack size will reduce with 1)voidcopyInventory(InventoryPlayer par1InventoryPlayer) Copy the ItemStack contents from another InventoryPlayer instancevoiddamageArmor(float par1) Damages armor in each slot by the specified amount.voidDecrement the number of animations remaining.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.voidDrop all armor and main inventory items.voidfunc_70439_a(Item par1Item, int par2) Returns the item stack currently held by the player.intReturns the first item stack that is empty.static intGet the size of the player hotbar inventoryintReturns the maximum stack size for a inventory slot.Returns the name of the inventory.intReturns the number of slots in the inventory.getStackInSlot(int par1) Returns the stack in slot igetStackInSlotOnClosing(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.floatgetStrVsBlock(World world, Block par1Block, int i, int j, int k) Gets the strength of the current item (tool) against the specified block, 1.0f if not holding anything.intBased on the damage values and maximum damage values of each armor item, returns the current armor value.booleanhasItem(int par1) Get if a specifiied item id is inside the inventory.booleanhasItemStack(ItemStack par1ItemStack) Returns true if the specified ItemStack exists in the inventory.booleanIf this returns false, the inventory name will be used as an unlocalized name, and translated into the player's language.booleanisItemValidForSlot(int par1, ItemStack par2ItemStack) Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot.booleanisUseableByPlayer(EntityPlayer par1EntityPlayer) Do not make give this method the name canInteractWith because it clashes with ContainervoidCalled when an the contents of an Inventory change, usuallyvoidvoidreadFromNBT(NBTTagList par1NBTTagList) Reads from the given tag list and fills the slots in the inventory with the correct items.voidsetCurrentItem(int par1, int par2, boolean par3, boolean par4) Sets a specific itemID as the current item being held (only if it exists on the hotbar)voidsetInventorySlotContents(int par1, ItemStack par2ItemStack) Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).voidsetItemStack(ItemStack par1ItemStack) writeToNBT(NBTTagList par1NBTTagList) Writes the inventory out as a list of compound tags.
-
Field Details
-
mainInventory
An array of 36 item stacks indicating the main player inventory (including the visible bar). -
armorInventory
An array of 4 item stacks containing the currently worn armor pieces. -
currentItem
public int currentItemThe index of the currently held item (0-8). -
player
The player whose inventory this is. -
inventoryChanged
public boolean inventoryChangedSet 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 Details
-
InventoryPlayer
-
-
Method Details
-
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) Sets a specific itemID as the current item being held (only if it exists on the hotbar) -
changeCurrentItem
public void changeCurrentItem(int par1) Switch the current item to the next one or the previous one -
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
-
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
Adds the item stack to the inventory, returns false if it is impossible. -
decrStackSize
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:
decrStackSizein interfaceIInventory
-
getStackInSlotOnClosing
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:
getStackInSlotOnClosingin interfaceIInventory
-
setInventorySlotContents
Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).- Specified by:
setInventorySlotContentsin interfaceIInventory
-
getStrVsBlock
Gets the strength of the current item (tool) against the specified block, 1.0f if not holding anything. -
writeToNBT
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
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:
getSizeInventoryin interfaceIInventory
-
getStackInSlot
Returns the stack in slot i- Specified by:
getStackInSlotin interfaceIInventory
-
getInvName
Returns the name of the inventory.- Specified by:
getInvNamein interfaceIInventory
-
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:
isInvNameLocalizedin interfaceIInventory
-
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:
getInventoryStackLimitin interfaceIInventory
-
canHarvestBlock
Returns whether the current item (tool) can harvest from the specified block (actually get a result). -
armorItemInSlot
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:
onInventoryChangedin interfaceIInventory
-
setItemStack
-
getItemStack
-
isUseableByPlayer
Do not make give this method the name canInteractWith because it clashes with Container- Specified by:
isUseableByPlayerin interfaceIInventory
-
hasItemStack
Returns true if the specified ItemStack exists in the inventory. -
openChest
public void openChest()- Specified by:
openChestin interfaceIInventory
-
closeChest
public void closeChest()- Specified by:
closeChestin interfaceIInventory
-
isItemValidForSlot
Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot.- Specified by:
isItemValidForSlotin interfaceIInventory
-
copyInventory
Copy the ItemStack contents from another InventoryPlayer instance
-