Items

Item types

There are three kinds of items: nodes, tools and craftitems.

  • Node: Can be placed in the world's voxel grid
  • Tool: Has a wear property but cannot be stacked. The default use action is to dig nodes or hit objects according to its tool capabilities.
  • Craftitem: Cannot dig nodes or be placed

Amount and wear

All item stacks have an amount between 0 and 65535. It is 1 by default. Tool item stacks can not have an amount greater than 1.

Tools use a wear (damage) value ranging from 0 to 65535. The value 0 is the default and is used for unworn tools. The values 1 to 65535 are used for worn tools, where a higher value stands for a higher wear. Non-tools always have a wear value of 0.

Item formats

Items and item stacks can exist in three formats: Serializes, table format and ItemStack.

When an item must be passed to a function, it can usually be in any of these formats.

Serialized

This is called "stackstring" or "itemstring". It is a simple string with 1-3 components: the full item identifier, an optional amount and an optional wear value. Syntax:

<identifier> [<amount>[ <wear>]]

Examples:

  • 'default:apple': 1 apple
  • 'default:dirt 5': 5 dirt
  • 'default:pick_stone': a new stone pickaxe
  • 'default:pick_wood 1 21323': a wooden pickaxe, ca. 1/3 worn out

Table format

Examples:

5 dirt nodes:

{name="default:dirt", count=5, wear=0, metadata=""}

A wooden pick about 1/3 worn out:

{name="default:pick_wood", count=1, wear=21323, metadata=""}

An apple:

{name="default:apple", count=1, wear=0, metadata=""}

ItemStack

A native C++ format with many helper methods. Useful for converting between formats. See the [Class reference] section for details.