Bedrock Edition function/loot tables/trade tables documentation

This is the loot tables/trade tables documentation for Bedrock Edition 1.16.221.

Version: v1.16.1

Creating Loot Tables

 * Loot table and trade table JSONs are created in subfolders of the root behavior pack folder; loot tables in the  folder and trade tables in the   folder. Some vanilla files belong in subfolders within those folders, such as the newer villager trades.

{ "pools": [ {     "rolls": 1, "entries": [ {         "type": "item", "name": "minecraft:string", "weight": 1 }     ]    }  ] }
 * Example of a loot table file named  at   folder:
 * From this example, we can see that the loot table would drop one string.

Applying Loot Tables
"minecraft:loot": { "table": "loot_tables/entities/custom_loot_table.json" }
 * Applying loot tables on an entity requires the  component in your entity. Refer to the Entities documentation to learn more about entity components.

"minecraft:loot": "loot_tables/blocks/custom_block_drop.json"
 * Applying loot tables on a block requires the  component in your block. Refer to the Blocks documentation to learn more about block components.

"minecraft:economy_trade_table": { "table": "trading/economy_trades/custom_trades.json" }
 * Applying trade tables on an entity requires the  or   component in your entity.

Conditions

 * Conditions are mainly used to allow specific loot table entries to be used.


 * Conditions are optional.


 * Conditions can be used in loot table functions. Check Functions section for more information.

"conditions": [ {   "condition": "killed_by_player" } ]
 * Loot table condition example:

entity_properties
Returns true if the defined actor's properties were executed.


 * Parameters
 * {| class="wikitable"

! Name !! Type !! Default Value !! Description
 * entity
 * String
 * "this"
 * The entity to test. The value must be only "this".
 * properties
 * JSON Object
 * {}
 * The entity's properties; "on_fire" and "on_ground" are used for now.
 * }
 * The entity's properties; "on_fire" and "on_ground" are used for now.
 * }

has_mark_variant
Returns true if the actor's mark variant is matched to the value.


 * Parameters
 * {| class="wikitable"

! Name !! Type !! Default Value !! Description
 * value
 * Integer
 * 64
 * Tests for the actor's mark variant (if it has one).
 * }
 * }

killed_by_player
Returns the condition true if the actor of the loot table is killed by the player.

killed_by_player_or_pets
Returns the condition true if the actor of the loot table is killed by player or entities that has owner.

random_chance
Sets a random chance of the specified value.


 * Parameters
 * {| class="wikitable"

! Name !! Type !! Default Value !! Description
 * chance
 * Decimal
 * 0.0
 * The random chance of the value.
 * }
 * }

random_chance_with_looting
Sets a random chance of the specified value. Looting enchantment increases the random chance multiplier.


 * Parameters
 * {| class="wikitable"

! Name !! Type !! Default Value !! Description
 * chance
 * Decimal
 * 0.0
 * The random chance of the value.
 * looting_multiplier
 * Decimal
 * 0.0
 * The multiplier for the chance if the target entity has the looting enchant that affects the actor.
 * }
 * The multiplier for the chance if the target entity has the looting enchant that affects the actor.
 * }

random_difficulty_chance
Sets a random chance of the specified value based on the level difficulty.


 * Parameters
 * {| class="wikitable"

! Name !! Type !! Default Value !! Description
 * default_chance
 * Decimal
 * 0.0
 * The default random chance if the level difficulty is not assigned.
 * peaceful
 * Decimal
 * 0.0
 * The default random chance if the level difficulty is in peaceful. Omitting this field will set the value to "default_chance" field.
 * easy
 * Decimal
 * 0.0
 * The default random chance if the level difficulty is in easy. Omitting this field will set the value to "default_chance" field.
 * normal
 * Decimal
 * 0.0
 * The default random chance if the level difficulty is in normal. Omitting this field will set the value to "default_chance" field.
 * hard
 * Decimal
 * 0.0
 * The default random chance if the level difficulty is in hard. Omitting this field will set the value to "default_chance" field.
 * }
 * hard
 * Decimal
 * 0.0
 * The default random chance if the level difficulty is in hard. Omitting this field will set the value to "default_chance" field.
 * }

random_regional_difficulty_chance
Sets a max regional difficulty random chance of the specified value.


 * Parameters
 * {| class="wikitable"

! Name !! Type !! Default Value !! Description
 * max_chance
 * Decimal
 * 0.0
 * The maximum random chance value allowed.
 * }
 * }

enchant_with_levels
Increases the likelihood of the enchants being powerful. Example:

"functions": [ {   "function": "enchant_with_levels", "treasure": true, "levels": { "min": 30, "max": 59 } } ]

enchant_randomly
Will enchant the item completely random but do note "treasure": true will increase the chance of a better enchantment.

"functions": [ {   "function": "enchant_randomly", "treasure": false } ]

enchant_random_gear
Will only use enchantments that can be used on gear such as looting, silk touch, mending, etc., "chance" increases likely hood that it will be enchanted at all, example: 0.5 = 50%, 1.0 = 100%. "functions": [ {   "function": "enchant_random_gear", "chance": 0.5 } ]

specific_enchants
You can specifically enchant gear.

"functions": [ {   "function": "specific_enchants", "enchants": [ {       "id": "soul_speed", "level": [1, 3] }   ]  } ]  "functions": [ {   "function": "specific_enchants", "enchants": [ "knockback", "fire_aspect" ] } ]
 * See Enchants for all possible enchantments.
 * Examples

set_damage
Will drop or give a damaged item with 0.5 = 50% damage remaining, 0.75 = 75% damage remaining. "functions": [ {   "function": "set_damage", "damage": { "min": 0.5, "max": 0.75 } } ]

set_data
Will drop or give a block item with a data value.

white wool is 0, black wool is 15 and arrows use Arrow and a slightly different format explained below.

"functions": [ {   "function": "set_data", "data": { "min": 0, "max": 15 } } ]
 * 1) Example of setting the function randomly between two ranges.

{ "type": "item", "name": "minecraft:potion", "functions": [ {     "function": "set_data", "data": 19 } ] }
 * 1) Example of a potion item being set using this loot table function.

{ "item": "minecraft:arrow:10", "quantity": 5 }
 * 1) Example of arrows with added effects but do note that they don't use the set_data loot_table function but instead use an odd semicolon format : to set the metadata value.

set_book_contents
Will drop or give a written book with author's name and book title.

"functions": [ {   "function": "set_book_contents", "author": "Example Author", "title": "Example Title", "pages": [ "Page 1", "Page 2", "Page 3", "Page 4", "Page 5", "Page 6", "Page 7", "Page 8", "Page 9", "Page 10" ] } ] Rawtext Example:
 * Do not try passing the limit of text per page in the JSON file or the game may crash upon dropping the book or when the player tries opening the book in-game after picking it up/collecting it.

"functions": [ {   "function": "set_book_contents", "author": "Example Author", "title": "Example Title", "pages": [ "{\"rawtext\":[ {\"translate\":\"book.line.one\"}]}", "{\"rawtext\":[ {\"translate\":\"book.line.two\"}]}", "{\"rawtext\":[ {\"translate\":\"action.interact.mount\"}]}" ] } ]
 * rawtext is supported pages to translate strings and do other cool stuff, see rawtext documentation for more information.
 * When using rawtext remember to use \ escape for special characters like " and \

fill_container
Will drop or give a chest, dispenser, dropper, etc. with a custom loot table. "functions": [ {   "function": "fill_container", "loot_table": "loot_tables/gameplay/op_chest.json" } ]

set_count
Will drop set items in a given range.

"functions": [ {   "function": "set_count", "count": { "min": 1, "max": 3 } } ]
 * When used in "gives" in villager trades, villagers will give the player 1 to 3 items upon loading the trade initially.

looting_enchant
For drop loot, will increase the dropped amount of items using the looting enchantment

"functions": [ {       "function": "looting_enchant", "count": { "min": 0, "max": 1 }   } ]
 * For equipment gear, will increase chance to drop by percentage of items using the looting enchantment.

furnace_smelt
Will drop a smelted item's result. Example: beef => cooked beef, iron ore => iron ingot. This example also shows how to access entity properties such as 'on_fire', 'on_ground'.

"functions": [ {   "function": "furnace_smelt", "conditions": [ {       "condition": "entity_properties", "entity": "this", "properties": { "on_fire": true }     }    ]  } ]
 * Refer to Conditions for loot table conditions.

minecraft:set_data_from_color_index
Will drop a sheep's color wool based on the "minecraft:color" behavior component For example, "minecraft:color":0 will drop white wool. "functions": [ {       "function": "minecraft:set_data_from_color_index" } ]

set_banner_details
Will drop an Illager banner item ("type": 1). Types 0 and 2+ are unused. "functions": [ {       "function": "set_banner_details", "type": 1 } ]

exploration_map
Will drop a map that has an X marking a location.

"functions": [ {   "function": "exploration_map", "destination": "monument" } ]
 * Value is /locate command name, such as "monument", "mansion", "village", "stronghold", "temple", "ruins", "shipwreck", "pillageroutpost", "buriedtreasure", "mineshaft", "endcity", "fortress", "ruinedportal", "bastionremnant".
 * These only work in the correct dimension, with ruined portals being locatable in both the overworld and nether.

enchant_book_for_trading
Will set enchantments randomly using the players' current enchantment seed in the player.dat, or local player to choose the enchantment when initially loading the trade on the entity.

"functions": [ {   "function": "enchant_book_for_trading", "base_cost": 2, "base_random_cost": 5, "per_level_random_cost": 10, "per_level_cost": 3 } ]
 * Can only be used on trades; this will not work on chest loot, entity drops, entity equipment, fishing loot, or block drop loot.
 * "base_cost" is the min number used when generating a range for the enchantment.
 * "base_random_cost" is the max number used when generating a range for the enchantment.
 * "per_level_random_cost" is the max cost number used when generating a range and is the cost of XP needed to attach the enchantment to an item using an anvil.
 * "per_level_cost" is the min cost number used when generating a range and is the cost of XP needed to attach the enchantment to an item using an anvil.

random_block_state
Will choose a random block state value using the "block_state": "value"-specified, example, "coral_color", "flower_type", "sapling_type".

"functions": [ {       "function": "random_block_state", "block_state": "flower_type", "values": { "min": 0, "max": 10 }   } ]
 * Uses the internal block state names. Check bedrock edition's block state names for the key.
 * This does not set the damage or data values on the block but instead sets the block state in NBT on the item when dropped.

random_aux_value
Will drop or give a non-block item with a data value. Example: effects of suspicious stew or tipped arrow. "functions": [ {       "function": "random_aux_value", "values": { "min": 0, "max": 9 }   } ]

set_lore
Will drop or give an item with custom lore on it. The recommended amount of characters per line is 37, including spaces.

"functions": [ {       "function": "set_lore" "lore": [ "Line 1" "Line 2" "Line 3" ]   } ]
 * Going past this may cause characters to display offscreen on lower resolutions, consoles, or mobile devices.

set_name
Will drop or give an item with a custom name.

{       "function": "set_name" "name": "Custom Name Here!" } ]
 * Note that the set_name will not work with the set count function with items that can't be stacked and will just show the normal Minecraft name instead. "functions": [

set_actor_id
Will set a spawn_egg item to an entity identifier. If "id" is omitted as a parameter, then it will drop its own entity identifier. "functions": [ {       "function": "set_actor_id", "id": "minecraft:creeper" } ]

random_dye
Will set leather armor with random dye. "functions": [ {       "function": "random_dye" } ]

trader_material_type
Will set material of items based on trader type.

"functions": [ {       "function": "trader_material_type" } ]
 * Can only be used on trades.

Enchants

 * {| class="wikitable"

! Name !! Description
 * aqua_affinity
 * speeds up how fast you mine blocks underwater
 * bane_of_arthropods
 * increases attack damage against arthropods such as spiders, silverfish, etc.
 * blast_protection
 * decreases blast and explosion damage
 * channeling
 * summons a lightning bolt at an entity when the enchanted trident is thrown, note: the entity must be in the rain
 * curse_of_binding
 * prevent removal of armor from armor slot
 * curse_of_vanishing
 * item will disappear upon death, instead of dropped.
 * depth_strider
 * speeds up how fast you swim under the water
 * efficiency
 * increases how fast you can mine
 * feather_falling
 * decreases fall damage and teleportation damage
 * fire_aspect
 * sets entity that is hit to be on fire.
 * fire_protection
 * decreases damage caused by fire damage and lava damage
 * flame
 * makes arrows on fire so when they hit an entity it sets them on fire
 * fortune
 * increase block drops from mining blocks such as gold ore, diamond ore & redstone ore, etc.
 * frost_walker
 * freezes water into ice blocks so you can walk on top of the ice
 * impaling
 * increases attack damage against sea creatures such as squid, drowned, cod, etc.
 * infinity
 * allows you to shoot an infinite amount of arrows
 * knockback
 * increases knockback damage against all entities, (entities will fly backwards)
 * looting
 * increases the loot quantity dropped when the entity is killed
 * loyalty
 * returns the trident to the entity after throwing
 * luck_of_the_sea
 * increases chances of catching valuable items while fishing
 * lure
 * increases the chance rate of fish biting your hook from your fishing rod
 * mending
 * uses the players XP to mend their tools, weapons and armor
 * multishot
 * allows the entity to shoots 3 arrows at once but only uses 1 arrow from the entities inventory
 * piercing
 * arrow can pierce through multiple entities while flying
 * projectile_protection
 * reduces projectile damage from arrows, fireballs, tridents, etc.
 * protection
 * normal protection against attacks, fire, lava, and falling
 * punch
 * increases knockback damage against all entities with arrows, (entities will fly backwards)
 * quick_charge
 * decreases the amount of time it takes to reload with a crossbow.
 * respiration
 * increases underwater breathing & helps you see underwater better use on helmets,
 * riptide
 * pushes the player forward when enchanted trident is thrown while in water or when you are in the rain.
 * sharpness
 * increases attack damage on a sword or axe.
 * silk_touch
 * mines the blocks that can't be mined under normal means, e.g. Grass Blocks, Pathway Blocks, Ice.
 * smite
 * increases attack damage against undead entities like zombies, skeletons, etc.
 * soul_speed
 * Increases the speed of the player while walking on Soul Sand and Soul Soil.
 * power
 * Increases all the damage dealt by a bow when applied.
 * thorns
 * causes damage to the attacking entities.
 * unbreaking
 * chance of not reducing durability when using an item.
 * }
 * protection
 * normal protection against attacks, fire, lava, and falling
 * punch
 * increases knockback damage against all entities with arrows, (entities will fly backwards)
 * quick_charge
 * decreases the amount of time it takes to reload with a crossbow.
 * respiration
 * increases underwater breathing & helps you see underwater better use on helmets,
 * riptide
 * pushes the player forward when enchanted trident is thrown while in water or when you are in the rain.
 * sharpness
 * increases attack damage on a sword or axe.
 * silk_touch
 * mines the blocks that can't be mined under normal means, e.g. Grass Blocks, Pathway Blocks, Ice.
 * smite
 * increases attack damage against undead entities like zombies, skeletons, etc.
 * soul_speed
 * Increases the speed of the player while walking on Soul Sand and Soul Soil.
 * power
 * Increases all the damage dealt by a bow when applied.
 * thorns
 * causes damage to the attacking entities.
 * unbreaking
 * chance of not reducing durability when using an item.
 * }
 * soul_speed
 * Increases the speed of the player while walking on Soul Sand and Soul Soil.
 * power
 * Increases all the damage dealt by a bow when applied.
 * thorns
 * causes damage to the attacking entities.
 * unbreaking
 * chance of not reducing durability when using an item.
 * }
 * unbreaking
 * chance of not reducing durability when using an item.
 * }