Facts
cinnabar:extension/facts@0.1.0
Native item and effect facts from the pinned tables and the installation’s food definitions.
Requires player-state authority. A callback may make MAX_FACT_READS reads, counted apart
from player-state reads; one more traps it.
Grants: player_state.
Types
food
Food attributes from an installed item definition; saturation is a modifier, not current saturation.
record food {
nutrition: u32,
saturation-modifier: f32,
}
| Member | Type | Description |
|---|---|---|
nutrition | u32 | |
saturation-modifier | f32 |
potion-effect
Amplifier is zero-based; duration none is instant.
record potion-effect {
effect-id: s32,
amplifier: s32,
duration-ticks: option<u64>,
}
| Member | Type | Description |
|---|---|---|
effect-id | s32 | |
amplifier | s32 | |
duration-ticks | option<u64> |
item-facts
Known item properties; absent properties must not be treated as zero.
record item-facts {
max-durability: option<u32>,
food: option<food>,
potion-effects: list<potion-effect>,
}
| Member | Type | Description |
|---|---|---|
max-durability | option<u32> | The pinned maximum; none for items that take no damage or whose maximum is unknown. |
food | option<food> | The installation’s food definition for the identifier or its pinned legacy name. Server item components are not consulted; vitals.held-food reports those. |
potion-effects | list<potion-effect> | The effects of the potion that potions, splash and lingering potions carry by metadata, and tipped arrows by metadata minus one. Durations are the potion’s own, a quarter of them for lingering potions; tipped arrows report the carried potion’s. |
Types: food, potion-effect.
food-item
One installed food definition; metadata none applies to every variant of the item.
record food-item {
identifier: string,
metadata: option<u32>,
food: food,
}
| Member | Type | Description |
|---|---|---|
identifier | string | |
metadata | option<u32> | |
food | food |
Types: food.
effect-facts
A status effect’s localization key and HUD icon texture as JSON-UI names it, without an extension; the texture is empty for effects without a HUD icon.
record effect-facts {
name-key: string,
texture: string,
}
| Member | Type | Description |
|---|---|---|
name-key | string | |
texture | string |
Functions
read-item
read-item: func(identifier: string, metadata: u32) -> result<option<item-facts>, string>;
None when neither the pinned item facts nor the installed food know the identifier.
Types: item-facts.
read-foods
read-foods: func() -> result<list<food-item>, string>;
Every item the installation’s food table defines, by the identifiers read-item
resolves: a pinned legacy name is listed as the items that alias it. The table defines
food per identifier, so metadata is none. Sorted by identifier, at most
facts::MAX_FOOD_ITEMS, keeping the first; identifiers over MAX_ITEM_IDENTIFIER_BYTES
are left out. Empty while no food table is installed. One read.
Types: food-item.
read-effect
read-effect: func(effect-id: s32) -> result<option<effect-facts>, string>;
None for an unknown effect id.
Types: effect-facts.