Drops the given loot table into the specified inventory or into the world.
Syntax[]
- Java Edition
loot <TARGET> <SOURCE>
- In which:
<TARGET>
is:give <players>
- Gives items to players, ignoring empty item stacks.
insert <targetPos>
- Distributes items to a container block.
spawn <targetPos>
- Spawns item entities.
replace block <targetPos> <slot> [<count>]
- Distributes items to a container block.
replace entity <entities> <slot> [<count>]
- Distributes items to entities.
<SOURCE>
is:fish <loot_table> <pos> [<tool>|mainhand|offhand]
loot <loot_table>
kill <target>
mine <pos> [<tool>|mainhand|offhand]
- 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> [count: int]
- Distributes items to a container block.
replace entity <entity: target> <slotType: EntityEquipmentSlot> <slotId: int> [count: int]
- Distributes items to entities.
<SOURCE>
is:kill <entity: target> ["<tool>|mainhand|offhand": string]
loot <loot_table: string> ["<tool>|mainhand|offhand": string]
Arguments[]
JE: <loot_table>
: resource_location
BE: loot_table: string
: basic_string
- Specifies which loot table to use.
- In Java Edition, must be a resource location which will be resolved during command execution into unregistered content or client-side content.
- In Bedrock Edition, must be a string. And it must be a single word that has no space or a quoted string. 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 mine or fish.
- It must be in the format of
item_id{data_tags}
(accepts item and block tags), in which data tags can be omitted when they are not needed.
BE: "<tool>|mainhand|offhand": string
: string
- Specifies a tool to be used to kill or loot.
- Must be a string. And it must be a single word that has no space or a quoted string. Can be
mainhand
andoffhand
, 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.
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 a three-dimensional coordinates with 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 drops.
- Must be a three-dimensional coordinates with floating-point number 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 filled.
- Must be a 32-bit integer number. 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 certain slots 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[]
Command | Trigger | Java Edition | Bedrock Edition |
---|---|---|---|
any | the arguments are not specified correctly | Unparseable | Failed |
/... fish ... | <pos> or position: x y z is unloaded or out of the world | Failed | |
/... mainhand | 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 ... | When one or more item stacks are got, all the targeted entities meet one or more of the following conditions:
| Successful | |
/loot give ... | <players> or player: target fails to resolve to one or more online players | Failed | |
/loot insert ... | <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> ... | 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 | Successful |
/loot replace block <targetPos> <slot> <count> ... | the <count> plus the <slot> id is bigger than the number of all slots in the specified container | Failed | |
any | Otherwise | Successful |
Output[]
Command | Edition | Situation | Success Count | /execute store success ... | /execute store result ... |
---|---|---|---|---|---|
any | Java Edition | On fail | 0 | 0 | 0 |
/loot spawn ... | On success | 1 | 1 | the number of item stacks got from loot | |
/loot give ... | On success | 1 | 1 | the total number of item stacks successfully allocated to each player | |
/loot insert ... | On success | 1 | 1 | the number of item stacks successfully distributed to the container | |
/loot replace block ... | On success | 1 | 1 | the number of item stacks successfully distributed to the container | |
On error | 0 | unchanged | unchanged | ||
/loot replace entity ... | On success | 1 | 1 | the total number of item stacks successfully allocated to each entity | |
On error | 0 | unchanged | unchanged | ||
any | Bedrock Edition | On fail | 0 | N/A | N/A |
loot give ... | On success | [needs testing] | N/A | N/A | |
loot spawn ... | On success | 1 | N/A | N/A | |
loot replace entity ... | On success | When zero item stack is got, return 1.
When one or more item stacks are got, return the number of entities that do not meet any of the following conditions:
| N/A | N/A |
See also[]
/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
History[]
Java Edition | |||||
---|---|---|---|---|---|
1.14 | 18w43a | Added /drop . | |||
18w45a | Renamed /drop to /loot .
| ||||
/loot got reworked. | |||||
Bedrock Edition | |||||
1.18 | beta 1.18.0.21 | Added /loot spawn ... loot ... . | |||
beta 1.18.0.22 | Removed /loot . | ||||
1.18.10 | beta 1.18.10.21 | Re-added /loot . | |||
beta 1.18.10.24 | Added /loot spawn ... kill ... | ||||
1.18.20 | beta 1.18.20.21 | Added /loot give ... | |||
1.18.30 | beta 1.18.30.20 | Added /loot insert ... | |||
1.19.0 | beta 1.19.0.30 | Added /loot replace entity ... | |||
1.19.40 | beta 1.19.40.20 | Added /loot replace block ... |