ItemStack - Uberi/MineTest-API GitHub Wiki

ItemStack

Description

A stack of items, storing the type of item, the number of items, and extra information like wear or metadata.

Can be created via ItemStack(itemstack or itemstring or table or nil).

Syntax

ItemStack:is_empty(): return true if stack is empty
ItemStack:get_name(): returns item name (e.g. "default:stone")
ItemStack:get_count(): returns number of items on the stack
ItemStack:get_wear(): returns tool wear (0-65535), 0 for non-tools
ItemStack:get_metadata(): returns metadata (a string attached to an item stack)
ItemStack:clear(): removes all items from the stack, making it empty
ItemStack:replace(item): replace the contents of this stack (item can also be an itemstring or table)
ItemStack:to_string(): returns the stack in itemstring form
ItemStack:to_table(): returns the stack in Lua table form
ItemStack:get_stack_max(): returns the maximum size of the stack (depends on the item)
ItemStack:get_free_space(): returns get_stack_max() - get_count()
ItemStack:is_known(): returns true if the item name refers to a defined item type
ItemStack:get_definition(): returns the item definition table
ItemStack:get_tool_capabilities(): returns the digging properties of the item,
^ or those of the hand if none are defined for this item type
ItemStack:add_wear(amount): increases wear by amount if the item is a tool
ItemStack:add_item(item): put some item or stack onto this stack,
^ returns leftover ItemStack
ItemStack:item_fits(item): returns true if item or stack can be fully added to this one
ItemStack:take_item(n): take (and remove) up to n items from this stack
^ returns taken ItemStack
^ if n is omitted, n=1 is used
ItemStack:peek_item(n): copy (don't remove) up to n items from this stack
^ returns copied ItemStack
^ if n is omitted, n=1 is used
⚠️ **GitHub.com Fallback** ⚠️