IDE-helper: full docs for ItemStack

This commit is contained in:
alek13
2024-07-30 22:20:32 +03:00
parent ae51aadda6
commit 70e5d5abc9

View File

@@ -1,80 +1,110 @@
---@class ItemStack ---@class ItemStack
ItemStack = {} ItemStack = {}
--- put some item or stack onto this stack, returns leftover ItemStack --- @class ItemStackTable: table
--- @field name string
--- @field count number
--- @field wear number
--- @field metadata string|
--- @alias ItemStackString string
--- Put some item or stack onto this stack, returns leftover ItemStack
--- @param item ItemStack|ItemStackString|ItemStackTable
--- @return self
function ItemStack:add_item(item) end function ItemStack:add_item(item) end
--- increases wear by amount if the item is a tool --- Increases wear by amount if the item is a tool, otherwise does nothing.
---@param amount number --- Wear is only added if the item is a tool. Adding wear might destroy the item.
--- @param amount number Valid amount range is [0,65536]
--- @return boolean Returns true if the item is (or was) a tool.
function ItemStack:add_wear(amount) end function ItemStack:add_wear(amount) end
--- removes all items from the stack, making it empty --- Removes all items from the stack, making it empty
--- @return boolean it seams that it always return `true`
function ItemStack:clear() end function ItemStack:clear() end
--- returns number of items on the stack --- Returns number of items on the stack
---@return number --- @return number
function ItemStack:get_count() end function ItemStack:get_count() end
--- returns true/false (success), clears item on failure --- Returns true/false (success), clears item on failure
---@param count number --- @param count number count > 0 && count <= 65535 -- or clears
--- @return boolean
function ItemStack:set_count(count) end function ItemStack:set_count(count) end
--- returns the item definition table --- @return ItemDefinition returns the item definition table
function ItemStack:get_definition() end function ItemStack:get_definition() end
--- returns get_stack_max() - get_count() --- Returns get_stack_max() - get_count()
--- @return number
function ItemStack:get_free_space() end function ItemStack:get_free_space() end
--- @return MetaDataRef --- @return MetaDataRef
function ItemStack:get_meta() end function ItemStack:get_meta() end
--- returns a string, for compatibility reasons this is equal to get_meta():get_string("") --- Returns a string, for compatibility reasons this is equal to get_meta():get_string("")
---@deprecated --- @deprecated
function ItemStack:get_metadata() end function ItemStack:get_metadata() end
--- returns item name (e.g. "default:stone") --- Returns item name (e.g. "default:stone")
---@return string --- @return string
function ItemStack:get_name() end function ItemStack:get_name() end
--- returns true/false (success), clears item on failure --- Returns true/false (success), clears item on failure
---@param item_name string --- @param item_name string
--- @return boolean
function ItemStack:set_name(item_name) end function ItemStack:set_name(item_name) end
--- returns the maximum size of the stack (depends on the item) --- Returns the maximum size of the stack (depends on the item)
--- @return number
function ItemStack:get_stack_max() end function ItemStack:get_stack_max() end
--- returns the digging properties of the item, or those of the hand if none are defined for this item type --- Returns the digging properties of the item, or those of the hand if none are defined for this item type
--- @return table
function ItemStack:get_tool_capabilities() end function ItemStack:get_tool_capabilities() end
--- returns tool wear (0-65535), 0 for non-tools --- Returns tool wear (0-65535), 0 for non-tools
--- @return number
function ItemStack:get_wear() end function ItemStack:get_wear() end
--- returns true/false (success), clears item on failure --- Returns true/false (success), clears item on failure
--- @param wear number wear <= 65535, otherwise clears
--- @return boolean
function ItemStack:set_wear(wear) end function ItemStack:set_wear(wear) end
--- return true if stack is empty --- Return true if stack is empty
---@return boolean --- @return boolean
function ItemStack:is_empty() end function ItemStack:is_empty() end
--- returns true if the item name refers to a defined item type --- Returns true if the item name refers to a defined item type
---@return boolean --- @return boolean
function ItemStack:is_known() end function ItemStack:is_known() end
--- returns true if item or stack can be fully added to this one --- Returns true if item or stack can be fully added to this one
--- @param item ItemStack|ItemStackString|ItemStackTable
--- @return boolean
function ItemStack:item_fits(item) end function ItemStack:item_fits(item) end
--- copy (don't remove) up to n items from this stack; returns copied ItemStack; if n is omitted, n=1 is used --- Copy (don't remove) up to n items from this stack; returns copied ItemStack; if n is omitted, n=1 is used
function ItemStack:peek_item(n) end --- @param count number
--- @return ItemStack
function ItemStack:peek_item(count) end
--- replace the contents of this stack (item can also be an itemstring or table) --- Replace the contents of this stack (item can also be an itemstring or table)
--- @param item ItemStack|ItemStackString|ItemStackTable
--- @return boolean seams always `true`
function ItemStack:replace(item) end function ItemStack:replace(item) end
--- take (and remove) up to n items from this stack; returns taken ItemStack; if n is omitted, n=1 is used --- Take (and remove) up to n items from this stack; returns taken ItemStack; if n is omitted, n=1 is used
function ItemStack:take_item(n) end --- @param count number
--- @return ItemStack
function ItemStack:take_item(count) end
--- returns the stack in itemstring form --- Returns the stack in itemstring form
--- @return string
function ItemStack:to_string() end function ItemStack:to_string() end
--- returns the stack in Lua table form --- Returns the stack in Lua table form or `nil` if empty.
---@return table --- @return table|nil
function ItemStack:to_table() end function ItemStack:to_table() end