Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
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 (const IItemDefManager *itemdef) const
 
std::string getShortDescription (const IItemDefManager *itemdef) const
 
std::string getInventoryImage (const IItemDefManager *itemdef) const
 
std::string getInventoryOverlay (const IItemDefManager *itemdef) const
 
std::string getWieldImage (const IItemDefManager *itemdef) const
 
std::string getWieldOverlay (const IItemDefManager *itemdef) const
 
v3f getWieldScale (const IItemDefManager *itemdef) const
 
bool empty () const
 
void clear ()
 
void add (u16 n)
 
void remove (u16 n)
 
u16 getStackMax (const IItemDefManager *itemdef) const
 
u16 freeSpace (const IItemDefManager *itemdef) const
 
bool isKnown (const IItemDefManager *itemdef) const
 
const ItemDefinitiongetDefinition (const IItemDefManager *itemdef) const
 
const ToolCapabilitiesgetToolCapabilities (const IItemDefManager *itemdef) const
 
const std::optional< WearBarParams > & getWearBarParams (const IItemDefManager *itemdef) const
 
bool addWear (s32 amount, const IItemDefManager *itemdef)
 
ItemStack addItem (ItemStack newitem, IItemDefManager *itemdef)
 
bool itemFits (ItemStack newitem, ItemStack *restitem, IItemDefManager *itemdef) const
 
bool stacksWith (const ItemStack &other) 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(), InventoryList::moveItem(), and InventoryList::moveItemSomewhere().

+ 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,
const IItemDefManager * itemdef )
inline

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

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

+ 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(), InventoryList::moveItem(), 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 ( const 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 ( const IItemDefManager * itemdef) const
inline

References IItemDefManager::get(), and name.

Referenced by addWear(), drawItemStack(), getDescription(), getInventoryImage(), getInventoryOverlay(), getItemMesh(), getShortDescription(), getToolRange(), getWieldImage(), getWieldOverlay(), getWieldScale(), 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 ( const IItemDefManager * itemdef) const

References ItemDefinition::description, getDefinition(), SimpleMetadata::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:

◆ getInventoryImage()

std::string ItemStack::getInventoryImage ( const IItemDefManager * itemdef) const

References getDefinition(), SimpleMetadata::getString(), ItemDefinition::inventory_image, and metadata.

Referenced by drawItemStack(), getItemMesh(), and WieldMeshSceneNode::setItem().

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

◆ getInventoryOverlay()

std::string ItemStack::getInventoryOverlay ( const IItemDefManager * itemdef) const

References getDefinition(), SimpleMetadata::getString(), ItemDefinition::inventory_overlay, and metadata.

Referenced by drawItemStack(), getItemMesh(), and WieldMeshSceneNode::setItem().

+ 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(), ModApiEnv::l_add_item(), LuaItemStack::l_to_string(), LuaItemStack::mt_tostring(), read_object_properties(), TestMoveAction::testMove(), TestMoveAction::testMovePartial(), TestMoveAction::testMoveSomewhere(), TestMoveAction::testMoveSomewherePartial(), TestMoveAction::testMoveUnallowed(), TestMoveAction::testSwap(), TestMoveAction::testSwapFromUnallowed(), TestMoveAction::testSwapToUnallowed(), and RollbackAction::toString().

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

◆ getShortDescription()

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

References getDefinition(), getDescription(), SimpleMetadata::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 ( const IItemDefManager * itemdef) const
inline

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

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

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

◆ getToolCapabilities()

const ToolCapabilities & ItemStack::getToolCapabilities ( const 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:

◆ getWearBarParams()

const std::optional< WearBarParams > & ItemStack::getWearBarParams ( const IItemDefManager * itemdef) const
inline

References IItemDefManager::get(), ItemStackMetadata::getWearBarParamOverride(), metadata, name, and ItemDefinition::wear_bar_params.

Referenced by drawItemStack(), and LuaItemStack::l_get_wear_bar_params().

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

◆ getWieldImage()

std::string ItemStack::getWieldImage ( const IItemDefManager * itemdef) const

References getDefinition(), SimpleMetadata::getString(), metadata, and ItemDefinition::wield_image.

Referenced by WieldMeshSceneNode::setItem().

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

◆ getWieldOverlay()

std::string ItemStack::getWieldOverlay ( const IItemDefManager * itemdef) const

References getDefinition(), SimpleMetadata::getString(), metadata, and ItemDefinition::wield_overlay.

Referenced by WieldMeshSceneNode::setItem().

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

◆ getWieldScale()

v3f ItemStack::getWieldScale ( const IItemDefManager * itemdef) const

References getDefinition(), SimpleMetadata::getString(), metadata, str_to_v3f(), and ItemDefinition::wield_scale.

Referenced by WieldMeshSceneNode::setItem().

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

◆ isKnown()

bool ItemStack::isKnown ( const IItemDefManager * itemdef) const
inline

References IItemDefManager::isKnown(), and name.

Referenced by CCraftDefManager::getCraftResult(), ModApiEnv::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 IMoveAction::apply(), and 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(), InventoryList::moveItem(), 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(), SimpleMetadata::empty(), metadata, name, ItemStackMetadata::serialize(), serializeJsonStringIfNeeded(), SimpleMetadata::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:

◆ stacksWith()

bool ItemStack::stacksWith ( const ItemStack & other) const

References metadata, name, and wear.

Referenced by GUIFormSpecMenu::OnEvent().

+ 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: