Docs » API reference » ItemStack

ItemStack

Some of one item: what it is and how many.

An item's type is an ItemType, found by name (ItemType.named("Iron Ingot")). A capture cube holding a Voxelmon is an item too, and its stack names the creature inside.

Plain data, copied between the server and the plugin. Made by the plugin, or read from bags, containers and events.

Fields

FieldDescription
item: ItemTypeItemType item()What it is.
count: i64long count()How many, from 1 to its stack limit.
creature: Option<CreatureId>Optional<Long> creature()The Voxelmon in a capture cube, if it holds one.

ItemType

A kind of item: every block, tool, food, material, piece of gear, cube and station, and a content pack's own items (their numbers last the session; the world keeps them by key).

A handle to something in the game. Once that thing is gone, its calls fail with Gone.

MethodDescription
fn id(&self) -> Result<i64>long id()Its lasting number (a content pack's item: its number this session, 32768 and up).
fn name(&self) -> Result<String>String name()Its name as players see it, such as IRON INGOT.
fn stack_limit(&self) -> Result<i64>long stackLimit()How many fit in one slot.
fn kind(&self) -> Result<ItemKind>ItemKind kind()What sort of item it is.
fn value(&self) -> Result<i64>long value()What it is worth in coins in shops.
fn block(&self) -> Result<Option<BlockType>>Optional<BlockType> block()The block it places, if any.
fn key(&self) -> Result<Option<String>>Optional<String> key()A content pack's item's key (pack:name); none for the game's own.
fn named(name: &str) -> Result<Option<ItemType>>static Optional<ItemType> named(String name)An item by its name (any case), or a content pack's item by its key (pack:name).
fn by_id(id: i64) -> Result<Option<ItemType>>static Optional<ItemType> byId(long id)An item by its number.
fn all() -> Result<Vec<ItemType>>static List<ItemType> all()Every item players can have, the content packs' own after the game's.

ItemKind

What sort of item it is.

One of a fixed set of values.

ValueMeaning
ItemKind::BlockItemKind.BLOCKPlaces a block.
ItemKind::ToolItemKind.TOOLAn axe, pickaxe, shovel, hoe, hammer, rod or the like.
ItemKind::WeaponItemKind.WEAPONA sword, club, bow or trident.
ItemKind::ShieldItemKind.SHIELDA shield.
ItemKind::ArmourItemKind.ARMOURWorn gear.
ItemKind::FoodItemKind.FOODEaten or drunk.
ItemKind::CubeItemKind.CUBEA capture cube.
ItemKind::ObjectItemKind.OBJECTFurniture or a station, placed in the world.
ItemKind::MaterialItemKind.MATERIALAnything else: ores, bars, sticks, cloth.