Slot Sources
A slot source selects inventory slots: the slots of an entity or a block entity, the items stored inside an item, or a filtered, limited or merged mix of them. The same builders are used in four places:
| Where | Kore |
|---|---|
| Slot source file | slotSource("name") { ... } |
slots loot table entry |
slots { slotSources { ... } } |
/item source and destination slots |
items.replace(self(), slots, ...) |
/execute if items and if slots |
ifCondition { slots(self(), slots) } |
Several sources in one block are concatenated, a single one is written as an object and several as an array.
Reference: Slot source
Slot Source Files
slotSource writes data/<namespace>/slot_source/<name>.json and returns its SlotSourceArgument:
Another slot source points to a file with reference(hands), which writes {"type": "minecraft:reference", "name": "<namespace>:hands"}.
In Commands
/item and /execute if items|slots take a SlotsArgument, which is one of:
- a slot or a range, written as a slot string:
ARMOR.CHESTisarmor.chest,HOTBARandHOTBAR.all()arehotbar.*; - a slot source file, like
handsabove; - an inline slot source,
inlineSlotSource { ... }, written as SNBT.
items.replace, items.fill and items.override spread the source items over the destination slots differently, here with destination slots [12345] and source items (ABC):
| Function | Result | Destination slots left over |
|---|---|---|
replace |
[ABC45] |
untouched |
fill |
[ABCAB] |
filled by repeating sources |
override |
[ABC__] |
emptied |
/execute if slots counts the selected slots that exist on the target, /execute if items the selected slots whose item matches the predicate. Slot sources used by commands are evaluated with the command_slot_source loot context.
Slot Source Types
Slot Range
Selects the slots of a slot string from an inventory. Without an origin, it reads the loot context's container: the target of the command, or the inventory a loot table runs on.
Available origins: ATTACKING_ENTITY, BLOCK_ENTITY, CONTAINER, DIRECT_ATTACKER, INTERACTING_ENTITY, LAST_DAMAGE_PLAYER, TARGET_ENTITY, THIS.
Contents
Selects the slots stored in the inventory component of the items selected by slotSource:
Available component types: BUNDLE_CONTENTS, CHARGED_PROJECTILES, CONTAINER.
Empty
An empty selection containing no slots:
Filtered
Keeps only the selected slots whose item matches itemFilter:
Group
Merges several slot sources into one:
Limit Slots
Keeps the first limit selected slots:
Reference
Selects the slots of a slot source file:
See Also
- Loot Tables - The
slotsentry - Execute - The
itemsandslotsconditions
