Commands/loot

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

2

Restrictions

None

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

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

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

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

<targetPos>: block_pos (in spawn mode)

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

<entities>: entity

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

<players>: entity

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

<tool>: item_stack

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

<target>: entity

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

<count>: integer

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

<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 ...
<pos> is unloaded or out of the world Failed
/... mainhand
... offhand
the executor is not a living entity
/... kill ...<target> fails to resolve to a single entity (named player must be online)
/loot replace entity ...<entities> fails to resolve to one or more entities (named player must be online)
/loot give ...<players> fails to resolve to one or more online players
/... kill ...the <target> is not a living entity
/loot insert ...
/loot replace block ...
<targetPos> is unloaded or out of the worldif the block at <targetPos> is not a container
the block at <targetPos> is not a container
/loot replace block ...the block does not has the specified <slot>
/loot replace block <targetPos> <slot> ...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.