/loot

Jump to navigation Jump to search
/loot
Permission level
required
  • 2 ‌[JE only]
  • 1 ‌[BE only]
Restrictions

Cheats only‌[BE only]

Drops the given loot table into the specified inventory or into the world.

Syntax[edit | edit source]

  • Java Edition
loot <TARGET> <SOURCE>
In which:
<TARGET> is:
give <players>
Distributes items to players, ignoring empty item stacks.
insert <targetPos>
Distributes items to a container block, ignoring empty item stacks.
spawn <targetPos>
Spawns item entities. Empty item stacks are also spawned, but disappears instantly.
replace block <targetPos> <slot>
replace entity <targetPos> <slot>
Replaces item stacks into some consecutive slots in order. An empty item stack generated by the <SOURCE> clears a slot.
replace block <targetPos> <slot> <count>
replace entity <entities> <slot> <count>
Clears some consecutive slots, and then places item stacks into them in order. Empty item stacks are also placed. If the number of item stacks generated by the <SOURCE> exceeds the specified slot number, excess item stacks are ignored.
<SOURCE> is:
fish <loot_table> <pos> [<tool>|mainhand|offhand]
Simulates fishing with a specified tool at a specified position.
loot <loot_table>
Invokes a loot table directly.
kill <target>
Simulates killing a specified entity.
mine <pos> [<tool>|mainhand|offhand]
Simulates mining a block at a specified position with a specified tool.
Loot context provided by each <SOURCE> is:
  • Bedrock Edition
loot <TARGET> <SOURCE>
In which:
<TARGET> is:
give <player: target>
Gives items to players, ignoring empty item stacks.
insert <position: x y z>
Distributes items to a container block, ignoring empty item stacks.
spawn <position: x y z>
Spawns item entities, ignoring empty item stacks.
replace block <position: x y z> slot.container <slotId: int>
replace entity <entity: target> <slotType: EntityEquipmentSlot> <slotId: int>
Replaces item stacks into some consecutive slots in order. An empty item stack generated by the <SOURCE> clears a slot.
replace block <position: x y z> slot.container <slotId: int> [count: int]
replace entity <entity: target> <slotType: EntityEquipmentSlot> <slotId: int> [count: int]
Clears some consecutive slots, and then places item stacks into them in order. Empty item stacks are also placed. If the number of item stacks generated by the <SOURCE> exceeds the specified slot number, excess item stacks are ignored. An entity or a container must have all the specified consecutive slots in order to clear and place items in it.
<SOURCE> is:
kill <entity: target> ["<tool>|mainhand|offhand": string]
Simulates killing a specified entity with a specified tool.
loot <loot_table: string> ["<tool>|mainhand|offhand": string]
Invokes a loot table with a specified tool.

Arguments[edit | edit source]

JE: <loot_table>: loot_table BE: loot_table: string: basic_string

Specifies which loot table to use.
In Java Edition, specifies a loot table with a resource location or in SNBT format. Must be a valid loot table definition in SNBT format, or a resource location of an existing loot table (an entry in minecraft:loot_table registry). For NBT tag, if it is a string tag, the tag is also parsed into a resource location and resolved into an existing loot table; otherwise, the tag is parsed as a new loot table definition.
In Bedrock Edition, must be a string. And it must be a single word that has no space or a double-quoted string (When quoted, \ can be used to escape characters). And it refers to a loot table with the path of "loot_tables/loot_table: string.json".

JE: <tool>: item_stack

Specifies a tool to simulatively mine or fish.
It must be in the format of item_id[data_components], in which [data_components] can be omitted when they are not needed. See minecraft:item_stack for details.

BE: "<tool>|mainhand|offhand": string: basic_string

Specifies a tool to be used to simulatively kill or loot.
Must be a string. And it must be a single word that has no space or a double-quoted string (When quoted, \ can be used to escape characters). Can be mainhand and offhand, otherwise it represents an item id.

JE<target>: entity
BE: entity: target: CommandSelector<Actor> (in kill source)

Specifies one entity to kill simulatively.
Must be a player name, a target selector or a UUID. And the target selector must be in single type.

JE<players>: entity
BE: player: target: CommandSelector<Player>

Specifies one or more players to give.
Must be a player name, a target selector or a UUID[Java Edition only]. And the target selector must‌[JE only]/should‌[BE only] be of player type. In Bedrock Edition, the target selector should be of player type.

JE: <pos>: block_pos and <targetPos>: block_pos (in replace block and insert mode)
BE: position: x y z: CommandPositionFloat (in replace block and insert mode)

Specifies the position of a block.
In Java Edition: must be a block position composed of <X>, <Y> and <Z>, each of which must be an integer or a tilde and caret notation.
In Bedrock Edition: must be three-dimensional coordinates with single-precision floating-point number elements. Accepts tilde and caret notations.

JE<targetPos>: block_pos
BE: position: x y z: CommandPositionFloat (in spawn mode)

Specifies the location where item entities drop.
Must be three-dimensional coordinates with double-precision floating-point number[Java Edition only] or single-precision floating-point number[Bedrock Edition only] elements. Accepts tilde and caret notations.

JE<entities>: entity
BE: entity: target: CommandSelector<Actor>

Specifies one or more entities to modify.
Must be a player name, a target selector or a UUID[Java Edition only].

JE<count>: integer
BE: count: int: int

Specifies the number of consecutive slots to be cleared.
Must be a [Int]32-bit integer number (from -2147483648 (-231) to 2147483647 (231-1) ). In Java Edition, it must be between 0 and 2147483647 (inclusive).

JE: <slot>: item_slot
BE: slotType: EntityEquipmentSlot: enum, slot.container, and slotId: int: int

Specifies the inventory slot to be modified.
Must be a string notation that refer to a single slot in the inventory, which consists of "slot type" and optional "slot number", in the format of <slot_type> or <slot_type>.<slot_number> in Java Edition, or <slot_type> <slot_number> in Bedrock Edition. See Slot for details.

Result[edit | edit source]

CommandTriggerJava EditionBedrock Edition
AnyThe command is incomplete, or any argument is not specified correctly. Unparseable Unparseable
/... fish ...
/... mine ...
<pos> or position: x y z is unloaded or out of the world. Failed Failed
/... mainhand
/... offhand
The executor is not a living entity. N/A
The executor is not an entity. Failed
/... kill ...<target> or entity: target fails to resolve to a single entity (named player must be online).
The target is not a living entity. N/A
The target has no loot table. N/A Failed
/... loot ...The loot_table: string is not a valid loot table.
/loot replace entity ...<entities> or entity: target fails to resolve to one or more entities (named player must be online). Failed
/loot replace entity <entities> <slot> <SOURCE>
/loot replace entity ... <slotId: int> <SOURCE>
One or more item stacks are got, and all the targeted entities do not have the specified slot. Successful
-{}-/loot replace entity <entities> <slot> <count> <SOURCE>
/loot replace entity ... <slotId: int> <count: int> <SOURCE>
One or more item stacks are got, and all the targeted entities do not have all the specified consecutive slots.
/loot give ...<players> or player: target fails to resolve to one or more online players. Failed
/loot insert ...
/loot replace block ...
<targetPos> or position: x y z is unloaded or out of the world.
The block at <targetPos> or position: x y z is not a container.
/loot replace block ...The block does not have the specified slot.
/loot replace block <targetPos> <slot> <SOURCE>
/loot replace block ... <slotId: int> <SOURCE>
The number of item stacks got from the source plus the <slot> id is bigger than the number of all slots in the specified container. Error Successful
/loot replace block <targetPos> <slot> <count> <SOURCE>
/loot replace block ... <slotId: int> <count: int> <SOURCE>
The <count> plus the <slot> id is bigger than the number of all slots in the specified container. Failed
AnyOtherwiseSuccessful

Output[edit | edit source]

CommandEditionSituationSuccess Count/execute store success .../execute store result ...
AnyJava EditionOn fail000
/loot spawn ...On success11the number of item stacks got from loot
/loot give ...On success11the total number of item stacks successfully allocated to each player
/loot insert ...On success11the number of item stacks successfully distributed to the container
/loot replace block ...On success11the number of item stacks successfully distributed to the container
On error0unchangedunchanged
/loot replace entity ...On success11the total number of item stacks successfully allocated to each entity
On error0unchangedunchanged
AnyBedrock EditionOn fail0N/AN/A
loot give ...On success[needs testing]N/AN/A
loot spawn ...
loot insert ...
On success1N/AN/A
-{}-/loot replace entity ... <slotId: int> <SOURCE>On successWhen zero item stack is got, outputs 1.
Otherwise, outputs the number of targeted entities that have the specified slot
N/AN/A
-{}-/loot replace entity ... <slotId: int> <count: int> <SOURCE>On successWhen zero item stack is got, outputs 1.
Otherwise, outputs the number of targeted entities that have all the specified consecutive slots
N/AN/A

History[edit | edit source]

[hide]Java Edition
1.1418w43aAdded /drop.
18w45aRenamed /drop to /loot.
/loot got reworked.
1.20.524w12a/loot now also accepts an inline SNBT-formatted loot table definition for the <loot_table>: loot_table argument.
[hide]Bedrock Edition
1.18beta 1.18.0.21Added /loot spawn ... loot ....
1.18beta 1.18.0.22Removed /loot.
1.18.10beta 1.18.10.21Re-added /loot.
1.18.10beta 1.18.10.24Added /loot spawn ... kill ...
1.18.30beta 1.18.20.21Added /loot give ...
beta 1.18.30.20Added /loot insert ...
1.19.0beta 1.19.0.30Added /loot replace entity ...
1.19.40Preview 1.19.40.20Added /loot replace block ...

See also[edit | edit source]

  • /give — give specific items to players without specifying a loot table
  • /item[Java Edition only] — modify specific item slots of entities or container
  • /replaceitem[Bedrock Edition only] — modify specific item slots of entities or container

Navigation[edit | edit source]