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 slot source file is written as one object (several sources are wrapped in a group), a field takes a single source 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:
A file is always one source object. Several sources, or a lone reference, are written as a group, which Kore does for you: slotSource("alias") { reference(hands) } is written as
Another slot source points to a file with reference(hands), which writes the bare string "<namespace>:hands", see Reference. A slotSource { } without any source throws when the pack is generated, empty() selects no slot.
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. A lonereference(hands)is the quoted ID:item fill entity @s "my_pack:hands" with minecraft:stone.
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, written as its bare ID. reference(id) takes the SlotSourceArgument returned by slotSource, or a SlotSourceTagArgument to select the slots of every source of a tag:
Every slot_source field (contents, filtered, limitSlots, the slots loot entry), the terms of a group and an inline slot source accept an ID, a tag, an inline source or a list mixing IDs and inline sources. A tag can't be one of the list's elements, only the whole list. A slot source file doesn't: it is always an object.
A slot source that references itself, directly or through other files, makes the pack fail to load.
See Also
- Loot Tables - The
slotsentry - Execute - The
itemsandslotsconditions
