Minecraft:Slot sources
More actions
Template:Exclusive Template:Move Template:Improve lead Template:Wip Slot sources provide any number of Minecraft:inventory slots in Minecraft:data packs via Template:Cd type Minecraft:loot table entries and in slot_source argument type of Minecraft:commandsTemplate:Upcoming.
Definition
Slot sources may be defined inline, or stored as Minecraft:JSON files and referenced elsewhere, as part of the data pack directory structure:
The root element of a slot source file can be either an Template:Nbt following the slot source structure below, or an Template:Nbt containing multiple slot sources. In the latter case all resulting slots from each source are concatenated together, acting as a shorthand for the Template:Cd type.
Format
- Template:Nbt: The root tag.
- Template:Nbt: The slot source type as a Minecraft:resource location. May be any of Template:Cd.
- Extra fields of the slot source depending on Template:Nbt, described below.
The type values can omit or include the namespace Template:Cd, for example using the type Template:Cd or Template:Cd has the same effect.
Inventory-based types
These types select any number of slots from an inventory provided by Minecraft:loot context.
empty
Empty selection containing no slots.
- Template:Nbt: A slot source
- Template:Nbt: Template:Cd
- No additional fields.
slot_range
Selects slots within a slot range from the inventory of an entity or block entity. Mirrors the behavior of the item_slots used in Template:Cmd previouslyTemplate:Upcoming from the slot source.
- Template:Nbt: A slot source
- Template:Nbt: Template:Cd
- Template:Nbt: (optional, defaults to Template:Cd)Template:Upcoming An entity or block entity from which the slots will be sourced, from loot context. Can be Template:Cd, Template:Cd, Template:Cd, Template:Cd, Template:Cd, Template:Cd, Template:Cd or Template:CdTemplate:Upcoming.
- Template:Nbt: Slot range in the format of Template:Cd or Template:Cd, wildcard (Template:Cd) is accepted (e.g. Template:Cd or Template:Cd)
Inheriting types
The types below restrict, merge or expand on existing slot sources.
group
Merges several slot sources into one, with the resulting selection containing all slots from each slot source provided in the order they appear in Template:Nbt. If a slot is included in more than one slot source, it will be repeated in the resulting slot source.
- Template:Nbt: A slot source
- Template:Nbt: Template:Cd
- Template:NbtTemplate:UpcomingTemplate:NbtTemplate:UpcomingTemplate:Nbt: List of slot sources to join. Has to be inline if the group is top-level to avoid circular definitions.
contents
Selects all non-emptyTemplate:Until slots from the inventory component of one or more items. If no item is stored inside that component, the resulting selection will be empty. If Template:Nbt results in more than one item with that component, the resulting selections will be concatenated as with the Template:Cd type.
- Template:Nbt: A slot source
- Template:Nbt: Template:Cd
- Template:Nbt: The inventory component to target. Allowed values are Template:Cd, Template:Cd, and Template:Cd.
- Template:NbtTemplate:UpcomingTemplate:NbtTemplate:Nbt: A slot source containing slots with item(s) to target.
filtered
Applies a filter to the selected slots, excluding any non-matching slots from the resulting selection.
- Template:Nbt: A slot source
- Template:Nbt: Template:Cd
- Template:Nbt: An Minecraft:item predicate to match against the items in each slot.
- Template:NbtTemplate:UpcomingTemplate:NbtTemplate:Nbt: The slot source to filter.
limit_slots
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.
- Template:Nbt: A slot source
- Template:Nbt: Template:Cd
- Template:Nbt: The maximum number of slots to include in the resulting selection.
- Template:NbtTemplate:UpcomingTemplate:NbtTemplate:Nbt: The slot source to limit.
Example
Example slot source selecting every slot with more than 16 items from the hotbar and armor slots of an entity:<syntaxhighlight lang="json"> {
"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.*"
}
]
} </syntaxhighlight>
History
Template:Navbox Java Edition technical
Minecraft:de:Inventarplatzquelle Minecraft:ja:スロット供与子 Minecraft:pt:Fontes de espaço Minecraft:ru:Источники слотов Minecraft:zh:槽位源