cInventory


Index:
Articles
Classes
Hooks

Quick navigation:
cArrowEntity
cBeaconEntity
cBlockArea
cBlockEntity
cBlockEntityWithItems
cBlockInfo
cBoundingBox
cBrewingstandEntity
cChatColor
cChestEntity
cChunkDesc
cClientHandle
cCommandBlockEntity
cCompositeChat
cCraftingGrid
cCraftingRecipe
cCryptoHash
cCuboid
cDispenserEntity
cDropperEntity
cDropSpenserEntity
cEnchantments
cEntity
cEntityEffect
cExpBottleEntity
cFile
cFireChargeEntity
cFireworkEntity
cFloater
cFlowerPotEntity
cFurnaceEntity
cGhastFireballEntity
cHangingEntity
cHopperEntity
cIniFile
cInventory
cItem
cItemFrame
cItemGrid
cItems
cJson
cJukeboxEntity
cLineBlockTracer
cLuaWindow
cMap
cMapManager
cMobHeadEntity
cMobSpawnerEntity
cMojangAPI
cMonster
cNetwork
cNoteEntity
cObjective
cPainting
cPawn
cPickup
cPlayer
cPlugin
cPluginLua
cPluginManager
cProjectileEntity
cRankManager
cRoot
cScoreboard
cServer
cServerHandle
cSignEntity
cSplashPotionEntity
cStatManager
cStringCompression
cTCPLink
cTeam
cThrownEggEntity
cThrownEnderPearlEntity
cThrownSnowballEntity
cTNTEntity
cTracer
cUDPEndpoint
cUrlClient
cUrlParser
cWebAdmin
cWindow
cWitherSkullEntity
cWorld
HTTPFormData
HTTPRequest
HTTPTemplateRequest
ItemCategory
lxp
sqlite3
TakeDamageInfo
tolua
Vector3d
Vector3f
Vector3i
Globals

Contents


cInventory class

This object is used to store the items that a cPlayer has. It also keeps track of what item the player has currently selected in their hotbar. Internally, the class uses three cItemGrid objects to store the contents:

  • Armor
  • Inventory
  • Hotbar
  • These ItemGrids are available in the API and can be manipulated by the plugins, too.

    When using the raw slot access functions, such as GetSlot() and SetSlot(), the slots are numbered consecutively, each ItemGrid has its offset and count. To future-proff your plugins, use the named constants instead of hard-coded numbers.


    Constants

    Rather than hardcoding numbers, use the following constants for slot indices and counts:

    NameValueNotes
    invArmorCount 4 Number of slots in the Armor part
    invArmorOffset 0 Starting slot number of the Armor part
    invHotbarCount 9 Number of slots in the Hotbar part
    invHotbarOffset 31 Starting slot number of the Hotbar part
    invInventoryCount 27 Number of slots in the main inventory part
    invInventoryOffset 4 Starting slot number of the main inventory part
    invNumSlots 40 Total number of slots in a cInventory



    Functions

    NameParametersReturn valueNotes
    AddItem cItem, [AllowNewStacks] number Adds an item to the storage; if AllowNewStacks is true (default), will also create new stacks in empty slots. Returns the number of items added
    AddItems cItems, [AllowNewStacks] number Same as AddItem, but for several items at once
    ChangeSlotCount SlotNum, AddToCount number Adds AddToCount to the count of items in the specified slot. If the slot was empty, ignores the call. Returns the new count in the slot, or -1 if invalid SlotNum
    Clear Empties all slots
    CopyToItems cItems Copies all non-empty slots into the cItems object provided; original cItems contents are preserved
    DamageEquippedItem [DamageAmount] bool Adds the specified damage (1 by default) to the currently equipped it
    DamageItem SlotNum, [DamageAmount] bool Adds the specified damage (1 by default) to the specified item, returns true if the item reached its max damage and should be destroyed
    GetArmorGrid cItemGrid Returns the ItemGrid representing the armor grid (1 x 4 slots)
    GetArmorSlot ArmorSlotNum cItem Returns the specified armor slot contents. Note that the returned item is read-only
    GetEquippedBoots cItem Returns the item in the "boots" slot of the armor grid. Note that the returned item is read-only
    GetEquippedChestplate cItem Returns the item in the "chestplate" slot of the armor grid. Note that the returned item is read-only
    GetEquippedHelmet cItem Returns the item in the "helmet" slot of the armor grid. Note that the returned item is read-only
    GetEquippedItem cItem Returns the currently selected item from the hotbar. Note that the returned item is read-only
    GetEquippedLeggings cItem Returns the item in the "leggings" slot of the armor grid. Note that the returned item is read-only
    GetEquippedSlotNum number Returns the hotbar slot number for the currently selected item
    GetHotbarGrid cItemGrid Returns the ItemGrid representing the hotbar grid (9 x 1 slots)
    GetHotbarSlot HotBarSlotNum cItem Returns the specified hotbar slot contents. Note that the returned item is read-only
    GetInventoryGrid cItemGrid Returns the ItemGrid representing the main inventory (9 x 3 slots)
    GetInventorySlot InventorySlotNum cItem Returns the specified main inventory slot contents. Note that the returned item is read-only
    GetOwner cPlayer Returns the player whose inventory this object represents
    GetSlot SlotNum cItem Returns the contents of the specified slot. Note that the returned item is read-only
    HasItems cItem bool Returns true if there are at least as many items of the specified type as in the parameter
    HowManyCanFit ItemStack, BeginSlotNum, EndSlotNum, [AllowNewStacks] number Returns how many items of the specified type would fit into the slot range specified. If AllowNewStacks is false, only considers slots already containing the specified item. AllowNewStacks defaults to true if not given.
    HowManyCanFit ItemStack, [AllowNewStacks] number Returns number of items out of a_ItemStack that can fit in the storage. If AllowNewStacks is false, only considers slots already containing the specified item. AllowNewStacks defaults to true if not given.
    HowManyItems cItem number Returns the number of the specified items that are currently stored
    RemoveItem cItem number Removes the specified item from the inventory, as many as possible, up to the item's m_ItemCount. Returns the number of items that were removed.
    RemoveOneEquippedItem Removes one item from the hotbar's currently selected slot
    SendEquippedSlot Sends the equipped item slot to the client
    SetArmorSlot ArmorSlotNum, cItem Sets the specified armor slot contents
    SetEquippedSlotNum EquippedSlotNum Sets the currently selected hotbar slot number
    SetHotbarSlot HotbarSlotNum, cItem Sets the specified hotbar slot contents
    SetInventorySlot InventorySlotNum, cItem Sets the specified main inventory slot contents
    SetSlot SlotNum, cItem Sets the specified slot contents
    Generated on 2016-08-22 23:53:06, Build ID Unknown, Commit approx: 2ed4af74edd14ae17e1c6c64d44caa7b7fc30d5a