Items
Obtain api with module.TypedContent(ctx) during Load.
On this page
Overview
_, err := api.Items().Register(
content.Item("example:token").
DisplayName("Token").Icon("token").
StackSize(1).Creative(content.Items),
)
Obtain api with module.TypedContent(ctx) during Load. The registrar accepts ItemDefinition and returns (ItemRef, error).
| Field / builder | Meaning | Omitted default |
|---|---|---|
ID / Item(id) | Semantic item ID | Required |
Label / DisplayName(text) | Literal client-visible text | No name component is generated |
IconRef / Icon(alias) | Item atlas reference | Required for ordinary non-placeable items |
StackLimit / StackSize(n) | Maximum stack, 1..64 | 64 |
PlaceableBlock / Places(id) | The named block's default state | No block placement |
CreativeCategory / Creative(category) | Semantic creative placement | Hidden |
An ID does not automatically become a display name. .DisplayName("") and whitespace-only labels are errors; a nil Label means omission. Pulce generates no translation key. Client fallback text for an omitted label is not guaranteed to match across versions.
.Icon("token") references an alias in textures/item_texture.json, not textures/items/token.png. A missing icon on a non-placeable item passes shape validation but causes host normalization to reject startup. StackSize(0) is an explicit invalid value, not a request for the default.
Separate placeable item
Use Places if the block should not generate its own item or you need an additional item:
_, err := api.Items().Register(
content.Item("example:stone_tool").
DisplayName("Stone Tool").Places("example:stone").
StackSize(16).Creative(content.Items),
)
Block references are checked after all modules finish staging, so forward references are allowed. The block must exist in the staged graph or authoritative registry. With an omitted icon, a placeable item uses block-as-icon lowering. An explicit icon is validated separately against the item atlas and replaces the block icon. Plugins do not build block_placer, publisher or use_on components manually.
Places currently selects one default block state. Placement restrictions, multiple-state selection, custom use callbacks and item durability are not represented by this API. The association does not select the block's drops; see blocks.
Struct or builder
Builders return new definition values and copy optional values. The struct API describes the same declaration:
label := "Token"
limit := 1
definition := content.ItemDefinition{
ID: "example:token", Label: &label,
IconRef: resources.ItemTexture("token"), StackLimit: &limit,
}
_, err := api.Items().Register(definition)
Import core/content and core/resources. Pointer fields distinguish omission from explicit values. After Register, the host owns a copy; writing through label, limit or definition cannot change the staged item. Registering the same ID again is a collision, not an update.
Scope synchronization does not synchronize caller memory. Do not concurrently mutate a definition's pointers or slices while registration or cloning reads them.
The public typed API does not yet contain RawComponent, Advanced, OnUse or MaxDamage. Existing complex consumers can retain the legacy API, with different guarantees.
Documentation source
Snapshot from Pulce 4fc8a1bb. This page is generated from committed Markdown; code examples are preserved unchanged.