Items and containers
Section notes in abi.h
§E items (SNBT value objects) & containers
Item: enchants, matching, NBT (dedicated fns)
Client-side container resync
container_set_item / _clear / _add_item all write through Container::setItem, which mutates the server's copy and sends nothing. The client keeps rendering whatever it last received, so a bulk rewrite (swapping a player's inventory on a cross-dimension teleport, say) looks like it did nothing until the player clicks a slot and forces a resync.
Call this once after a batch of writes. Batching matters: this pushes the whole container, so calling it per-slot inside a loop is a packet storm for no benefit.
Appended: bulk block reads and writes
Slots
item_get_num
| C |
|---|
| bool (*item_get_num)(PierStr item_snbt, int32_t prop, double* out);
|
- Call:
api->item_get_num(item_snbt, prop, out)
- Parameters:
- item_snbt :
PierStr
- prop :
int32_t
- out :
double*
- Return type:
bool
- Section of abi.h: §E items (SNBT value objects) & containers
- Position in the table: slot 43, counting from 0
- Callers in each binding:
- Rust:
ItemStack::num, ItemStack::count, ItemStack::max_stack_size, ItemStack::aux_value, ItemStack::id, ItemStack::damage and more, 29 in all
- Go:
Item.Count, Item.MaxStackSize, Item.AuxValue, Item.Id, Item.Damage, Item.IsNull and more, 29 in all
- Zig:
Item.count, Item.maxStackSize, Item.auxValue, Item.id, Item.damage, Item.isNull and more, 28 in all
item_get_str
| C |
|---|
| bool (*item_get_str)(PierStr item_snbt, int32_t prop, void* ctx, PierStrSink sink);
|
- Call:
api->item_get_str(item_snbt, prop, ctx, sink)
- Parameters:
- item_snbt :
PierStr
- prop :
int32_t
- ctx :
void*
- sink :
PierStrSink
- Return type:
bool
- Section of abi.h: §E items (SNBT value objects) & containers
- Position in the table: slot 44, counting from 0
- Callers in each binding:
- Rust:
ItemStack::text, ItemStack::type_name, ItemStack::name, ItemStack::custom_name, ItemStack::hover_name, ItemStack::raw_name_id and more, 11 in all
- Go:
Item.TypeName, Item.Name, Item.CustomName, Item.RawNameId, Item.Lore, Item.CanDestroy and more, 12 in all
- Zig:
Item.typeName, Item.name, Item.customName, Item.rawNameId, Item.lore, Item.canDestroy and more, 11 in all
| C |
|---|
| bool (*item_transform)(PierStr item_snbt, int32_t op, PierStr sarg, double narg, void* ctx, PierStrSink out);
|
Rebuild → mutate → serialize; out receives the NEW item SNBT.
- Call:
api->item_transform(item_snbt, op, sarg, narg, ctx, out)
- Parameters:
- item_snbt :
PierStr
- op :
int32_t
- sarg :
PierStr
- narg :
double
- ctx :
void*
- out :
PierStrSink
- Return type:
bool
- Section of abi.h: §E items (SNBT value objects) & containers
- Position in the table: slot 45, counting from 0
- Callers in each binding:
container_size
| C |
|---|
| bool (*container_size)(PierContainerRef ref, int32_t* out);
|
- Call:
api->container_size(ref, out)
- Parameters:
- ref :
PierContainerRef
- out :
int32_t*
- Return type:
bool
- Section of abi.h: §E items (SNBT value objects) & containers
- Position in the table: slot 46, counting from 0
- Callers in each binding:
container_get_item
| C |
|---|
| bool (*container_get_item)(PierContainerRef ref, int32_t slot, void* ctx, PierStrSink sink);
|
Slot content as item SNBT (empty slots yield the air item's SNBT).
- Call:
api->container_get_item(ref, slot, ctx, sink)
- Parameters:
- ref :
PierContainerRef
- slot :
int32_t
- ctx :
void*
- sink :
PierStrSink
- Return type:
bool
- Section of abi.h: §E items (SNBT value objects) & containers
- Position in the table: slot 47, counting from 0
- Callers in each binding:
container_set_item
| C |
|---|
| bool (*container_set_item)(PierContainerRef ref, int32_t slot, PierStr item_snbt);
|
- Call:
api->container_set_item(ref, slot, item_snbt)
- Parameters:
- ref :
PierContainerRef
- slot :
int32_t
- item_snbt :
PierStr
- Return type:
bool
- Section of abi.h: §E items (SNBT value objects) & containers
- Position in the table: slot 48, counting from 0
- Callers in each binding:
container_add_item
| C |
|---|
| bool (*container_add_item)(PierContainerRef ref, PierStr item_snbt);
|
- Call:
api->container_add_item(ref, item_snbt)
- Parameters:
- ref :
PierContainerRef
- item_snbt :
PierStr
- Return type:
bool
- Section of abi.h: §E items (SNBT value objects) & containers
- Position in the table: slot 49, counting from 0
- Callers in each binding:
container_remove_item
| C |
|---|
| bool (*container_remove_item)(PierContainerRef ref, int32_t slot, int32_t count);
|
- Call:
api->container_remove_item(ref, slot, count)
- Parameters:
- ref :
PierContainerRef
- slot :
int32_t
- count :
int32_t
- Return type:
bool
- Section of abi.h: §E items (SNBT value objects) & containers
- Position in the table: slot 50, counting from 0
- Callers in each binding:
container_clear
| C |
|---|
| bool (*container_clear)(PierContainerRef ref);
|
- Call:
api->container_clear(ref)
- Parameters:
- Return type:
bool
- Section of abi.h: §E items (SNBT value objects) & containers
- Position in the table: slot 51, counting from 0
- Callers in each binding:
item_get_enchants
| C |
|---|
| bool (*item_get_enchants)(PierStr item_snbt, void* ctx, PierStrSink sink);
|
SNBT [{id, level},…]
- Call:
api->item_get_enchants(item_snbt, ctx, sink)
- Parameters:
- item_snbt :
PierStr
- ctx :
void*
- sink :
PierStrSink
- Return type:
bool
- Section of abi.h: Item: enchants, matching, NBT (dedicated fns)
- Position in the table: slot 125, counting from 0
- Callers in each binding:
item_set_enchants
| C |
|---|
| bool (*item_set_enchants)(PierStr item_snbt, PierStr enchants_snbt, void* ctx, PierStrSink out);
|
enchants_snbt = [{id, level},…]; out = new item SNBT. NULL on every current host: writing enchantments is not implemented, and item_get_enchants is the read side.
- Call:
api->item_set_enchants(item_snbt, enchants_snbt, ctx, out)
- Parameters:
- item_snbt :
PierStr
- enchants_snbt :
PierStr
- ctx :
void*
- out :
PierStrSink
- Return type:
bool
- Section of abi.h: Item: enchants, matching, NBT (dedicated fns)
- Position in the table: slot 126, counting from 0
- Callers in each binding:
item_matches
| C |
|---|
| bool (*item_matches)(PierStr a, PierStr b);
|
- Call:
api->item_matches(a, b)
- Parameters:
- Return type:
bool
- Section of abi.h: Item: enchants, matching, NBT (dedicated fns)
- Position in the table: slot 127, counting from 0
- Callers in each binding:
item_get_user_data
| C |
|---|
| bool (*item_get_user_data)(PierStr item_snbt, void* ctx, PierStrSink sink);
|
- Call:
api->item_get_user_data(item_snbt, ctx, sink)
- Parameters:
- item_snbt :
PierStr
- ctx :
void*
- sink :
PierStrSink
- Return type:
bool
- Section of abi.h: Item: enchants, matching, NBT (dedicated fns)
- Position in the table: slot 128, counting from 0
- Callers in each binding:
container_refresh
| C |
|---|
| bool (*container_refresh)(PierContainerRef ref);
|
Resend a player-owned container (which 0..3) to its owner. Returns false for block containers (which == 4) — a chest has no single owner to resend to; its viewers are refreshed by the engine's own container transaction path.
- Call:
api->container_refresh(ref)
- Parameters:
- Return type:
bool
- Section of abi.h: Client-side container resync
- Position in the table: slot 155, counting from 0
- Callers in each binding:
container_get_items
| C |
|---|
| bool (*container_get_items)(PierContainerRef ref, void* ctx, PierSlotSink sink);
|
Every slot of a container in one call: the sink receives (slot, item SNBT) for each slot in order, empty slots included as an empty-item snapshot. One container resolution and one FFI crossing replace one of each per slot. Returns false if the container cannot be resolved. Server thread only.
- Call:
api->container_get_items(ref, ctx, sink)
- Parameters:
- ref :
PierContainerRef
- ctx :
void*
- sink :
PierSlotSink
- Return type:
bool
- Section of abi.h: Appended: bulk block reads and writes
- Position in the table: slot 192, counting from 0
- Callers in each binding:
PierItemNumProp
item_get_num keys (query a transient ItemStack rebuilt from SNBT).
| Name |
Value |
Description |
PIER_IPROP_COUNT |
0 |
ItemStackBase::mCount |
PIER_IPROP_MAX_STACK_SIZE |
1 |
ItemStackBase::getMaxStackSize |
PIER_IPROP_AUX_VALUE |
2 |
ItemStackBase::getAuxValue |
PIER_IPROP_ID |
3 |
ItemStackBase::getId |
PIER_IPROP_DAMAGE |
4 |
ItemStackBase::getDamageValue |
PIER_IPROP_IS_NULL |
5 |
ItemStackBase::isNull |
PIER_IPROP_IS_BLOCK |
6 |
ItemStackBase::isBlock |
PIER_IPROP_IS_ENCHANTED |
7 |
ItemStackBase::isEnchanted |
PIER_IPROP_IS_ARMOR |
8 |
ItemStackBase::isArmorItem |
PIER_IPROP_IS_DAMAGEABLE |
9 |
ItemStackBase::isDamageableItem |
PIER_IPROP_IS_DAMAGED |
10 |
ItemStackBase::isDamaged |
PIER_IPROP_MAX_DAMAGE |
11 |
ItemStackBase::getMaxDamage |
PIER_IPROP_IS_UNBREAKABLE |
12 |
ItemStackBase::isUnbreakable |
PIER_IPROP_HAS_DURABILITY |
13 |
ItemStackBase::hasDurability |
PIER_IPROP_IS_POTION |
14 |
ItemStackBase::isPotionItem |
PIER_IPROP_IS_THROWABLE |
15 |
ItemStackBase::isThrowable |
PIER_IPROP_IS_FIRE_RESISTANT |
16 |
ItemStackBase::isFireResistant |
PIER_IPROP_ATTACK_DAMAGE |
17 |
ItemStackBase::getAttackDamage |
PIER_IPROP_REPAIR_COST |
18 |
ItemStackBase::getBaseRepairCost |
PIER_IPROP_ENCHANT_VALUE |
19 |
ItemStackBase::getEnchantValue |
PIER_IPROP_IS_STACKABLE |
20 |
ItemStackBase::isStackable |
PIER_IPROP_IS_MUSIC_DISC |
21 |
ItemStackBase::isMusicDiscItem |
PIER_IPROP_IS_OFFHAND |
22 |
ItemStackBase::isOffhandItem |
PIER_IPROP_USE_DURATION |
23 |
ItemStackBase::getMaxUseDuration |
PIER_IPROP_IS_GLINT |
24 |
ItemStackBase::isGlint |
PIER_IPROP_IS_BUNDLE |
25 |
ItemStackBase::isBundle |
PIER_IPROP_HAS_USER_DATA |
26 |
ItemStackBase::hasUserData |
PIER_IPROP_HAS_CUSTOM_NAME |
27 |
ItemStackBase::hasCustomHoverName |
PierItemStrProp
item_get_str keys.
| Name |
Value |
Description |
PIER_ISTR_TYPE_NAME |
0 |
ItemStackBase::getTypeName ("minecraft:apple") |
PIER_ISTR_NAME |
1 |
ItemStackBase::getName (display) |
PIER_ISTR_CUSTOM_NAME |
2 |
ItemStackBase::getCustomName |
PIER_ISTR_RAW_NAME_ID |
3 |
ItemStackBase::getRawNameId |
PIER_ISTR_LORE |
4 |
SNBT list ["l1","l2"] ItemStackBase::getCustomLore |
PIER_ISTR_CAN_DESTROY |
5 |
SNBT list ["minecraft:stone",…] |
PIER_ISTR_CAN_PLACE_ON |
6 |
SNBT list |
PIER_ISTR_USER_DATA |
7 |
full NBT user data as SNBT |
PIER_ISTR_HOVER_NAME |
8 |
ItemStackBase::getHoverName |
PIER_ISTR_EFFECT_NAME |
9 |
ItemStackBase::getEffectName |
PIER_ISTR_COLOR |
10 |
SNBTItemStackBase::getColor |
PierItemOp
item_transform ops: rebuild → mutate → serialize back (out = new SNBT).
| Name |
Value |
Description |
PIER_IOP_SET_CUSTOM_NAME |
0 |
sarg=name ItemStackBase::setCustomName |
PIER_IOP_SET_DAMAGE |
1 |
narg=damage ItemStackBase::setDamageValue |
PIER_IOP_SET_COUNT |
2 |
narg=count ItemStackBase::mCount |
PIER_IOP_SET_LORE |
3 |
sarg=SNBT list ["l1","l2"] ItemStackBase::setCustomLore |
PIER_IOP_SET_UNBREAKABLE |
4 |
narg=0/1 ItemStackBase::setUnbreakable |
PIER_IOP_HURT_AND_BREAK |
5 |
narg=damage ItemStackBase::hurtAndBreak |
PIER_IOP_SET_REPAIR_COST |
6 |
narg=cost ItemStackBase::setRepairCost |
PIER_IOP_ADD_ENCHANT |
7 |
sarg="name:level" saveEnchantsToUserData |
PIER_IOP_REMOVE_ENCHANTS |
8 |
ItemStackBase::removeEnchants |
PIER_IOP_CLEAR_LORE |
9 |
ItemStackBase::clearCustomLore |
PIER_IOP_RESET_NAME |
10 |
ItemStackBase::resetHoverName |
PIER_IOP_SET_CAN_DESTROY |
11 |
sarg=SNBT list ItemStackBase::setCanDestroy |
PIER_IOP_SET_CAN_PLACE_ON |
12 |
sarg=SNBT list ItemStackBase::setCanPlaceOn |