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.
Element | Description |
---|---|
<lootables> </lootables> | A procedural list of loot. |
Sub-elements | Value/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
Element | Description | Value/Children |
---|---|---|
<loot> | A generated set of items. | Loot Sub-elements |
Loot Attributes
Attribute | Description | Value |
---|---|---|
id | Unique identifier used to reference this loot from other places in the XML. | String |
Loot Sub-elements
Element | Description | Value |
---|---|---|
<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
Attribute | Description | Value | Default |
---|---|---|---|
count | The number of child elements to choose. | Numeric Range | |
unique | Set to true if each child can only be chosen once.Set to false to allow a child to be chosen multiple times. | true/false | true |
Any Sub-elements
Element | Description |
---|---|
<option> | A single option for the random selection. |
Option Attributes
Attribute | Description | Value | Default |
---|---|---|---|
weight | The weight of this option relative to all others. | Number | 1 |
filter | Filter used to decide the eligibility of this option. | Filter | always |
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
Attribute | Description | Value |
---|---|---|
filter | Filter 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
Element | Description |
---|---|
<fill> | Automatically fills containers with loot. |
Fill Attributes
Attribute | Description | Value | Default |
---|---|---|---|
loot | Loot to fill containers with. | Loot | |
filter | Selects which blocks/entities to fill. | Filter | always |
refill-trigger | Optional dynamic filter that causes containers to be refilled. | Dynamic Filter | |
refill-interval | Time to refill containers after they are first accessed. | Time Period | oo (never) |
refill-clear | Whether to clear containers before refilling them. | true/false | true |
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>