Skip to content

Instantly share code, notes, and snippets.

@misode
Last active April 3, 2019 13:37
Show Gist options
  • Save misode/001892611c9fad1ed4e3770eeaeb8568 to your computer and use it in GitHub Desktop.
Save misode/001892611c9fad1ed4e3770eeaeb8568 to your computer and use it in GitHub Desktop.

Loot syntax

/loot can be separated into two major parts, target and source. Those two parts follow each other in the command. In snapshots prior to 18w45a, this command was named /drop

loot <target> <source>

Last updated: 18w45a

Target

The target defines where to drop the items. It has several arguments. The first argument is the target type. It's one of these options: spawn, replace, insert and give.

spawn

This spawns the item as an entity in the world. It has one more argument: the position to spawn the item entity in the world.

loot spawn ~ ~ ~ <source>

replace

This target type works similar to /replaceitem. It has three more arguments: The first is a literal, which is either entity or block.

  • If you choose entity, the second argument is an entity selector
  • If you choose block, the second argument is a block position

The third argument is the start slot, which is the slot where to start replacing the items. An optional fourth argument is a maximum count

loot replace entity @s inventory.0 <source>
loot replace entity @s inventory.0 4 <source>
loot replace block ~ ~ ~ container.0 <source>
loot replace block ~ ~ ~ container.0 4 <source>

insert

This inserts the items in a container block, similar to shift left-click. It takes one more arguments: a block position. This will not replace any items that were already in the container.

loot insert ~ ~ ~ <source>

give

This inserts the item in a player's inventory as if they were given using /give. The only argument is the entity selector, which has to be a player.

loot give @a <source>

Source

The source defines where to get the items. It has several arguments. The first argument is the source type. It's one of these options: loot, mine, kill and fish.

loot

This takes items from a loot table using the loot chest context. The only argument is the loot table.

loot <target> loot minecraft:chests/buried_treasure

mine

This takes items as if they were dropped by a mined block. It takes two more arguments: a block position in the world and an optional item to break the block. If no item is given, it defaults to mainhand. Note that it will not actually break this block, it will only drop its item(s).

loot <target> mine ~ ~ ~
loot <target> mine ~ ~ ~ diamond_pickaxe{Enchantments:[{id:"silk_touch",lvl:1}]}

kill

This takes items as if they were dropped by a killed entity. This takes one more argument: an entity selector to kill. Note that it will not actually kill this entity, it will only drop its loot.

loot <target> kill @e[type=creeper,sort=nearest,limit=1]

fish

This takes items as if they came from fishing. This takes three more arguments: a loot table, a block position and an optional item. If no item is given, it defaults to mainhand.

loot <target> fish minecraft:gameplay/fishing ~ ~ ~
loot <target> fish minecraft:gameplay/fishing ~ ~ ~ fishing_rod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment