Skip to main content

Lootables

Lootables are chests or other containers that generate their contents based on custom rules and probabilities. They can optionally refill themselves on a schedule or in response to dynamic filters.

ElementDescription
<lootables> </lootables>A procedural list of loot.
Sub-elementsValue/Children
<loot> </loot>A generated set of items.Loot Sub-elements
<fill> </fill>Configuration for filling containers with loot.Fill Sub-elements

Loot

The <loot> element defines a generated set of items, using literal <item> elements, and operations for choosing them.

Loot Element

ElementDescriptionValue/Children
<loot>A generated set of items.Loot Sub-elements

Loot Attributes

AttributeDescriptionValue
idUnique identifier used to reference this loot from other places in the XML.String

Loot Sub-elements

ElementDescriptionValue
<item>An item to include in the loot. This can be any type of item element, and can have any item attributes.Item
<any>A random selection of children.
<maybe>Include child conditionally based on a filter.
<all>Include all children.

Random Selection

The <any> element makes a random selection from any number of child elements. Its children can be <option> elements, or any other <loot> sub-element.

Any Attributes

AttributeDescriptionValueDefault
countThe number of child elements to choose.Numeric Range
uniqueSet to true if each child can only be chosen once.
Set to false to allow a child to be chosen multiple times.
true/falsetrue

Any Sub-elements

ElementDescription
<option>A single option for the random selection.

Option Attributes

AttributeDescriptionValueDefault
weightThe weight of this option relative to all others.Number1
filterFilter used to decide the eligibility of this option.Filteralways

Conditional Inclusion

The <maybe> element includes its child elements only if the specified filter matches. The filter is matched against the first player to access the loot.

Maybe Attributes

AttributeDescriptionValue
filterFilter used to decide inclusion of children.Filter

Container Fill

The <fill> element fills containers with generated loot. It will fill anything that has an inventory, and matches its filter property. This can include chests, dispensers, storage minecarts, or any other container block or entity. It will fill containers regardless of where they came from, so if you don't want player-placed chests to be filled, you will need to use blocks filter.

Fill Element

ElementDescription
<fill>Automatically fills containers with loot.

Fill Attributes

AttributeDescriptionValueDefault
lootLoot to fill containers with.Loot
filterSelects which blocks/entities to fill.Filteralways
refill-triggerOptional dynamic filter that causes containers to be refilled.Dynamic Filter
refill-intervalTime to refill containers after they are first accessed.Time Periodoo (never)
refill-clearWhether to clear containers before refilling them.true/falsetrue

Examples

<lootables>
<!-- Define a procedural list of loot -->
<!-- Can be different every time it is used -->
<!-- All operators can be composed within each other -->
<loot id="stuff">
<!-- Always include these items -->
<item material="stone sword"/>
<item material="bow"/>
<!-- Include if filter matches opener of the container -->
<maybe filter="red-team">
<item material="stained clay" damage="14" amount="64"/>
<item material="leather helmet" color="#f00"/>
</maybe>

<!-- Choose one element at random -->
<any>
<item material="stone" damage="1"/>
<item material="stone" damage="2"/>
<item material="stone" damage="3"/>
</any>

<!-- Weighted choice -->
<any>
<option weight="5">
<item material="cookie"/>
</option>
<option weight="3">
<item material="bread"/>
</option>
<option weight="1">
<item material="golden apple"/>
</option>
</any>

<!-- Choose any two unique elements (unique="false" to allow duplicates) -->
<any count="2">
...
</any>

<!-- Choose between 3 and 5 unique elements -->
<any count="3..5">
...
</any>
</loot>

<!-- Define inventories to refill -->
<!-- Filling always happens when a player opens the inventory -->
<!-- Any block or entity that has an inventory (and matches the filter) will be filled -->
<fill loot="stuff" <!-- Loot to fill inventory with -->
filter="chests" <!-- Inventories to fill (blocks or entities) -->
refill-interval="3s" <!-- Minimum interval between refills (default +inf) -->
refill-trigger="..." <!-- Dynamic filter to trigger refill (default none) -->
refill-clear="true" <!-- Clear inventory before refilling (default true) -->
/>
</lootables>