Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:Slot sources: Difference between revisions

From SAS Gaming Wiki
SyncBot (talk | contribs)
Sync: updated from Minecraft
SyncBot (talk | contribs)
Sync: updated from Minecraft
Line 3: Line 3:
{{improve lead}}
{{improve lead}}
{{wip}}
{{wip}}
'''Slot sources''' provide any number of [[Minecraft:inventory]] slots in [[Minecraft:data pack]]s via {{cd|slots}} type [[Minecraft:loot table]] entries and in [[Minecraft:argument types#minecraft:slot_source|slot_source]] argument type of [[Minecraft:commands]]{{Upcoming|Java 26.3}}.
'''Slot sources''' provide any number of [[Minecraft:inventory]] slots in [[Minecraft:data pack]]s via {{cd|slots}} type [[Minecraft:loot table]] entries and in [[Minecraft:argument types#minecraft:slot_source|slot_source]] argument type of [[Minecraft:commands]].


== Definition ==
== Definition ==
{{in development|Java|section=1||26.3}}


Slot sources may be defined inline, or stored as [[Minecraft:JSON]] files and referenced elsewhere, as part of the data pack directory structure:
Slot sources may be defined inline, or stored as [[Minecraft:JSON]] files and referenced elsewhere, as part of the data pack directory structure:
Line 40: Line 39:
==== slot_range ====
==== slot_range ====


Selects slots within a slot range from the inventory of an entity or block entity. Mirrors the behavior of the [[Minecraft:argument types#minecraft:item_slots|item_slots]] used in {{cmd|item ... from}} previously{{Upcoming|Java 26.3}} from the slot source.
Selects slots within a slot range from the inventory of an entity or block entity. Mirrors the behavior of the [[Minecraft:argument types#minecraft:item_slots|item_slots]] used in {{cmd|item ... from}} previously from the slot source.


<div class="treeview" id="slot_range">
<div class="treeview" id="slot_range">
* {{nbt|compound}}: A slot source
* {{nbt|compound}}: A slot source
** {{nbt|string|type}}: {{cd|slot_range}}
** {{nbt|string|type}}: {{cd|slot_range}}
** {{nbt|string|source}}: (optional, defaults to {{cd|container}}){{Upcoming|Java 26.3}} An entity or block entity from which the slots will be sourced, from loot context. Can be {{cd|block_entity}}, {{cd|this}}, {{cd|attacking_entity}}, {{cd|last_damage_player}}, {{cd|direct_attacker}}, {{cd|target_entity}}, {{cd|interacting_entity}} or {{cd|container}}{{Upcoming|Java 26.3}}.
** {{nbt|string|source}}: (optional, defaults to {{cd|container}}) An entity or block entity from which the slots will be sourced, from loot context. Can be {{cd|block_entity}}, {{cd|this}}, {{cd|attacking_entity}}, {{cd|last_damage_player}}, {{cd|direct_attacker}}, {{cd|target_entity}}, {{cd|interacting_entity}} or {{cd|container}}.
** {{nbt|string|slots}}: [[Minecraft:Slot#Command argument|Slot range]] in the format of {{cd|<slot_type>}} or {{cd|<slot_type>.<slot_number>}}, wildcard ({{cd|*}}) is accepted (e.g. {{cd|armor.chest}} or {{cd|container.*}})
** {{nbt|string|slots}}: [[Minecraft:Slot#Command argument|Slot range]] in the format of {{cd|<slot_type>}} or {{cd|<slot_type>.<slot_number>}}, wildcard ({{cd|*}}) is accepted (e.g. {{cd|armor.chest}} or {{cd|container.*}})
</div>
</div>
Line 60: Line 59:
* {{nbt|compound}}: A slot source
* {{nbt|compound}}: A slot source
** {{nbt|string|type}}: {{cd|group}}
** {{nbt|string|type}}: {{cd|group}}
** {{nbt|string}}{{Upcoming|Java 26.3}}{{nbt|compound}}{{Upcoming|Java 26.3}}{{nbt|list|terms}}: List of slot sources to join. Has to be inline if the group is top-level to avoid circular definitions.
** {{nbt|string}}{{nbt|compound}}{{nbt|list|terms}}: List of slot sources to join. Has to be inline if the group is top-level to avoid circular definitions.
</div>
</div>


Line 71: Line 70:
** {{nbt|string|type}}: {{cd|contents}}
** {{nbt|string|type}}: {{cd|contents}}
** {{nbt|string|component}}: The inventory component to target. Allowed values are {{cd|minecraft:bundle_contents}}, {{cd|minecraft:charged_projectiles}}, and {{cd|minecraft:container}}.
** {{nbt|string|component}}: The inventory component to target. Allowed values are {{cd|minecraft:bundle_contents}}, {{cd|minecraft:charged_projectiles}}, and {{cd|minecraft:container}}.
** {{nbt|string}}{{Upcoming|Java 26.3}}{{nbt|list}}{{nbt|compound|slot_source}}: A slot source containing slots with item(s) to target.
** {{nbt|string}}{{nbt|list}}{{nbt|compound|slot_source}}: A slot source containing slots with item(s) to target.
</div>
</div>


Line 83: Line 82:
** {{nbt|compound|item_filter}}: An [[Minecraft:item predicate]] to match against the items in each slot.
** {{nbt|compound|item_filter}}: An [[Minecraft:item predicate]] to match against the items in each slot.
*** {{Nbt inherit/conditions/item}}
*** {{Nbt inherit/conditions/item}}
** {{nbt|string}}{{Upcoming|Java 26.3}}{{nbt|list}}{{nbt|compound|slot_source}}: The slot source to filter.
** {{nbt|string}}{{nbt|list}}{{nbt|compound|slot_source}}: The slot source to filter.
</div>
</div>


Line 94: Line 93:
** {{nbt|string|type}}: {{cd|limit_slots}}
** {{nbt|string|type}}: {{cd|limit_slots}}
** {{nbt|int|limit}}: The maximum number of slots to include in the resulting selection.
** {{nbt|int|limit}}: The maximum number of slots to include in the resulting selection.
** {{nbt|string}}{{Upcoming|Java 26.3}}{{nbt|list}}{{nbt|compound|slot_source}}: The slot source to limit.
** {{nbt|string}}{{nbt|list}}{{nbt|compound|slot_source}}: The slot source to limit.
</div>
</div>


Line 125: Line 124:
|{{HistoryLine|java}}
|{{HistoryLine|java}}
|{{HistoryLine||1.21.11|dev=25w44a|Added slot sources.}}
|{{HistoryLine||1.21.11|dev=25w44a|Added slot sources.}}
|{{HistoryLine|upcoming java}}
|{{HistoryLine||26.3|dev=snap1|Slot sources can now be defined as files inside a datapack, within the {{cd|slot_source}} folder.|{{cd|minecraft:contents}} is no longer restricted to only selecting non-empty slots.|Added {{cd|minecraft:reference}}.|Changed {{cd|minecraft:slot_range}}.}}
|{{HistoryLine||26.3|dev=snap1|Slot sources can now be defined as files inside a datapack, within the {{cd|slot_source}} folder.|{{cd|minecraft:contents}} is no longer restricted to only selecting non-empty slots.|Added {{cd|minecraft:reference}}.|Changed {{cd|minecraft:slot_range}}.}}
|{{HistoryLine|||dev=snap4|Removed {{cd|minecraft:reference}}.|
|{{HistoryLine|||dev=snap4|Removed {{cd|minecraft:reference}}.|

Revision as of 11:35, 16 September 2026

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:commands.

Definition

Slot sources may be defined inline, or stored as Minecraft:JSON files and referenced elsewhere, as part of the data pack directory structure:

Template:Data pack directory

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

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.

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 previously from the slot source.

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.

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.

filtered

Applies a filter to the selected slots, excluding any non-matching slots from the resulting selection.

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.

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:HistoryTable

Navigation

Template:Navbox Java Edition technical

Minecraft:de:Inventarplatzquelle Minecraft:ja:スロット供与子 Minecraft:pt:Fontes de espaço Minecraft:ru:Источники слотов Minecraft:zh:槽位源