217 lines
12 KiB
Text
217 lines
12 KiB
Text
{{Infobox command
|
|
|name=loot
|
|
|oplevel=
|
|
* 2 {{only|java|short=1}}
|
|
* 1 {{only|bedrock|short=1}}
|
|
|others=[[Options|Cheats]] only{{only|bedrock|short=1}}
|
|
}}
|
|
|
|
Drops the given [[loot table]] into the specified inventory or into the world.
|
|
|
|
==Syntax==
|
|
* '''Java Edition'''
|
|
: <code>loot <''TARGET''> <''SOURCE''></code>
|
|
::In which:
|
|
::<code><''TARGET''></code> is:
|
|
::: <code>give <players></code>
|
|
:::: Distributes items to players, ignoring empty item stacks.
|
|
::: <code>insert <targetPos></code>
|
|
:::: Distributes items to a container block, ignoring empty item stacks.
|
|
::: <code>spawn <targetPos></code>
|
|
:::: Spawns item entities. Empty item stacks are also spawned, but disappears instantly.
|
|
::: <code>replace block <targetPos> <slot></code>
|
|
::: <code>replace entity <targetPos> <slot></code>
|
|
:::: Replaces item stacks into some consecutive [[slot]]s in order. An empty item stack generated by the <''SOURCE''> clears a slot.
|
|
::: <code>replace block <targetPos> <slot> <count></code>
|
|
::: <code>replace entity <entities> <slot> <count></code>
|
|
:::: Clears some consecutive [[slot]]s, 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.
|
|
|
|
::<code><''SOURCE''></code> is:
|
|
::: <code>fish <loot_table> <pos> [<tool>|mainhand|offhand]</code>
|
|
:::: Simulates [[fishing]] with a specified tool at a specified position.
|
|
::: <code>loot <loot_table></code>
|
|
:::: Invokes a [[loot table]] directly.
|
|
::: <code>kill <target></code>
|
|
:::: Simulates killing a specified entity.
|
|
::: <code>mine <pos> [<tool>|mainhand|offhand]</code>
|
|
:::: Simulates mining a block at a specified position with a specified tool.
|
|
|
|
::[[Loot context]] provided by each <code><''SOURCE''></code> is:
|
|
:::{|class="wikitable collapsible collapsed
|
|
! <''SOURCE''> !! Supplied loot context parameters
|
|
|-
|
|
| fish
|
|
|
|
|
* '''{{cd|this}} entity:''' (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
|
|
|
|
|
* '''{{cd|this}} entity:''' The specified entity.
|
|
* '''Origin:''' The command execution position.
|
|
* '''Damage source:''' The <code>magic</code> [[damage type]]
|
|
* '''{{cd|attacker}} entity:''' (If the executor is an entity) The command executor entity.
|
|
* '''{{cd|direct_attacker}} entity:''' (If the executor is an entity) The command executor entity.
|
|
* '''{{cd|attacking_player}} entity:''' (If the executor is a player) The command executor player.
|
|
|-
|
|
| loot
|
|
|
|
|
* '''{{cd|this}} entity:''' (If the executor is an entity) The command executor entity.
|
|
* '''Origin:''' The command execution position.
|
|
|-
|
|
| mine
|
|
|
|
|
* '''{{cd|this}} entity:''' (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'''
|
|
: <code>loot <''TARGET''> <''SOURCE''></code>
|
|
::In which:
|
|
::<code><''TARGET''></code> is:
|
|
::: <code>give <player: target></code>
|
|
:::: Gives items to players, ignoring empty item stacks.
|
|
::: <code>insert <position: x y z></code>
|
|
:::: Distributes items to a container block, ignoring empty item stacks.
|
|
::: <code>spawn <position: x y z></code>
|
|
:::: Spawns item entities, ignoring empty item stacks.
|
|
::: <code>replace block <position: x y z> slot.container <slotId: int></code>
|
|
:::<code>replace entity <entity: target> <slotType: EntityEquipmentSlot> <slotId: int></code>
|
|
:::: Replaces item stacks into some consecutive [[slot]]s in order. An empty item stack generated by the <''SOURCE''> clears a slot.
|
|
::: <code>replace block <position: x y z> slot.container <slotId: int> [count: int]</code>
|
|
:::<code>replace entity <entity: target> <slotType: EntityEquipmentSlot> <slotId: int> [count: int]</code>
|
|
:::: Clears some consecutive [[slot]]s, 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.
|
|
|
|
::<code><''SOURCE''></code> is:
|
|
:::<code>kill <entity: target> ["<tool>|mainhand|offhand": string]</code>
|
|
:::: Simulates killing a specified entity with a specified tool.
|
|
:::<code>loot <loot_table: string> ["<tool>|mainhand|offhand": string]</code>
|
|
:::: Invokes a [[loot table]] with a specified tool.
|
|
|
|
==Arguments==
|
|
{{el|je|short=1}}: {{argument|loot_table|loot_table}}
|
|
{{el|be|short=1}}: {{argument|loot_table: string|basic_string|be=1}}
|
|
:Specifies which loot table to use.
|
|
:{{IN|java}}, {{lcfirst:{{arg desc|je=loot_table}}}}
|
|
:{{IN|bedrock}}, {{lcfirst:{{arg desc|be=string}}}} And it refers to a loot table with the path of "loot_tables/<code>loot_table: string</code>.json".
|
|
|
|
{{el|je|short=1}}: {{argument|tool|item_stack}}
|
|
:Specifies a tool to simulatively mine or fish.
|
|
:{{arg desc|je=item_stack}}
|
|
|
|
{{el|be|short=1}}: {{argument|be=1|"<tool>{{!}}mainhand{{!}}offhand": string|basic_string}}
|
|
:Specifies a tool to be used to simulatively kill or loot.
|
|
:{{arg desc|be=string}} Can be <code>mainhand</code> and <code>offhand</code>, otherwise it represents an item id.
|
|
|
|
{{argument|target|entity|entity: target|CommandSelector<Actor>}} (in <code>kill</code> source)
|
|
: Specifies one entity to kill simulatively.
|
|
:{{arg desc|je=entity|amount=single|type=entities|actor}}
|
|
|
|
{{argument|players|entity|player: target|CommandSelector<Player>}}
|
|
:Specifies one or more players to give.
|
|
:{{arg desc|je=entity|amount=multiple|type=players|be=CommandSelector<Player>}}
|
|
|
|
{{el|je|short=1}}: {{argument|pos|block_pos}} and {{argument|targetPos|block_pos}} (in <code>replace block</code> and <code>insert</code> mode)<br>
|
|
{{el|be|short=1}}: {{argument|be=1|position: x y z|CommandPositionFloat}} (in <code>replace block</code> and <code>insert</code> mode)
|
|
:Specifies the position of a block.
|
|
:{{IN|java}}: {{lcfirst:{{arg desc|je=block_pos}}}}
|
|
:{{IN|bedrock}}: {{lcfirst:{{arg desc|be=CommandPositionFloat}}}}
|
|
|
|
{{argument|targetPos|block_pos|position: x y z|CommandPositionFloat}} (in <code>spawn</code> mode)
|
|
:Specifies the location where item entities drop.
|
|
:{{arg desc|je=vec3|be=CommandPositionFloat}}
|
|
|
|
{{argument|entities|entity|entity: target|CommandSelector<Actor>}}
|
|
:Specifies one or more entities to modify.
|
|
:{{arg desc|je=entity|amount=multiple|type=entities|be=actor}}
|
|
|
|
{{argument|count|integer|count: int|int}}
|
|
:Specifies the number of consecutive slots to be cleared.
|
|
:{{arg desc|je=integer|min=0|be=int}}
|
|
|
|
{{el|je|short=1}}: {{argument|slot|item_slot}}<br>
|
|
{{el|be|short=1}}: {{argument|be=1|slotType: EntityEquipmentSlot|enum}}, <code>slot.container</code>, and {{argument|be=1|slotId: int|int}}
|
|
:Specifies the inventory slot to be modified.
|
|
:{{arg desc|je=item_slot|be=enum}}
|
|
|
|
==Result==
|
|
|
|
{{Result table}}
|
|
{{Result table|The command is incomplete, or any argument is not specified correctly.|unparseable|unparseable}}
|
|
{{Result table|cmd=/... fish ...<br>/... mine ...|<code><pos></code> or <code>position: x y z</code> is unloaded or out of the world.|fail|fail}}
|
|
{{Result table|cmd=/... mainhand<br>/... offhand|The executor is not a living entity.||N/A}}
|
|
{{Result table|The executor is not an entity.||fail}}
|
|
{{Result table|cmd=/... kill ...|<code><target></code> or <code>entity: target</code> fails to resolve to a single entity (named player must be online).}}
|
|
{{Result table|The target is not a living entity.||N/A}}
|
|
{{Result table|The target has no loot table.|N/A|fail}}
|
|
{{Result table|cmd=/... loot ...|The <code>loot_table: string</code> is not a valid loot table.<!--unparseable in java because the argument is not specified correctly-->}}
|
|
{{Result table|cmd=/loot replace entity ...|<code><entities></code> or <code>entity: target</code> fails to resolve to one or more entities (named player must be online).|fail}}
|
|
{{Result table|cmd=/loot replace entity <entities> <slot> <''SOURCE''><br>/loot replace entity ... <slotId: int> <''SOURCE''>|One or more item stacks are got, and all the targeted entities do not have the specified slot.|success}}
|
|
{{Result table|cmd=-{}-/loot replace entity <entities> <slot> <count> <''SOURCE''><br>/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.}}
|
|
{{Result table|cmd=/loot give ...|<code><players></code> or <code>player: target</code> fails to resolve to one or more online players.|fail}}
|
|
{{Result table|cmd=/loot insert ...<br>/loot replace block ...|<code><targetPos></code> or <code>position: x y z</code> is unloaded or out of the world.}}
|
|
{{Result table|The block at <code><targetPos></code> or <code>position: x y z</code> is not a container.}}
|
|
{{Result table|cmd=/loot replace block ...|The block does not have the specified slot.}}
|
|
{{Result table|cmd=/loot replace block <targetPos> <slot> <''SOURCE''><br>/loot replace block ... <slotId: int> <''SOURCE''>|The number of item stacks got from the source plus the <code><slot></code> id is bigger than the number of all slots in the specified container.|exception|success}}
|
|
{{Result table|cmd=/loot replace block <targetPos> <slot> <count> <''SOURCE''><br>/loot replace block ... <slotId: int> <count: int> <''SOURCE''>|The <code><count></code> plus the <code><slot></code> id is bigger than the number of all slots in the specified container.||fail}}
|
|
{{Result table|cmd=|success}}
|
|
{{Result table}}
|
|
|
|
==Output==
|
|
|
|
{{Output table}}
|
|
{{Output table|edition=je|On fail|0|0|0}}
|
|
{{Output table|cmd=/loot spawn ...|On success|1|1|the number of item stacks got from loot}}
|
|
{{Output table|cmd=/loot give ...|On success|1|1|the total number of item stacks successfully allocated to each player}}
|
|
{{Output table|cmd=/loot insert ...|On success|1|1|the number of item stacks successfully distributed to the container}}
|
|
{{Output table|cmd=/loot replace block ...|On success|1|1|the number of item stacks successfully distributed to the container}}
|
|
{{Output table|On error|0|unchanged|unchanged}}
|
|
{{Output table|cmd=/loot replace entity ...|On success|1|1|the total number of item stacks successfully allocated to each entity}}
|
|
{{Output table|On error|0|unchanged|unchanged}}
|
|
{{Output table|edition=be|cmd=|On fail|0}}
|
|
{{Output table|cmd=loot give ...|On success|{{needs testing}}}}
|
|
{{Output table|cmd=loot spawn ...<br>loot insert ...|On success|1}}
|
|
{{Output table|cmd=-{}-/loot replace entity ... <slotId: int> <''SOURCE''>|On success|When zero item stack is got, outputs 1.<br>Otherwise, outputs the number of targeted entities that have the specified slot}}
|
|
{{Output table|cmd=-{}-/loot replace entity ... <slotId: int> <count: int> <''SOURCE''>|On success|When zero item stack is got, outputs 1.<br>Otherwise, outputs the number of targeted entities that have all the specified consecutive slots}}
|
|
{{Output table}}
|
|
|
|
==History==
|
|
|
|
{{HistoryTable
|
|
|{{HistoryLine|java}}
|
|
|
|
|{{HistoryLine||1.14|dev=18w43a|Added {{cmd|drop|link=none}}.}}
|
|
|{{HistoryLine|||dev=18w45a|Renamed {{cmd|drop|link=none}} to {{cmd|loot|link=none}}.
|
|
|{{cmd|loot|link=none}} got reworked.}}
|
|
|{{HistoryLine||1.20.5|dev=24w12a|{{cmd|loot|link=none}} now also accepts an inline SNBT-formatted loot table definition for the {{argument|loot_table|loot_table}} argument.}}
|
|
|
|
|{{HistoryLine|bedrock}}
|
|
|{{HistoryLine||1.18|dev=beta 1.18.0.21|Added {{cmd|loot spawn ... loot ...|link=none}}.}}
|
|
|{{HistoryLine||1.18|dev=beta 1.18.0.22|Removed {{cmd|loot|link=none}}.}}
|
|
|{{HistoryLine||1.18.10|dev=beta 1.18.10.21|Re-added {{cmd|loot|link=none}}.}}
|
|
|{{HistoryLine||1.18.10|dev=beta 1.18.10.24|Added {{cmd|loot spawn ... kill ...|link=none}}}}
|
|
|{{HistoryLine||1.18.30|dev=beta 1.18.20.21|Added {{cmd|loot give ...|link=none}}}}
|
|
|{{HistoryLine|||dev=beta 1.18.30.20|Added {{cmd|loot insert ...|link=none}}}}
|
|
|{{HistoryLine||1.19.0|dev=beta 1.19.0.30|Added {{cmd|loot replace entity ...|link=none}}}}
|
|
|{{HistoryLine||1.19.40|dev=Preview 1.19.40.20|Added {{cmd|loot replace block ...|link=none}}}}
|
|
}}
|
|
|
|
== See also==
|
|
|
|
*{{cmd|give}} — give specific items to players without specifying a loot table
|
|
*{{cmd|item}}{{only|je}} — modify specific item slots of entities or container
|
|
*{{cmd|replaceitem}}{{only|be}} — modify specific item slots of entities or container
|
|
|
|
== Navigation ==
|
|
{{Navbox commands}}
|
|
|
|
[[de:Befehl/loot]]
|
|
[[ja:コマンド/loot]]
|
|
[[pt:Comandos/loot]]
|
|
[[ru:Команды консоли/loot]]
|
|
[[uk:Команди консолі/loot]]
|
|
[[zh:命令/loot]]
|