endstone/inventory
Classes
| Name | Description |
|---|---|
BookMeta | Represents the meta for a written book that can have a title, an author, and pages. |
CrossbowMeta | Represents the meta for a crossbow that can have charged projectiles. |
Impl | |
Inventory | Interface to the various inventories. |
ItemFactory | |
ItemMeta | Represents the metadata of a generic item. |
ItemStack | Represents a stack of items. |
ItemType | |
MapMeta | Represents the metadata for a map item. |
PlayerInventory | Interface to the inventory of a Player, including the four armor slots and any extra slots. |
Recipe | Represents some type of crafting recipe. |
WritableBookMeta | Represents the meta for a writable book that can have pages. |
Enums
| Name | Description |
|---|---|
EquipmentSlot |
Type Aliases
| Name | Description |
|---|---|
ItemTypeId | Represents an item type. |
classBookMeta
Defined in <endstone/inventory/meta/book_meta.h>
Bases: WritableBookMeta
Represents the meta for a written book that can have a title, an author, and pages.
Enums
| Name | Description |
|---|---|
Generation | Represents the generation (or level of copying) of a written book. |
Methods
| Name | Description |
|---|---|
hasTitle | Checks for the existence of a title in the book. |
getTitle | Gets the title of the book. |
setTitle | Sets the title of the book. |
hasAuthor | Checks for the existence of an author in the book. |
getAuthor | Gets the author of the book. |
setAuthor | Sets the author of the book. Removes author when given std::nullopt. |
hasGeneration | Checks for the existence of generation level in the book. |
getGeneration | Gets the generation of the book. |
setGeneration | Sets the generation of the book. Removes generation when given std::nullopt. |
enumGeneration
GenerationRepresents the generation (or level of copying) of a written book.
Values
| Name | Value | Description |
|---|---|---|
Original | Book written into a book-and-quill. Can be copied. (Default value) | |
CopyOfOriginal | Book that was copied from an original. Can be copied. | |
CopyOfCopy | Book that was copied from a copy of an original. Can't be copied. |
methhasTitleabstractconst
bool hasTitle() const =0Checks for the existence of a title in the book.
Returns
| Type | Description |
|---|---|
bool | true if the book has a title |
methgetTitleabstractconst
std::string getTitle() const =0Gets the title of the book.
Note
Plugins should check that hasTitle() returns true before calling this method.
Returns
| Type | Description |
|---|---|
std::string | the title of the book |
methsetTitleabstract
void setTitle(std::optional<std::string> title) =0Sets the title of the book.
Note
Limited to 32 characters. Removes title when given std::nullopt.
Parameters
| Name | Type | Description |
|---|---|---|
title | std::optional<std::string> | the title to set |
Returns
| Type | Description |
|---|---|
void | true if the title was successfully set |
methhasAuthorabstractconst
bool hasAuthor() const =0Checks for the existence of an author in the book.
Returns
| Type | Description |
|---|---|
bool | true if the book has an author |
methgetAuthorabstractconst
std::string getAuthor() const =0Gets the author of the book.
Note
Plugins should check that hasAuthor() returns true before calling this method.
Returns
| Type | Description |
|---|---|
std::string | the author of the book |
methsetAuthorabstract
void setAuthor(std::optional<std::string> author) =0Sets the author of the book. Removes author when given std::nullopt.
Parameters
| Name | Type | Description |
|---|---|---|
author | std::optional<std::string> | the author to set |
methhasGenerationabstractconst
bool hasGeneration() const =0Checks for the existence of generation level in the book.
Returns
| Type | Description |
|---|---|
bool | true if the book has a generation level |
methgetGenerationabstractconst
std::optional<Generation> getGeneration() const =0Gets the generation of the book.
Note
Plugins should check that hasGeneration() returns true before calling this method.
Returns
| Type | Description |
|---|---|
std::optional<Generation> | the generation of the book |
methsetGenerationabstract
void setGeneration(std::optional<Generation> generation) =0Sets the generation of the book. Removes generation when given std::nullopt.
Parameters
| Name | Type | Description |
|---|---|---|
generation | std::optional<Generation> | the generation to set |
classCrossbowMeta
Defined in <endstone/inventory/meta/crossbow_meta.h>
Bases: ItemMeta
Represents the meta for a crossbow that can have charged projectiles.
Methods
| Name | Description |
|---|---|
hasChargedProjectiles | Returns whether the item has any charged projectiles. |
getChargedProjectiles | Returns an immutable list of the projectiles charged on this item. |
setChargedProjectiles | Sets the projectiles charged on this item. |
addChargedProjectile | Adds a charged projectile to this item. |
methhasChargedProjectilesabstractconst
bool hasChargedProjectiles() const =0Returns whether the item has any charged projectiles.
Returns
| Type | Description |
|---|---|
bool | whether charged projectiles are present |
methgetChargedProjectilesabstractconst
std::vector<ItemStack> getChargedProjectiles() const =0Returns an immutable list of the projectiles charged on this item.
Returns
| Type | Description |
|---|---|
std::vector<ItemStack> | charged projectiles |
methsetChargedProjectilesabstract
void setChargedProjectiles(std::vector<ItemStack> projectiles) =0Sets the projectiles charged on this item.
Parameters
| Name | Type | Description |
|---|---|---|
projectiles | std::vector<ItemStack> | the projectiles to set |
methaddChargedProjectileabstract
void addChargedProjectile(const ItemStack& item) =0Adds a charged projectile to this item.
Parameters
| Name | Type | Description |
|---|---|---|
item | const ItemStack& | projectile |
classImpl
Defined in <endstone/inventory/item_stack.h>
Methods
meth~Implvirtual
~Impl() =defaultmethcloneabstractconst
std::unique_ptr<Impl> clone() const =0methgetTypeabstractconst
const ItemType& getType() const =0methsetTypeabstract
void setType(ItemTypeId type) =0methgetAmountabstractconst
int getAmount() const =0methsetAmountabstract
void setAmount(int amount) =0methgetDataabstractconst
int getData() const =0methsetDataabstract
void setData(int data) =0methgetTranslationKeyabstractconst
std::string getTranslationKey() const =0methgetMaxStackSizeabstractconst
int getMaxStackSize() const =0methisSimilarabstractconst
bool isSimilar(const Impl& other) const =0methgetItemMetaabstractconst
std::unique_ptr<ItemMeta> getItemMeta() const =0methhasItemMetaabstractconst
bool hasItemMeta() const =0methsetItemMetaabstract
bool setItemMeta(const ItemMeta* meta) =0methgetNbtabstractconst
CompoundTag getNbt() const =0methsetNbtabstract
void setNbt(const CompoundTag& nbt) =0classInventory
Defined in <endstone/inventory/inventory.h>
Interface to the various inventories.
Methods
| Name | Description |
|---|---|
~Inventory | |
getSize | Returns the size of the inventory. |
getMaxStackSize | Returns the maximum stack size for an ItemStack in this inventory. |
getItem | Returns the ItemStack found in the slot at the given index. |
setItem | Stores the ItemStack at the given index of the inventory. |
addItem | Stores the given ItemStacks in the inventory. |
removeItem | Removes the given ItemStacks from the inventory. |
addItem | Stores the given ItemStacks in the inventory. |
removeItem | Removes the given ItemStacks from the inventory. |
getContents | Returns all ItemStacks from the inventory. |
setContents | Completely replaces the inventory's contents. Removes all existing contents and replaces it with the ItemStacks given in the array. |
contains | Checks if the inventory contains any ItemStacks with the given ItemType. |
contains | Checks if the inventory contains any ItemStacks with the given ItemStack. |
contains | Checks if the inventory contains at least the minimum amount specified of exactly matching ItemStacks. |
containsAtLeast | Checks if the inventory contains any ItemStacks with the given ItemType, adding to at least the minimum amount specified. |
containsAtLeast | Checks if the inventory contains ItemStacks matching the given ItemStack whose amounts sum to at least the minimum amount specified. |
all | Finds all slots in the inventory containing any ItemStacks with the given ItemType. |
all | Finds all slots in the inventory containing any ItemStacks with the given ItemStack. |
first | Finds the first slot in the inventory containing an ItemStack with the given ItemType. |
first | Returns the first slot in the inventory containing an ItemStack with the given stack. |
firstEmpty | Returns the first empty Slot. |
isEmpty | Check whether this inventory is empty. An inventory is considered to be empty if there are no ItemStacks in any slot of this inventory. |
remove | Removes all stacks in the inventory matching the given ItemType. |
remove | Removes all stacks in the inventory matching the given stack. |
clear | Clears out a particular slot in the index. |
clear | Clears out the whole Inventory. |
meth~Inventoryvirtual
~Inventory() =defaultmethgetSizeabstractconst
int getSize() const =0Returns the size of the inventory.
Returns
| Type | Description |
|---|---|
int | The size of the inventory |
methgetMaxStackSizeabstractconst
int getMaxStackSize() const =0Returns the maximum stack size for an ItemStack in this inventory.
Returns
| Type | Description |
|---|---|
int | The maximum size for an ItemStack in this inventory. |
methgetItemabstractconst
std::optional<ItemStack> getItem(int index) const =0Returns the ItemStack found in the slot at the given index.
Parameters
| Name | Type | Description |
|---|---|---|
index | int | The index of the Slot's ItemStack to return |
Returns
| Type | Description |
|---|---|
std::optional<ItemStack> | The ItemStack in the slot |
methsetItemabstract
void setItem(int index, std::optional<ItemStack> item) =0Stores the ItemStack at the given index of the inventory.
Parameters
| Name | Type | Description |
|---|---|---|
index | int | The index where to put the ItemStack |
item | std::optional<ItemStack> | The ItemStack to set |
methaddItemabstract
std::unordered_map<int, ItemStack> addItem(std::vector<ItemStack> items) =0Stores the given ItemStacks in the inventory.
Note
This will try to fill existing stacks and empty slots as well as it can.
Note
The returned map contains what it couldn't store, where the key is the index, and the value is the ItemStack. If all items are stored, it will return an empty map.
Parameters
| Name | Type | Description |
|---|---|---|
items | std::vector<ItemStack> | The ItemStacks to add |
Returns
| Type | Description |
|---|---|
std::unordered_map<int, ItemStack> | A map containing items that couldn't be added. |
methremoveItemabstract
std::unordered_map<int, ItemStack> removeItem(std::vector<ItemStack> items) =0Removes the given ItemStacks from the inventory.
Note
It will try to remove 'as much as possible' from the types and amounts you give as arguments.
Note
The returned HashMap contains what it couldn't remove, where the key is the index, and the value is the ItemStack. If all the given ItemStacks are removed, it will return an empty map.
Parameters
| Name | Type | Description |
|---|---|---|
items | std::vector<ItemStack> | The ItemStacks to remove |
Returns
| Type | Description |
|---|---|
std::unordered_map<int, ItemStack> | A map containing items that couldn't be removed. |
methaddItem
std::unordered_map<int, ItemStack> addItem(Args&&... items)Stores the given ItemStacks in the inventory.
Note
This will try to fill existing stacks and empty slots as well as it can.
Note
The returned map contains what it couldn't store, where the key is the index, and the value is the ItemStack. If all items are stored, it will return an empty map.
Parameters
| Name | Type | Description |
|---|---|---|
items | Args&&... | The ItemStacks to add |
Returns
| Type | Description |
|---|---|
std::unordered_map<int, ItemStack> | A map containing items that couldn't be added. |
methremoveItem
std::unordered_map<int, ItemStack> removeItem(Args&&... items)Removes the given ItemStacks from the inventory.
Note
It will try to remove 'as much as possible' from the types and amounts you give as arguments.
Note
The returned HashMap contains what it couldn't remove, where the key is the index, and the value is the ItemStack. If all the given ItemStacks are removed, it will return an empty map.
Parameters
| Name | Type | Description |
|---|---|---|
items | Args&&... | The ItemStacks to remove |
Returns
| Type | Description |
|---|---|
std::unordered_map<int, ItemStack> | A map containing items that couldn't be removed. |
methgetContentsabstractconst
std::vector<std::optional<ItemStack>> getContents() const =0Returns all ItemStacks from the inventory.
Returns
| Type | Description |
|---|---|
std::vector<std::optional<ItemStack>> | An array of ItemStacks from the inventory. Empty slots are represented as std::nullopt. |
methsetContentsabstract
void setContents(std::vector<std::optional<ItemStack>> items) =0Completely replaces the inventory's contents. Removes all existing contents and replaces it with the ItemStacks given in the array.
Parameters
| Name | Type | Description |
|---|---|---|
items | std::vector<std::optional<ItemStack>> | A complete replacement for the contents; the length must be less than or equal to getSize(). |
methcontainsabstractconst
bool contains(const std::string& type) const =0Checks if the inventory contains any ItemStacks with the given ItemType.
Parameters
| Name | Type | Description |
|---|---|---|
type | const std::string& | The item type to check for |
methcontainsabstractconst
bool contains(const ItemStack& item) const =0Checks if the inventory contains any ItemStacks with the given ItemStack.
Note
This will only return true if both the type and the amount of the stack match.
Returns
| Type | Description |
|---|---|
bool | true if any exactly matching ItemStacks were found, false otherwise |
methcontainsabstractconst
bool contains(const ItemStack& item, int amount) const =0Checks if the inventory contains at least the minimum amount specified of exactly matching ItemStacks.
Note
An ItemStack only counts if both the type and the amount of the stack match.
Parameters
Returns
| Type | Description |
|---|---|
bool | true if amount less than 1 or if amount of exactly matching ItemStacks were found, false otherwise |
methcontainsAtLeastabstractconst
bool containsAtLeast(const std::string& type, int amount) const =0Checks if the inventory contains any ItemStacks with the given ItemType, adding to at least the minimum amount specified.
Parameters
| Name | Type | Description |
|---|---|---|
type | const std::string& | The ItemType to check for |
amount | int | The minimum amount |
Returns
| Type | Description |
|---|---|
bool | true if amount is less than 1, true if enough ItemStacks were found to add to the given amount |
methcontainsAtLeastabstractconst
bool containsAtLeast(const ItemStack& item, int amount) const =0Checks if the inventory contains ItemStacks matching the given ItemStack whose amounts sum to at least the minimum amount specified.
Parameters
Returns
| Type | Description |
|---|---|
bool | true if amount less than 1 or enough ItemStacks were found to add to the given amount, false otherwise |
methallabstractconst
std::unordered_map<int, ItemStack> all(const std::string& type) const =0Finds all slots in the inventory containing any ItemStacks with the given ItemType.
The returned map contains entries where, the key is the slot index, and the value is the ItemStack in that slot. If no matching ItemStack is found, an empty map is returned.
Parameters
| Name | Type | Description |
|---|---|---|
type | const std::string& | The ItemType to match against |
Returns
| Type | Description |
|---|---|
std::unordered_map<int, ItemStack> | A map from slot indexes to item at index |
methallabstractconst
std::unordered_map<int, ItemStack> all(const ItemStack& item) const =0Finds all slots in the inventory containing any ItemStacks with the given ItemStack.
Note
This will only match slots if both the type and the amount of the stack match
The returned map contains entries where, the key is the slot index, and the value is the ItemStack in that slot. If no matching ItemStack is found, an empty map is returned.
Returns
| Type | Description |
|---|---|
std::unordered_map<int, ItemStack> | A map from slot indexes to item at index |
methfirstabstractconst
int first(const std::string& type) const =0Finds the first slot in the inventory containing an ItemStack with the given ItemType.
Parameters
| Name | Type | Description |
|---|---|---|
type | const std::string& | The ItemType to look for |
Returns
| Type | Description |
|---|---|
int | The slot index of the given ItemType or -1 if not found |
methfirstabstractconst
int first(const ItemStack& item) const =0Returns the first slot in the inventory containing an ItemStack with the given stack.
Returns
| Type | Description |
|---|---|
int | The slot index of the given ItemStack or -1 if not found |
methfirstEmptyabstractconst
int firstEmpty() const =0Returns the first empty Slot.
Returns
| Type | Description |
|---|---|
int | The first empty Slot found, or -1 if no empty slots. |
methisEmptyabstractconst
bool isEmpty() const =0Check whether this inventory is empty. An inventory is considered to be empty if there are no ItemStacks in any slot of this inventory.
Returns
| Type | Description |
|---|---|
bool | true if empty, false otherwise |
methremoveabstract
void remove(const std::string& type) =0Removes all stacks in the inventory matching the given ItemType.
Parameters
| Name | Type | Description |
|---|---|---|
type | const std::string& | The ItemType to remove |
methremoveabstract
void remove(const ItemStack& item) =0Removes all stacks in the inventory matching the given stack.
Note
This will only match a slot if both the type and the amount of the stack match
methclearabstract
void clear(int index) =0Clears out a particular slot in the index.
Parameters
| Name | Type | Description |
|---|---|---|
index | int | The index to empty. |
methclearabstract
void clear() =0Clears out the whole Inventory.
classItemFactory
Defined in <endstone/inventory/item_factory.h>
Methods
| Name | Description |
|---|---|
~ItemFactory | |
getItemMeta | This creates a new item meta for the item type. |
isApplicable | This method checks the item meta to confirm that it is applicable (no data lost if applied) to the specified ItemStack. |
equals | This method is used to compare two ItemMeta objects. |
asMetaFor | Returns an appropriate item meta for the specified item type. |
meth~ItemFactoryvirtual
~ItemFactory() =defaultmethgetItemMetaabstractconst
std::unique_ptr<ItemMeta> getItemMeta(ItemTypeId type) const =0This creates a new item meta for the item type.
Parameters
| Name | Type | Description |
|---|---|---|
type | ItemTypeId | The item type to consider as base for the meta |
Returns
| Type | Description |
|---|---|
std::unique_ptr<ItemMeta> | a new ItemMeta that could be applied to an item stack of the specified item type |
methisApplicableabstractconst
bool isApplicable(const ItemMeta* meta, ItemTypeId type) const =0This method checks the item meta to confirm that it is applicable (no data lost if applied) to the specified ItemStack.
Parameters
| Name | Type | Description |
|---|---|---|
meta | const ItemMeta* | Meta to check |
type | ItemTypeId | The item type that meta will be applied to |
Returns
| Type | Description |
|---|---|
bool | true if the meta can be applied without losing data, false otherwise |
methequalsabstractconst
This method is used to compare two ItemMeta objects.
Parameters
Returns
| Type | Description |
|---|---|
bool | false if one of the meta has data the other does not, otherwise true |
methasMetaForabstractconst
std::unique_ptr<ItemMeta> asMetaFor(const ItemMeta* meta, ItemTypeId type) const =0Returns an appropriate item meta for the specified item type.
The item meta returned will always be a valid meta for a given ItemStack of the specified item type. It may be a more or less specific meta, and could also be the same meta or meta type as the parameter. The item meta returned will also always be the most appropriate meta.
Parameters
| Name | Type | Description |
|---|---|---|
meta | const ItemMeta* | the meta to convert |
type | ItemTypeId | the item type to convert the meta for |
Returns
| Type | Description |
|---|---|
std::unique_ptr<ItemMeta> | An appropriate item meta for the specified item type. |
classItemMeta
Defined in <endstone/inventory/meta/item_meta.h>
Represents the metadata of a generic item.
Enums
| Name | Description |
|---|---|
Type |
Methods
| Name | Description |
|---|---|
~ItemMeta | |
getType | Gets the type of this item meta. |
hasDisplayName | Checks for existence of a display name. |
getDisplayName | Gets the display name that is set. |
setDisplayName | Sets the display name. |
hasLore | Checks for existence of lore. |
getLore | Gets the lore that is set. |
setLore | Sets the lore for this item or removes lore when given std::nullopt. |
hasEnchants | Checks for the existence of any enchantments. |
hasEnchant | Checks for existence of the specified enchantment. |
getEnchantLevel | Checks for the level of the specified enchantment. |
getEnchants | Returns a copy the enchantments in this ItemMeta. |
addEnchant | Adds the specified enchantment to this item meta. |
removeEnchant | Removes the specified enchantment from this item meta. |
removeEnchants | Removes all enchantments from this item meta. |
hasConflictingEnchant | |
isUnbreakable | Return if the unbreakable tag is true. An unbreakable item will not lose durability. |
setUnbreakable | Sets the unbreakable tag. An unbreakable item will not lose durability. |
hasDamage | Checks to see if this item has damage. |
getDamage | Gets the damage. |
setDamage | Sets the damage. |
hasRepairCost | Checks to see if this has a repair penalty. |
getRepairCost | Gets the repair penalty. |
setRepairCost | Sets the repair penalty. |
clone | Creates a clone of the current metadata. |
getExtras | |
as | |
as |
enumType
TypeValues
| Name | Value | Description |
|---|---|---|
Item | ||
Book | ||
CrossBow | ||
Map | ||
WritableBook |
meth~ItemMetavirtual
~ItemMeta() =defaultmethgetTypeabstractconst
Type getType() const =0Gets the type of this item meta.
Returns
| Type | Description |
|---|---|
Type | type of this item meta |
methhasDisplayNameabstractconst
bool hasDisplayName() const =0Checks for existence of a display name.
Returns
| Type | Description |
|---|---|
bool | true if this has a display name |
methgetDisplayNameabstractconst
std::string getDisplayName() const =0Gets the display name that is set.
Returns
| Type | Description |
|---|---|
std::string | the display name that is set |
methsetDisplayNameabstract
void setDisplayName(std::optional<std::string> name) =0Sets the display name.
Parameters
| Name | Type | Description |
|---|---|---|
name | std::optional<std::string> | the name to set |
methhasLoreabstractconst
bool hasLore() const =0Checks for existence of lore.
Returns
| Type | Description |
|---|---|
bool | true if this has lore |
methgetLoreabstractconst
std::vector<std::string> getLore() const =0Gets the lore that is set.
Returns
| Type | Description |
|---|---|
std::vector<std::string> | a list of lore that is set |
methsetLoreabstract
void setLore(std::optional<std::vector<std::string>> lore) =0Sets the lore for this item or removes lore when given std::nullopt.
Parameters
| Name | Type | Description |
|---|---|---|
lore | std::optional<std::vector<std::string>> | the lore that will be set |
methhasEnchantsabstractconst
bool hasEnchants() const =0Checks for the existence of any enchantments.
Returns
| Type | Description |
|---|---|
bool | true if an enchantment exists on this meta |
methhasEnchantabstractconst
bool hasEnchant(EnchantmentId id) const =0Checks for existence of the specified enchantment.
Parameters
| Name | Type | Description |
|---|---|---|
id | EnchantmentId | enchantment id to check |
Returns
| Type | Description |
|---|---|
bool | true if this enchantment exists for this meta |
methgetEnchantLevelabstractconst
int getEnchantLevel(EnchantmentId id) const =0Checks for the level of the specified enchantment.
Parameters
| Name | Type | Description |
|---|---|---|
id | EnchantmentId | enchantment id to check |
Returns
| Type | Description |
|---|---|
int | The level that the specified enchantment has, or 0 if none |
methgetEnchantsabstractconst
std::unordered_map<const Enchantment*, int> getEnchants() const =0Returns a copy the enchantments in this ItemMeta.
Returns an empty map if none.
Returns
| Type | Description |
|---|---|
std::unordered_map<const Enchantment*, int> | An immutable copy of the enchantments |
methaddEnchantabstract
bool addEnchant(EnchantmentId id, int level, bool force) =0Adds the specified enchantment to this item meta.
Parameters
| Name | Type | Description |
|---|---|---|
id | EnchantmentId | Enchantment id to add |
level | int | Level for the enchantment |
force | bool | this indicates the enchantment should be applied, ignoring the level limit |
Returns
| Type | Description |
|---|---|
bool | true if the item meta changed as a result of this call, false otherwise |
methremoveEnchantabstract
bool removeEnchant(EnchantmentId id) =0Removes the specified enchantment from this item meta.
Parameters
| Name | Type | Description |
|---|---|---|
id | EnchantmentId | Enchantment id to remove |
Returns
| Type | Description |
|---|---|
bool | true if the item meta changed as a result of this call, false otherwise |
methremoveEnchantsabstract
void removeEnchants() =0Removes all enchantments from this item meta.
methhasConflictingEnchantabstractconst
bool hasConflictingEnchant(EnchantmentId id) const =0Checks if the specified enchantment conflicts with any enchantments in this ItemMeta.
Parameters
| Name | Type | Description |
|---|---|---|
id | EnchantmentId | Enchantment id to test |
Returns
| Type | Description |
|---|---|
bool | true if the enchantment conflicts, false otherwise |
methisUnbreakableabstractconst
bool isUnbreakable() const =0Return if the unbreakable tag is true. An unbreakable item will not lose durability.
Returns
| Type | Description |
|---|---|
bool | true if the unbreakable tag is true |
methsetUnbreakableabstract
void setUnbreakable(bool unbreakable) =0Sets the unbreakable tag. An unbreakable item will not lose durability.
Parameters
| Name | Type | Description |
|---|---|---|
unbreakable | bool | true if set unbreakable |
methhasDamageabstractconst
bool hasDamage() const =0Checks to see if this item has damage.
Returns
| Type | Description |
|---|---|
bool | true if this has damage |
methgetDamageabstractconst
int getDamage() const =0Gets the damage.
Returns
| Type | Description |
|---|---|
int | the damage |
methsetDamageabstract
void setDamage(int damage) =0Sets the damage.
Parameters
| Name | Type | Description |
|---|---|---|
damage | int | item damage |
methhasRepairCostabstractconst
bool hasRepairCost() const =0Checks to see if this has a repair penalty.
Returns
| Type | Description |
|---|---|
bool | true if this has a repair penalty |
methgetRepairCostabstractconst
int getRepairCost() const =0Gets the repair penalty.
Returns
| Type | Description |
|---|---|
int | the repair penalty |
methsetRepairCostabstract
void setRepairCost(int cost) =0Sets the repair penalty.
Parameters
| Name | Type | Description |
|---|---|---|
cost | int | repair penalty |
methcloneabstractconst
std::unique_ptr<ItemMeta> clone() const =0Creates a clone of the current metadata.
Returns
| Type | Description |
|---|---|
std::unique_ptr<ItemMeta> | A copy of the metadata containing the same state as the original. |
methgetExtrasabstractconst
const core::ItemMetaExtras& getExtras() const =0methas
T* as()methasconst
const T* as() constclassItemStack
Defined in <endstone/inventory/item_stack.h>
Represents a stack of items.
Methods
| Name | Description |
|---|---|
ItemStack | An item stack. |
ItemStack | |
ItemStack | |
operator= | |
operator= | |
~ItemStack | |
getType | Gets the type of this item. |
setType | Sets the type of this item. |
getAmount | Gets the amount of items in this stack. |
setAmount | Sets the amount of items in this stack. |
getData | Gets the data for this stack of items. |
setData | Sets the data for this stack of items. |
getTranslationKey | Get the translation key, suitable for use in a translation component. |
getMaxStackSize | Get the maximum stack size for this item. |
getNbt | Gets the NBT compound tag of this item stack. |
setNbt | Sets the NBT compound tag of this item stack. |
operator== | |
operator!= | |
isSimilar | Checks if the two stacks are equal, but does not consider stack size (amount). |
getItemMeta | Gets a copy of this ItemStack's ItemMeta. |
hasItemMeta | Checks to see if any metadata has been defined. |
setItemMeta | Set the ItemMeta of this ItemStack. |
methItemStackexplicit
ItemStack(ItemTypeId type, int amount = 1, int data = 0)An item stack.
Parameters
| Name | Type | Description |
|---|---|---|
type | ItemTypeId | the type |
amount | int | the amount in the stack |
data | int | the data value |
methItemStack
ItemStack(const ItemStack& other)methItemStacknoexcept
ItemStack(ItemStack&& other) noexcept=defaultmethoperator=
methoperator=noexcept
meth~ItemStack
~ItemStack() =defaultmethgetTypeconst
const ItemType& getType() constGets the type of this item.
Returns
| Type | Description |
|---|---|
const ItemType& | Type of the items in this stack |
methsetType
void setType(ItemTypeId type)Sets the type of this item.
Parameters
| Name | Type | Description |
|---|---|---|
type | ItemTypeId | New type to set the items in this stack to |
methgetAmountconst
int getAmount() constGets the amount of items in this stack.
Returns
| Type | Description |
|---|---|
int | Amount of items in this stack |
methsetAmount
void setAmount(int amount)Sets the amount of items in this stack.
Parameters
| Name | Type | Description |
|---|---|---|
amount | int | New amount of items in this stack |
methgetDataconst
int getData() constGets the data for this stack of items.
Returns
| Type | Description |
|---|---|
int | Data for this item |
methsetData
void setData(int data)Sets the data for this stack of items.
Parameters
| Name | Type | Description |
|---|---|---|
data | int | New data for this item |
methgetTranslationKeyconst
std::string getTranslationKey() constGet the translation key, suitable for use in a translation component.
Returns
| Type | Description |
|---|---|
std::string | the translation key |
methgetMaxStackSizeconst
int getMaxStackSize() constGet the maximum stack size for this item.
Returns
| Type | Description |
|---|---|
int | The maximum you can stack this item to. |
methgetNbtconst
CompoundTag getNbt() constGets the NBT compound tag of this item stack.
Returns
| Type | Description |
|---|---|
CompoundTag | the NBT compound tag |
methsetNbt
void setNbt(const CompoundTag& nbt)Sets the NBT compound tag of this item stack.
Parameters
| Name | Type | Description |
|---|---|---|
nbt | const CompoundTag& | the NBT compound tag to set |
methoperator==const
bool operator==(const ItemStack& other) constmethoperator!=const
bool operator!=(const ItemStack& other) constmethisSimilarconst
bool isSimilar(const ItemStack& other) constChecks if the two stacks are equal, but does not consider stack size (amount).
Parameters
| Name | Type | Description |
|---|---|---|
other | const ItemStack& | the item stack to compare to |
Returns
| Type | Description |
|---|---|
bool | true if the two stacks are equal, ignoring the amount |
methgetItemMetaconst
std::unique_ptr<ItemMeta> getItemMeta() constGets a copy of this ItemStack's ItemMeta.
Returns
| Type | Description |
|---|---|
std::unique_ptr<ItemMeta> | a copy of the current ItemStack's ItemMeta |
methhasItemMetaconst
bool hasItemMeta() constChecks to see if any metadata has been defined.
Returns
| Type | Description |
|---|---|
bool | Returns true if some metadata has been set for this item |
methsetItemMeta
bool setItemMeta(ItemMeta* meta)Set the ItemMeta of this ItemStack.
Returns
| Type | Description |
|---|---|
bool | True if successfully applied ItemMeta |
classItemType
Defined in <endstone/inventory/item_type.h>
Variables
| Name | Description |
|---|---|
Air |
Methods
| Name | Description |
|---|---|
getTranslationKey | Get the translation key, suitable for use in a translation component. |
getTranslationKey | Get the translation key, suitable for use in a translation component. |
getMaxStackSize | Gets the maximum amount of this item type that can be held in a stack. |
getMaxDurability | Gets the maximum durability of this item type. |
createItemStack | Constructs a new ItemStack with this item type that has the amount 1. |
createItemStack | Constructs a new ItemStack with this item type. |
varAirstaticconstexpr
auto AirmethgetTranslationKeyabstractconstoverride
std::string getTranslationKey() const override=0Get the translation key, suitable for use in a translation component.
Returns
| Type | Description |
|---|---|
std::string | the translation key |
methgetTranslationKeyabstractconst
std::string getTranslationKey(int data) const =0Get the translation key, suitable for use in a translation component.
Parameters
| Name | Type | Description |
|---|---|---|
data | int | Data for this item type |
Returns
| Type | Description |
|---|---|
std::string | the translation key |
methgetMaxStackSizeabstractconst
int getMaxStackSize() const =0Gets the maximum amount of this item type that can be held in a stack.
Returns
| Type | Description |
|---|---|
int | Maximum stack size for this item type |
methgetMaxDurabilityabstractconst
int getMaxDurability() const =0Gets the maximum durability of this item type.
Returns
| Type | Description |
|---|---|
int | Maximum durability for this item type |
methcreateItemStackabstractconst
ItemStack createItemStack() const =0Constructs a new ItemStack with this item type that has the amount 1.
Returns
| Type | Description |
|---|---|
ItemStack | the constructed item stack. |
methcreateItemStackabstractconst
ItemStack createItemStack(int amount) const =0Constructs a new ItemStack with this item type.
Parameters
| Name | Type | Description |
|---|---|---|
amount | int | the amount in the stack |
classMapMeta
Defined in <endstone/inventory/meta/map_meta.h>
Bases: ItemMeta
Represents the metadata for a map item.
Type Aliases
| Name | Description |
|---|---|
MapId |
Methods
| Name | Description |
|---|---|
hasMapId | Checks for existence of a map ID number. |
getMapId | Gets the map ID that is set. This is used to determine what map is displayed. |
setMapId | Sets the map ID. This is used to determine what map is displayed. |
hasMapView | Checks for existence of an associated map. |
getMapView | Gets the map view associated with this map item. |
setMapView | Sets the associated map. This is used to determine what map is displayed. |
typeMapId
std::int64_t MapIdmethhasMapIdabstractconst
bool hasMapId() const =0Checks for existence of a map ID number.
Returns
| Type | Description |
|---|---|
bool | true if this has a map ID number. |
methgetMapIdabstractconst
MapId getMapId() const =0Gets the map ID that is set. This is used to determine what map is displayed.
Returns
| Type | Description |
|---|---|
MapId | the map ID that is set |
methsetMapIdabstract
void setMapId(MapId id) =0Sets the map ID. This is used to determine what map is displayed.
Parameters
| Name | Type | Description |
|---|---|---|
id | MapId | the map id to set |
methhasMapViewabstractconst
bool hasMapView() const =0Checks for existence of an associated map.
Returns
| Type | Description |
|---|---|
bool | true if this item has an associated map |
methgetMapViewabstractconst
MapView* getMapView() const =0Gets the map view associated with this map item.
Note
Plugins should check that hasMapView() returns true before calling this method.
Returns
| Type | Description |
|---|---|
MapView* | the map view, or nullptr if the item hasMapView(), but this map does not exist on the server |
methsetMapViewabstract
void setMapView(const MapView* map) =0Sets the associated map. This is used to determine what map is displayed.
Parameters
| Name | Type | Description |
|---|---|---|
map | const MapView* | the map to set |
classPlayerInventory
Defined in <endstone/inventory/player_inventory.h>
Bases: Inventory
Interface to the inventory of a Player, including the four armor slots and any extra slots.
Methods
| Name | Description |
|---|---|
getHelmet | Return the ItemStack from the helmet slot. |
getChestplate | Return the ItemStack from the chestplate slot. |
getLeggings | Return the ItemStack from the leg slot. |
getBoots | Return the ItemStack from the boots slot. |
setHelmet | Put the given ItemStack into the helmet slot. |
setChestplate | Put the given ItemStack into the chestplate slot. |
setLeggings | Put the given ItemStack into the leggings slot. |
setBoots | Put the given ItemStack into the boots slot. |
getItemInMainHand | Gets the item the player is currently holding in their main hand. |
setItemInMainHand | Sets the item the player is holding in their main hand. |
getItemInOffHand | Gets the item the player is currently holding in their off hand. |
setItemInOffHand | Sets the item the player is holding in their off hand. |
getHeldItemSlot | Get the slot number of the currently held item. |
setHeldItemSlot | Set the slot number of the currently held item. |
methgetHelmetabstractconst
std::optional<ItemStack> getHelmet() const =0Return the ItemStack from the helmet slot.
Returns
| Type | Description |
|---|---|
std::optional<ItemStack> | The ItemStack in the helmet slot |
methgetChestplateabstractconst
std::optional<ItemStack> getChestplate() const =0Return the ItemStack from the chestplate slot.
Returns
| Type | Description |
|---|---|
std::optional<ItemStack> | The ItemStack in the chestplate slot |
methgetLeggingsabstractconst
std::optional<ItemStack> getLeggings() const =0Return the ItemStack from the leg slot.
Returns
| Type | Description |
|---|---|
std::optional<ItemStack> | The ItemStack in the leg slot |
methgetBootsabstractconst
std::optional<ItemStack> getBoots() const =0Return the ItemStack from the boots slot.
Returns
| Type | Description |
|---|---|
std::optional<ItemStack> | The ItemStack in the boots slot |
methsetHelmetabstract
void setHelmet(std::optional<ItemStack> helmet) =0Put the given ItemStack into the helmet slot.
This does not check if the ItemStack is a helmet.
Parameters
| Name | Type | Description |
|---|---|---|
helmet | std::optional<ItemStack> | The ItemStack to use as helmet |
methsetChestplateabstract
void setChestplate(std::optional<ItemStack> chestplate) =0Put the given ItemStack into the chestplate slot.
This does not check if the ItemStack is a chestplate.
Parameters
| Name | Type | Description |
|---|---|---|
chestplate | std::optional<ItemStack> | The ItemStack to use as chestplate |
methsetLeggingsabstract
void setLeggings(std::optional<ItemStack> leggings) =0Put the given ItemStack into the leggings slot.
This does not check if the ItemStack is a pair of leggings.
Parameters
| Name | Type | Description |
|---|---|---|
leggings | std::optional<ItemStack> | The ItemStack to use as leggings |
methsetBootsabstract
void setBoots(std::optional<ItemStack> boots) =0Put the given ItemStack into the boots slot.
This does not check if the ItemStack is a pair of boots.
Parameters
| Name | Type | Description |
|---|---|---|
boots | std::optional<ItemStack> | The ItemStack to use as boots |
methgetItemInMainHandabstractconst
std::optional<ItemStack> getItemInMainHand() const =0Gets the item the player is currently holding in their main hand.
Returns
| Type | Description |
|---|---|
std::optional<ItemStack> | the currently held item |
methsetItemInMainHandabstract
void setItemInMainHand(std::optional<ItemStack> item) =0Sets the item the player is holding in their main hand.
Parameters
| Name | Type | Description |
|---|---|---|
item | std::optional<ItemStack> | The item to put into the player's hand |
methgetItemInOffHandabstractconst
std::optional<ItemStack> getItemInOffHand() const =0Gets the item the player is currently holding in their off hand.
Returns
| Type | Description |
|---|---|
std::optional<ItemStack> | the currently held item |
methsetItemInOffHandabstract
void setItemInOffHand(std::optional<ItemStack> item) =0Sets the item the player is holding in their off hand.
Parameters
| Name | Type | Description |
|---|---|---|
item | std::optional<ItemStack> | The item to put into the player's hand |
methgetHeldItemSlotabstractconst
int getHeldItemSlot() const =0Get the slot number of the currently held item.
Returns
| Type | Description |
|---|---|
int | Held item slot number |
methsetHeldItemSlotabstract
void setHeldItemSlot(int slot) =0Set the slot number of the currently held item.
This validates whether the slot is between 0 and 8 inclusive.
Parameters
| Name | Type | Description |
|---|---|---|
slot | int | The new slot number |
classRecipe
Defined in <endstone/inventory/recipe.h>
Represents some type of crafting recipe.
classWritableBookMeta
Defined in <endstone/inventory/meta/writable_book_meta.h>
Bases: ItemMeta
Represents the meta for a writable book that can have pages.
Methods
| Name | Description |
|---|---|
hasPages | Checks for the existence of pages in the book. |
getPage | Gets the specified page in the book. The given page must exist. |
setPage | Sets the specified page in the book. Pages of the book must be contiguous. |
getPages | Gets all the pages in the book. |
setPages | Clears the existing book pages, and sets the book to use the provided pages. |
setPages | Maximum 50 pages with 798 characters per page. |
addPage | Adds new pages to the end of the book. |
addPage | Adds new pages to the end of the book. |
getPageCount | Gets the number of pages in the book. |
methhasPagesabstractconst
bool hasPages() const =0Checks for the existence of pages in the book.
Returns
| Type | Description |
|---|---|
bool | true if the book has pages |
methgetPageabstractconst
std::string getPage(int page) const =0Gets the specified page in the book. The given page must exist.
Note
Pages are 1-indexed.
Parameters
| Name | Type | Description |
|---|---|---|
page | int | the page number to get, in range [1, getPageCount()] |
Returns
| Type | Description |
|---|---|
std::string | the page from the book |
methsetPageabstract
void setPage(int page, std::string data) =0Sets the specified page in the book. Pages of the book must be contiguous.
Note
The data can be up to 1024 characters in length, additional characters are truncated.
Pages are 1-indexed.
Parameters
| Name | Type | Description |
|---|---|---|
page | int | the page number to set, in range [1, getPageCount()] |
data | std::string | the data to set for that page |
methgetPagesabstractconst
std::vector<std::string> getPages() const =0Gets all the pages in the book.
Returns
| Type | Description |
|---|---|
std::vector<std::string> | list of all the pages in the book |
methsetPages
void setPages(Args&&... pages)Clears the existing book pages, and sets the book to use the provided pages.
Note
Maximum 50 pages with 798 characters per page.
Parameters
| Name | Type | Description |
|---|---|---|
pages | Args&&... | A list of pages to set the book to use |
methsetPagesabstract
void setPages(std::vector<std::string> pages) =0Maximum 50 pages with 798 characters per page.
Note
Clears the existing book pages, and sets the book to use the provided pages.
Parameters
| Name | Type | Description |
|---|---|---|
pages | std::vector<std::string> | A list of strings, each being a page |
methaddPage
void addPage(Args&&... pages)Adds new pages to the end of the book.
Note
Up to a maximum of 50 pages with 798 characters per page.
Parameters
| Name | Type | Description |
|---|---|---|
pages | Args&&... | A list of strings, each being a page |
methaddPageabstract
void addPage(std::vector<std::string> pages) =0Adds new pages to the end of the book.
Note
Up to a maximum of 50 pages with 798 characters per page.
Parameters
| Name | Type | Description |
|---|---|---|
pages | std::vector<std::string> | A list of strings, each being a page |
methgetPageCountabstractconst
int getPageCount() const =0Gets the number of pages in the book.
Returns
| Type | Description |
|---|---|
int | the number of pages in the book |
enumEquipmentSlot
EquipmentSlotValues
| Name | Value | Description |
|---|---|---|
Hand | ||
OffHand | ||
Feet | ||
Legs | ||
Chest | ||
Head | ||
Body | Note Only for certain entities such as horses and wolves. |
typeItemTypeId
Identifier<ItemType> ItemTypeIdRepresents an item type.