#include <inventory.h>
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 ItemDefinition & | getDefinition (const IItemDefManager *itemdef) const |
const ToolCapabilities & | getToolCapabilities (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 |
|
default |
ItemStack::ItemStack | ( | const std::string & | name_, |
u16 | count_, | ||
u16 | wear, | ||
IItemDefManager * | itemdef ) |
References clear(), count, IItemDefManager::get(), ITEM_TOOL, name, and ItemDefinition::type.
|
default |
|
inline |
References count.
Referenced by addItem(), InventoryList::moveItem(), and InventoryList::moveItemSomewhere().
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().
|
inline |
References clear(), getDefinition(), ITEM_TOOL, and wear.
Referenced by Server::handleCommand_Interact(), LuaItemStack::l_add_wear(), and LuaItemStack::l_add_wear_by_uses().
|
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().
void ItemStack::deSerialize | ( | const std::string & | s, |
IItemDefManager * | itemdef = NULL ) |
void ItemStack::deSerialize | ( | std::istream & | is, |
IItemDefManager * | itemdef = NULL ) |
References BasicStrfnd< T >::at_end(), clear(), content_mapnode_get_name_id_mapping(), content_translate_from_19_to_internal(), count, ItemStackMetadata::deSerialize(), deSerializeJsonStringIfNeeded(), IItemDefManager::get(), IItemDefManager::getAlias(), NameIdMapping::getName(), ITEM_TOOL, metadata, name, BasicStrfnd< T >::next(), BasicStrfnd< T >::skip_over(), BasicStrfnd< T >::start(), stoi, trim(), ItemDefinition::type, and wear.
Referenced by GenericCAO::addToScene(), craftDecrementOrReplaceInput(), craftGetItemName(), InventoryList::deSerialize(), deSerialize(), GUIItemImage::draw(), TextDrawer::draw(), getCraftingResult(), CCraftDefManager::getCraftResult(), ModApiCraft::l_get_craft_result(), PlayerDatabaseSQLite3::loadPlayer(), parse_itemstack(), GUIFormSpecMenu::parseItemImageButton(), read_item(), and TestCraft::testShapeless().
|
inline |
References count.
Referenced by InventoryList::addItem(), addItem(), ICraftAction::apply(), IDropAction::apply(), IMoveAction::apply(), CraftDefinitionToolRepair::check(), GUIInventoryList::draw(), drawItemStack(), CraftDefinitionToolRepair::getOutput(), itemFits(), ModApiEnv::l_add_item(), LuaItemStack::l_is_empty(), InvRef::l_remove_item(), LuaItemStack::l_set_name(), LuaItemStack::l_to_table(), InventoryList::moveItem(), InventoryList::moveItemSomewhere(), GUIFormSpecMenu::OnEvent(), InventoryList::removeItem(), serialize(), InventoryList::takeItem(), TestMoveAction::testMoveUnallowed(), GUIFormSpecMenu::updateSelectedItem(), and GUIFormSpecMenu::verifySelectedItem().
|
inline |
References count, and getStackMax().
Referenced by addItem(), itemFits(), and LuaItemStack::l_get_free_space().
|
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().
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().
std::string ItemStack::getInventoryImage | ( | const IItemDefManager * | itemdef | ) | const |
References getDefinition(), SimpleMetadata::getString(), ItemDefinition::inventory_image, and metadata.
Referenced by drawItemStack(), getItemMesh(), and WieldMeshSceneNode::setItem().
std::string ItemStack::getInventoryOverlay | ( | const IItemDefManager * | itemdef | ) | const |
References getDefinition(), SimpleMetadata::getString(), ItemDefinition::inventory_overlay, and metadata.
Referenced by drawItemStack(), getItemMesh(), and WieldMeshSceneNode::setItem().
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().
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().
|
inline |
References IItemDefManager::get(), name, and ItemDefinition::stack_max.
Referenced by freeSpace(), LuaItemStack::l_get_stack_max(), and GUIFormSpecMenu::OnEvent().
|
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().
|
inline |
References IItemDefManager::get(), ItemStackMetadata::getWearBarParamOverride(), metadata, name, and ItemDefinition::wear_bar_params.
Referenced by drawItemStack(), and LuaItemStack::l_get_wear_bar_params().
std::string ItemStack::getWieldImage | ( | const IItemDefManager * | itemdef | ) | const |
References getDefinition(), SimpleMetadata::getString(), metadata, and ItemDefinition::wield_image.
Referenced by WieldMeshSceneNode::setItem().
std::string ItemStack::getWieldOverlay | ( | const IItemDefManager * | itemdef | ) | const |
References getDefinition(), SimpleMetadata::getString(), metadata, and ItemDefinition::wield_overlay.
Referenced by WieldMeshSceneNode::setItem().
v3f ItemStack::getWieldScale | ( | const IItemDefManager * | itemdef | ) | const |
References getDefinition(), SimpleMetadata::getString(), metadata, str_to_v3f(), and ItemDefinition::wield_scale.
Referenced by WieldMeshSceneNode::setItem().
|
inline |
References IItemDefManager::isKnown(), and name.
Referenced by CCraftDefManager::getCraftResult(), ModApiEnv::l_add_item(), and LuaItemStack::l_is_known().
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().
|
inline |
|
inline |
ItemStack ItemStack::peekItem | ( | u32 | peekcount | ) | const |
References ItemStack(), and count.
Referenced by LuaItemStack::l_peek_item().
|
inline |
References clear(), and count.
Referenced by addItem(), itemFits(), InventoryList::moveItem(), and takeItem().
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().
bool ItemStack::stacksWith | ( | const ItemStack & | other | ) | const |
References metadata, name, and wear.
Referenced by GUIFormSpecMenu::OnEvent().
ItemStack ItemStack::takeItem | ( | u32 | takecount | ) |
References ItemStack(), clear(), count, and remove().
Referenced by GUIInventoryList::draw(), and LuaItemStack::l_take_item().
u16 ItemStack::count = 0 |
Referenced by ItemStack(), RollbackManager::actionRowsFromSelect(), add(), addItem(), ICraftAction::apply(), IDropAction::apply(), IMoveAction::apply(), RollbackAction::applyRevert(), clear(), InventoryList::containsItem(), craftToolRepair(), deSerialize(), ScriptApiDetached::detached_inventory_AllowPut(), ScriptApiDetached::detached_inventory_AllowTake(), drawItemStack(), GUIFormSpecMenu::drawSelectedItem(), empty(), freeSpace(), itemFits(), InvRef::l_add_item(), LuaItemStack::l_get_count(), LuaItemStack::l_set_count(), LuaItemStack::l_to_table(), InventoryList::moveItem(), ScriptApiNodemeta::nodemeta_inventory_AllowPut(), ScriptApiNodemeta::nodemeta_inventory_AllowTake(), GUIFormSpecMenu::OnEvent(), operator==(), peekItem(), ScriptApiPlayer::player_inventory_AllowPut(), ScriptApiPlayer::player_inventory_AllowTake(), RollbackManager::registerRow(), remove(), InventoryList::removeItem(), serialize(), takeItem(), TestInventory::testSerializeDeserialize(), GUIFormSpecMenu::updateSelectedItem(), and GUIFormSpecMenu::verifySelectedItem().
ItemStackMetadata ItemStack::metadata |
Referenced by addItem(), clear(), ItemStackMetaRef::clearMeta(), ItemStackMetaRef::clearToolCapabilities(), ItemStackMetaRef::clearWearBarParams(), InventoryList::containsItem(), deSerialize(), drawItemStack(), getDescription(), getInventoryImage(), getInventoryOverlay(), ItemStackMetaRef::getmeta(), getShortDescription(), getToolCapabilities(), getToolRange(), getWearBarParams(), getWieldImage(), getWieldOverlay(), getWieldScale(), itemFits(), LuaItemStack::l_get_metadata(), LuaItemStack::l_set_metadata(), LuaItemStack::l_to_table(), Game::nodePlacement(), operator==(), read_item(), serialize(), ItemStackMetaRef::setToolCapabilities(), ItemStackMetaRef::setWearBarParams(), stacksWith(), and Camera::wield().
std::string ItemStack::name = "" |
Referenced by ItemStack(), RollbackManager::actionRowFromRollbackAction(), addItem(), IMoveAction::apply(), RollbackAction::applyRevert(), clear(), InventoryList::containsItem(), craftGetItemName(), craftToolRepair(), deSerialize(), GUIInventoryList::draw(), getDefinition(), getDescription(), getPunchDamage(), getStackMax(), getToolCapabilities(), getWearBarParams(), Player::getWieldedItem(), isKnown(), ScriptApiItem::item_CraftPredict(), ScriptApiItem::item_OnCraft(), ScriptApiItem::item_OnDrop(), ScriptApiItem::item_OnPlace(), ScriptApiItem::item_OnSecondaryUse(), ScriptApiItem::item_OnUse(), itemFits(), LuaItemStack::l_get_definition(), LuaItemStack::l_get_name(), LuaItemStack::l_set_name(), LuaItemStack::l_to_table(), GUIFormSpecMenu::OnEvent(), operator==(), InventoryList::removeItem(), RollbackManager::rollbackActionsFromActionRows(), serialize(), stacksWith(), GUIFormSpecMenu::verifySelectedItem(), and Camera::wield().
u16 ItemStack::wear = 0 |
Referenced by addWear(), clear(), craftToolRepair(), deSerialize(), GenericCAO::directReportPunch(), drawItemStack(), getPunchDamage(), Server::handleCommand_Interact(), Game::handleDigging(), LuaItemStack::l_add_wear_by_uses(), LuaItemStack::l_get_wear(), LuaItemStack::l_set_wear(), LuaItemStack::l_to_table(), operator==(), serialize(), and stacksWith().