Minetest  5.4.0
ItemStack Struct Reference

#include <inventory.h>

+ Inheritance diagram for ItemStack:
+ Collaboration diagram for ItemStack:

Public Member Functions

 ItemStack ()=default
 
 ItemStack (const std::string &name_, u16 count_, u16 wear, IItemDefManager *itemdef)
 
 ~ItemStack ()=default
 
void serialize (std::ostream &os, bool serialize_meta=true) const
 
void deSerialize (std::istream &is, IItemDefManager *itemdef=NULL)
 
void deSerialize (const std::string &s, IItemDefManager *itemdef=NULL)
 
std::string getItemString (bool include_meta=true) const
 
std::string getDescription (IItemDefManager *itemdef) const
 
std::string getShortDescription (IItemDefManager *itemdef) const
 
bool empty () const
 
void clear ()
 
void add (u16 n)
 
void remove (u16 n)
 
u16 getStackMax (IItemDefManager *itemdef) const
 
u16 freeSpace (IItemDefManager *itemdef) const
 
bool isKnown (IItemDefManager *itemdef) const
 
const ItemDefinitiongetDefinition (IItemDefManager *itemdef) const
 
const ToolCapabilitiesgetToolCapabilities (IItemDefManager *itemdef) const
 
bool addWear (s32 amount, IItemDefManager *itemdef)
 
ItemStack addItem (ItemStack newitem, IItemDefManager *itemdef)
 
bool itemFits (ItemStack newitem, ItemStack *restitem, IItemDefManager *itemdef) const
 
ItemStack takeItem (u32 takecount)
 
ItemStack peekItem (u32 peekcount) const
 
bool operator== (const ItemStack &s) const
 
bool operator!= (const ItemStack &s) const
 

Public Attributes

std::string name = ""
 
u16 count = 0
 
u16 wear = 0
 
ItemStackMetadata metadata
 

Constructor & Destructor Documentation

◆ ItemStack() [1/2]

ItemStack::ItemStack ( )
default

Referenced by peekItem(), and takeItem().

+ Here is the caller graph for this function:

◆ ItemStack() [2/2]

ItemStack::ItemStack ( const std::string &  name_,
u16  count_,
u16  wear,
IItemDefManager itemdef 
)

References clear(), count, IItemDefManager::get(), ITEM_TOOL, name, and ItemDefinition::type.

+ Here is the call graph for this function:

◆ ~ItemStack()

ItemStack::~ItemStack ( )
default

Member Function Documentation

◆ add()

void ItemStack::add ( u16  n)
inline

References count.

Referenced by addItem().

+ Here is the caller graph for this function:

◆ addItem()

ItemStack ItemStack::addItem ( ItemStack  newitem,
IItemDefManager itemdef 
)

References add(), clear(), count, empty(), freeSpace(), metadata, name, and remove().

Referenced by LuaItemStack::l_add_item(), GUIFormSpecMenu::OnEvent(), and InventoryList::removeItem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addWear()

bool ItemStack::addWear ( s32  amount,
IItemDefManager itemdef 
)
inline

References clear(), getDefinition(), ITEM_TOOL, and wear.

Referenced by Server::handleCommand_Interact(), and LuaItemStack::l_add_wear().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clear()

void ItemStack::clear ( )
inline

References ItemStackMetadata::clear(), count, metadata, name, and wear.

Referenced by ItemStack(), addItem(), addWear(), deSerialize(), getCraftingResult(), itemFits(), LuaItemStack::l_clear(), LuaItemStack::l_set_count(), LuaItemStack::l_set_name(), LuaItemStack::l_set_wear(), GUIFormSpecMenu::OnEvent(), remove(), takeItem(), and GUIFormSpecMenu::verifySelectedItem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deSerialize() [1/2]

void ItemStack::deSerialize ( const std::string &  s,
IItemDefManager itemdef = NULL 
)

References deSerialize().

+ Here is the call graph for this function:

◆ deSerialize() [2/2]

◆ empty()

◆ freeSpace()

u16 ItemStack::freeSpace ( IItemDefManager itemdef) const
inline

References count, and getStackMax().

Referenced by addItem(), itemFits(), and LuaItemStack::l_get_free_space().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefinition()

const ItemDefinition& ItemStack::getDefinition ( IItemDefManager itemdef) const
inline

References IItemDefManager::get(), and name.

Referenced by addWear(), Server::checkInteractDistance(), drawItemStack(), getDescription(), getItemMesh(), getShortDescription(), Server::handleCommand_Interact(), Game::handlePointingAtNode(), GUIFormSpecMenu::parseItemImageButton(), Game::processPlayerInteraction(), and WieldMeshSceneNode::setItem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDescription()

std::string ItemStack::getDescription ( IItemDefManager itemdef) const

References ItemDefinition::description, getDefinition(), Metadata::getString(), metadata, and name.

Referenced by GUIInventoryList::draw(), getShortDescription(), and LuaItemStack::l_get_description().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getItemString()

std::string ItemStack::getItemString ( bool  include_meta = true) const

References serialize().

Referenced by ICraftAction::apply(), CraftDefinitionToolRepair::getOutput(), ModApiEnvMod::l_add_item(), LuaItemStack::l_to_string(), LuaItemStack::mt_tostring(), read_object_properties(), and RollbackAction::toString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getShortDescription()

std::string ItemStack::getShortDescription ( IItemDefManager itemdef) const

References getDefinition(), getDescription(), Metadata::getString(), metadata, and ItemDefinition::short_description.

Referenced by LuaItemStack::l_get_short_description().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStackMax()

u16 ItemStack::getStackMax ( IItemDefManager itemdef) const
inline

References IItemDefManager::get(), name, and ItemDefinition::stack_max.

Referenced by freeSpace(), and LuaItemStack::l_get_stack_max().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getToolCapabilities()

const ToolCapabilities& ItemStack::getToolCapabilities ( IItemDefManager itemdef) const
inline

References IItemDefManager::get(), ItemStackMetadata::getToolCapabilities(), metadata, name, and ItemDefinition::tool_capabilities.

Referenced by GenericCAO::directReportPunch(), Server::handleCommand_Interact(), Game::handleDigging(), LuaItemStack::l_get_tool_capabilities(), and Game::updateCamera().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isKnown()

bool ItemStack::isKnown ( IItemDefManager itemdef) const
inline

References IItemDefManager::isKnown(), and name.

Referenced by CCraftDefManager::getCraftResult(), ModApiEnvMod::l_add_item(), and LuaItemStack::l_is_known().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ itemFits()

bool ItemStack::itemFits ( ItemStack  newitem,
ItemStack restitem,
IItemDefManager itemdef 
) const

References clear(), count, empty(), freeSpace(), metadata, name, and remove().

Referenced by LuaItemStack::l_item_fits().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator!=()

bool ItemStack::operator!= ( const ItemStack s) const
inline

◆ operator==()

bool ItemStack::operator== ( const ItemStack s) const
inline

References count, metadata, name, and wear.

◆ peekItem()

ItemStack ItemStack::peekItem ( u32  peekcount) const

References ItemStack(), and count.

Referenced by LuaItemStack::l_peek_item().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ remove()

void ItemStack::remove ( u16  n)
inline

References clear(), and count.

Referenced by addItem(), itemFits(), and takeItem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize()

void ItemStack::serialize ( std::ostream &  os,
bool  serialize_meta = true 
) const

References count, empty(), Metadata::empty(), metadata, name, ItemStackMetadata::serialize(), serializeJsonStringIfNeeded(), Metadata::size(), and wear.

Referenced by getItemString(), and PlayerDatabaseSQLite3::savePlayer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ takeItem()

ItemStack ItemStack::takeItem ( u32  takecount)

References ItemStack(), clear(), count, and remove().

Referenced by GUIInventoryList::draw(), and LuaItemStack::l_take_item().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ count

◆ metadata

◆ name

◆ wear


The documentation for this struct was generated from the following files: