Slot sources
This article's lead section is missing or may not adequately summarize its contents.
You can help by improving it. To do this, add a few sentences at the beginning of the article that summarize the article's subject.
This article is a work in progress.
Please help expand and improve it. The talk page may contain suggestions.
Slot sources allow the location of any inventory slot to be specified within data packs.
- Format: object with fields.
type: the slot source type.<type-specific>: additional fields depending on the type.
minecraft:emptyType- Empty selection containing no slots.
minecraft:groupType- Merges several slot sources into one, with the resulting selection containing all slots from each slot source provided.
- If a slot is included in more than one slot source, it will be repeated in the resulting slot source.
- e.g.
[a, b] + [c, a]->[a, b, c, a]
- Format:
terms: list of slot sources to join.
- Can alternatively be written inline as a list of slot sources.
- Merges several slot sources into one, with the resulting selection containing all slots from each slot source provided.
minecraft:slot_rangeType- Selects slots within a slot range from the inventory of an entity or block entity.
- Mirrors the behavior of the
fromargument of the/itemcommand. - Format:
source: an entity or block entity from which the slots will be sourced, from loot context.- Can be
block_entity, this,attacking_entity,last_damage_player,direct_attacker,target_entity, orinteracting_entity
- Can be
slots: a slot range in the format of<slot_type>or<slot_type>.<slot_number>(e.g.armor.chestorcontainer.*).
minecraft:contentsType- Selects all non-empty slots from the inventory component of one or more items.
- If no item is stored inside that component, the resulting selection will be empty.
- The location of the item(s) whose inventory component to use is specified by another slot source.
- If the slot source includes more than one item with that component, the resulting selections will be merged identically as with the
minecraft:grouptype. - e.g.
Bundle [a, b] + Shulker Box [c, d]->[a, b, c, d]
- If the slot source includes more than one item with that component, the resulting selections will be merged identically as with the
- Format:
component: the inventory component to target.- Allowed values are
minecraft:bundle_contents,minecraft:charged_projectiles, andminecraft:container
- Allowed values are
slot_source: a slot source containing slots with item(s) to target.
- Selects all non-empty slots from the inventory component of one or more items.
minecraft:filteredType- Applies a filter to the selected slots, excluding any non-matching slots from the resulting selection.
- Format:
item_filter: an item predicate to match against the items in each slot.slot_source: the slot source to filter.
minecraft:limit_slotsType- Limits the number of slots provided, with the resulting selection containing at most that number of slots.
- Any slots bringing the number of slots above that limit will be excluded, in order of inclusion.
- e.g.
[a, b, c, d]->[a, b, c]if the limit is set to3
- Format:
limit: integer, the maximum number of slots to include in the resulting selection.slot_source: the slot source to limit.
- Limits the number of slots provided, with the resulting selection containing at most that number of slots.
- Example slot source selecting every slot with more than 16 items from the hotbar and armor slots of an entity:
{ "type": "minecraft:filtered", "item_filter": { "count": { "min": 16 } }, "slot_source": [ { "type": "minecraft:slot_range", "source": "this", "slots": "hotbar.*" }, { "type": "minecraft:slot_range", "source": "this", "slots": "armor.*" } ] }
History
| Java Edition | |||||||
|---|---|---|---|---|---|---|---|
| 25w44a | Added slot sources. | ||||||
| |||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||