Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

data/loot_tables/

A loot table: what a creature drops or a container holds, in Minecraft’s shape. Each pool rolls a number of times and each roll picks one entry by weight among those whose conditions hold; functions then change the counts. Rolls are deterministic per source, so replays and previews drop the same items. An archetype’s death names its table; tables can nest. Entries name item kinds. Loaded by the server only.

Registrymanifold:loot-table
Filesdata/loot_tables/*.ron, *.update.ron, *.final.ron
Sidesserver: only the server loads it
Readsmanifold:predicate
ContractGameplay framework, data stage

Entry

A record, written LootTable(..); the name before the parentheses is optional.

FieldTypeRequiredDefaultDescription
idstringyesThe table’s key, <mod-id>:<path> (flagship-game:entities/boar).
contextLootContextnoLootEntityWhat a roll can read.
poolslist of PoolnononeThe pools, each rolled in turn.
functionslist of LootFunctionnononeFunctions applied to everything the table yields.

Example

From tools/test-mods/guide-creature/data/loot_tables/razorback.ron:

LootTable(
    id: "guide-creature:entities/razorback",
    context: LootEntity,
    pools: [
        Pool(rolls: Const(1), entries: [
            Item(item: "guide-creature:bristle", weight: 3,
                 functions: [SetCount(Uniform(min: Const(2), max: Const(5)))]),
            Item(item: "flagship-game:boar_tusk", weight: 1, quality: 2),
        ]),
    ],
)

Types

LootContext

A loot table’s context.

VariantWrittenDescription
LootEntityLootEntityA creature’s drops: conditions may read the victim (This) and its killer (Killer, KillerPlayer).
LootGenericLootGenericDrops without a killer, such as a container; the opener is This.

Pool

A pool of a loot table.

A record: Pool(..) or (..).

FieldTypeRequiredDefaultDescription
rollsnumberno1How many times it rolls (at most 16 in all).
bonus_rollsnumberno0Extra rolls per point of luck, floored.
conditionslist of conditionnononeConditions that must all hold for the pool to roll.
entrieslist of LootEntrynononeThe entries a roll picks from.
functionslist of LootFunctionnononeFunctions applied to what the pool yields.

LootEntry

An entry a pool’s roll may pick. Every entry may also give weight, quality, conditions and functions.

VariantWrittenDescription
ItemItem(item: .., weight: .., quality: .., conditions: .., functions: ..)One item kind.
TableTable(table: .., weight: .., quality: .., conditions: .., functions: ..)Rolls another loot table, with its own draws (at most four deep, no cycles, and a context within this table’s).
EmptyEmpty(weight: .., quality: .., conditions: .., functions: ..)Nothing: a weighted chance of no drop.
AlternativesAlternatives(children: .., weight: .., quality: .., conditions: .., functions: ..)The first child whose conditions hold.
GroupGroup(children: .., weight: .., quality: .., conditions: .., functions: ..)Every child whose conditions hold.

Item fields:

FieldTypeRequiredDefaultDescription
itemstringyesThe item kind (manifold:item-kind key). An unknown key fails the data stage (DATA010).
weightu32no1Its weight among the roll’s entries.
qualityi32no0Weight added per point of luck, floored.
conditionslist of conditionnononeConditions that must all hold for the entry to be picked.
functionslist of LootFunctionnononeFunctions applied to what it yields.

Table fields:

FieldTypeRequiredDefaultDescription
tablestringyesThe table (manifold:loot-table key).
weightu32no1Its weight among the roll’s entries.
qualityi32no0Weight added per point of luck, floored.
conditionslist of conditionnononeConditions that must all hold for the entry to be picked.
functionslist of LootFunctionnononeFunctions applied to what it yields.

Empty fields:

FieldTypeRequiredDefaultDescription
weightu32no1Its weight among the roll’s entries.
qualityi32no0Weight added per point of luck, floored.
conditionslist of conditionnononeConditions that must all hold for the entry to be picked.
functionslist of LootFunctionnononeFunctions; nothing to apply them to.

Alternatives fields:

FieldTypeRequiredDefaultDescription
childrenlist of LootEntrynononeThe children, in order.
weightu32no1Its weight among the roll’s entries.
qualityi32no0Weight added per point of luck, floored.
conditionslist of conditionnononeConditions that must all hold for the entry to be picked.
functionslist of LootFunctionnononeFunctions applied to what it yields.

Group fields:

FieldTypeRequiredDefaultDescription
childrenlist of LootEntrynononeThe children.
weightu32no1Its weight among the roll’s entries.
qualityi32no0Weight added per point of luck, floored.
conditionslist of conditionnononeConditions that must all hold for the entry to be picked.
functionslist of LootFunctionnononeFunctions applied to what it yields.

LootFunction

A function that changes what an entry, pool or table yields.

VariantWrittenDescription
SetCountSetCount(number)Sets the count to a number (SetCount(Uniform(min: Const(1), max: Const(3)))).
AddCountAddCount(number)Adds a number to the count.
LimitCountLimitCount(min: .., max: ..)Clamps the count.
ConditionalConditional(when: .., then: ..)Applies then only when when holds.

LimitCount fields:

FieldTypeRequiredDefaultDescription
minu16yesThe smallest count.
maxu16yesThe largest count, at least min.

Conditional fields:

FieldTypeRequiredDefaultDescription
whenconditionyesThe condition.
thenLootFunctionyesThe function.

Value forms used here: condition, number.