Commands/loot

From Minecraft Wiki
Jump to: navigation, search
Information icon.svg
This feature is exclusive to Java Edition.
loot
Restrictions

Operator

First introduced

Java Edition 1.14 (18w43a)

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

Syntax[edit]

loot <TARGET> <SOURCE>
<TARGET>:
spawn <targetPos>
Spawns item entities.
replace entity <entities> <slot> [<count>]
Distributes items to entities.
replace block <targetPos> <slot> [<count>]
Distributes items to a container block.
give <players>
Gives items to players, ignoring empty item stacks.
insert <targetPos>
Distributes items to a container block.
<SOURCE>:
fish <loot_table> <pos> [<tool>|mainhand|offhand]
loot <loot_table>
kill <target>
mine <pos> [<tool>|mainhand|offhand]

Arguments[edit]

<loot_table>: resource_location

Must be a namespaced ID.
Specifies which loot table to use.

<pos>: block_pos and <targetPos>: block_pos (in replace block and insert mode)

It must be a block position composed of <x>, <y> and <z>, each of which must be an integer or tilde and caret notation.
Specifies the position of a block.

<targetPos>: block_pos (in spawn mode)

Must be a three-dimensional coordinates with floating-point number elements. Accepts tilde and caret notations.
Specifies the location where item drops.

<entities>: entity

Must be a player name, a target selector or a UUID
Specifies one or more entities to modify.

<players>: entity

Must be a player name, a target selector or a UUID. And the target selector must be of player type.
Specifies one or more players to give.

<tool>: item_stack

It must be a item argument (does not accept item tags).
Specifies an tool to mine or fish.

<target>: entity

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

<count>: integer

Must be a 32-bit integer number. And it must be between 0 and 2147483647 (inclusive).
Specifies the number of consecutive slots to be filled. If the target is a block, <slot_number> + <count> cannot exceed the greatest slot number.

<slot>: item_slot

Specifies the inventory slot to be modified. Valid values depend on whether a block or an entity is being modified.
For blocks, must be container.<slot_number> where <slot_number> is replaced with a number specifying the slot.
  • Chests, dispensers, droppers, hoppers, and trapped chests are numbered 0 for the top-left slot and then increase first horizontally, then vertically (so, for example, a chest's top row slots are numbered 0 to 8 from left to right). Double chests and double trapped chests are treated as two single container blocks.
  • A brewing stand's bottom slots are numbered 0 to 2 from left to right, its top slot is 3 and the fuel slot is 4.
  • A furnace's slots are numbered 0 for the input slot, 1 for the fuel slot, and 2 for the output slot.
Other blocks which hold items but don't have inventory GUIs (flower pots and jukeboxes) can be changed only with /data.
For entities, must be one of the following, where <slot_number> is replaced with a number specifying the slot:
Slot Slot Numbers Restrictions
armor.chest armor stands, mobs, and players only (though not all mobs show or make use of the items)
armor.feet
armor.head
armor.legs
weapon.mainhand
weapon.offhand
container.slot_number 0–53 players, item frames (slot 0), and minecarts only
enderchest.slot_number 0–26 players only
hotbar.slot_number 0–8
inventory.slot_number 0–26
horse.saddle horses, donkeys, and mules only; item must be a saddle
horse.chest donkeys, and mules only; item must be a chest
horse.armor horses and llamas only; item must be a type of horse armor (if a horse) or a carpet (if a llama)
horse.slot_number 0–14 donkeys and mules with chests only
villager.slot_number 0–7 villagers only

Result[edit]

CommandTriggerJava Edition
anythe arguments are not specified correctly Unparseable
/... fish ...
/... mine ...
if <pos> is unloaded or out of the world Failed
/... mainhand
... offhand
if the executor is not a living entity
/... kill ...if <target> fails to resolve to a single entity (named player must be online)
/loot replace entity ...if <entities> fails to resolve to one or more entities (named player must be online)
/loot give ...if <players> fails to resolve to one or more online players
/... kill ...if the <target> is not a living entity
/loot insert ...
/loot replace block ...
if <targetPos> is unloaded or out of the worldif the block at <targetPos> is not a container
if the block at <targetPos> is not a container
/loot replace block ...if the block does not has the specified <slot>
/loot replace block <targetPos> <slot> ...if the number of item stacks got from loot plus the <slot> id is bigger than the number of all slots in the specified container Error
/loot replace block <targetPos> <slot> <count> ...if the <count> plus the <slot> id is bigger than the number of all slots in the specified container
anyOn successDrops the given loot table into the specified inventory or into the world.

Output[edit]

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 players
/loot insert ...On success11the total number of item stacks successfully distributed to the container
/loot replace block ...On success11the total 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 entities
On error0unchangedunchanged

See also[edit]

  • /give — give specific items to players without specifying a loot table

History[edit]

Java Edition
1.1418w43aAdded /drop.
18w45aRenamed /drop to /loot.
/loot got reworked.