/loot
/loot| Permission level required |
|
|---|---|
| Restrictions |
Cheats only |
{
"title": "<code>/loot</code>",
"rows": [
{
"field": "\n* 2 <sup class=\"noprint nowrap Inline-Template \" title=\"\">[<i><span title=\"This statement only applies to Java Edition\">(link to Java Edition article, displayed as JE) only</span></i>]</sup>\n* 1 <sup class=\"noprint nowrap Inline-Template \" title=\"\">[<i><span title=\"This statement only applies to Bedrock Edition\">(link to Bedrock Edition article, displayed as BE) only</span></i>]</sup>",
"label": "(link to Permission level article, displayed as Permission level<br>required)"
},
{
"field": "(link to Options article, displayed as Cheats) only<sup class=\"noprint nowrap Inline-Template \" title=\"\">[<i><span title=\"This statement only applies to Bedrock Edition\">(link to Bedrock Edition article, displayed as BE) only</span></i>]</sup>",
"label": "(link to Commands#Restrictions article, displayed as Restrictions)"
}
],
"invimages": [],
"images": []
}
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>- 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 disappear 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:
- Loot context provided by each
<SOURCE> Supplied loot context parameters fish thisentity: (If the executor is an entity) The command executor entity.- Origin: The center of the block at the specified position.
- Tool: The specified item.
kill thisentity: The specified entity.- Origin: The command execution position.
- Damage source: The
magicdamage type attackerentity: (If the executor is an entity) The command executor entity.direct_attackerentity: (If the executor is an entity) The command executor entity.attacking_playerentity: (If the executor is a player) The command executor player.
loot thisentity: (If the executor is an entity) The command executor entity.- Origin: The command execution position.
mine thisentity: (If the executor is an entity) The command executor entity.- Origin: The center of the block at the specified position.
- Tool: The specified item.
- Block state: The specified block.
- Block entity: (If the block is a block entity.) Block entity data of the block.
- 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
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_tableregistry). 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 bemainhandandoffhand, 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. And the target selector must/should 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 or single-precision 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.
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
| Command | Trigger | Java Edition | Bedrock Edition |
|---|---|---|---|
| Any | The command is incomplete, or any argument is not specified correctly. | Unparseable | Unparseable |
/... fish ... | <pos> or position: x y z is unloaded or out of the world. | Failed | 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 <entities> <slot> <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> | 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 ... | <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> | 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> | 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 | N/A | N/A | ||
loot spawn ... | On success | 1 | N/A | N/A | |
-{}-/loot replace entity ... <slotId: int> <SOURCE> | On success | When zero item stack is got, outputs 1. Otherwise, outputs the number of targeted entities that have the specified slot | N/A | N/A | |
-{}-/loot replace entity ... <slotId: int> <count: int> <SOURCE> | On success | When zero item stack is got, outputs 1. Otherwise, outputs the number of targeted entities that have all the specified consecutive slots | N/A | N/A |
History
| Java Edition | |||||||
|---|---|---|---|---|---|---|---|
| 1.14 | 18w43a | Added /drop. | |||||
| 18w45a | Renamed /drop to /loot.
| ||||||
/loot got reworked. | |||||||
| 1.20.5 | 24w12a | /loot now also accepts an inline SNBT-formatted loot table definition for the <loot_table>: loot_table argument. | |||||
| Bedrock Edition | |||||||
| 1.18 | beta 1.18.0.21 | Added /loot spawn ... loot .... | |||||
| 1.18 | beta 1.18.0.22 | Removed /loot. | |||||
| 1.18.10 | beta 1.18.10.21 | Re-added /loot. | |||||
| 1.18.10 | beta 1.18.10.24 | Added /loot spawn ... kill ... | |||||
| 1.18.30 | beta 1.18.20.21 | Added /loot give ... | |||||
| beta 1.18.30.20 | Added /loot insert ... | ||||||
| 1.19.0 | beta 1.19.0.30 | Added /loot replace entity ... | |||||
| 1.19.40 | Preview 1.19.40.20 | Added /loot replace block ... | |||||
See also
/give— give specific items to players without specifying a loot table/item — modify specific item slots of entities or container/replaceitem — modify specific item slots of entities or container