Bedrock Edition function/loot tables/trade tables documentation

From Minecraft Wiki
Jump to: navigation, search
Information icon.svg
This feature is exclusive to Bedrock Edition.

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

Version: v1.14.30

Getting Started[edit]

Creating Loot Tables[edit]

  • Loot tables are JSON files created mainly in loot_tables folder at the root of your behavior pack.
  • Example of a loot table file named custom_loot_table.json at loot_tables/entities folder:
{
  "pools": [
    {
      "rolls": 1,
      "entries": [
        {
          "type": "item",
          "name": "minecraft:string",
          "weight": 1
        }
      ]
    }
  ]
}
  • From this example, we can see that the loot table would drop one string.

Applying Loot Tables[edit]

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

Notes[edit]

  • Note: will crash the game if your loot table has bad syntax it will crash the game when killing an entity.
  • Note: will crash the game if the trade table has bad syntax it will crash the game when loading the world or will display the trades blank.
  • Note: "Wants" key in trade tables does not currently accept items with functions meaning that it will display the item in trade but will accept any item that matches this item even if it's not named or enchanted or has custom lore.
  • Note: trade table behavior-component must be added in as a component group in "component groups" and not added directly in the "components", or the trades will all render blank even though the json may use the correct syntax.
  • Note: Random enchants example for loot-tables and villager trades.
  • Note: enchants will not work on items that can't be enchanted in game, examples: Diamonds, Coal & Stone Blocks can't be enchanted, but swords, axes, armor can be.
  • Note: Enchant with 'levels' will use XP levels to enchant btw a range 'min' & 'max','

Conditions[edit]

Note
  • 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.
  • Loot table condition example:
"conditions": [
  {
    "condition": "killed_by_player"
  }
]


entity_properties[edit]

Returns true if the actor properties defined were executed.

Parameters
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", "on_ground" is used for now.

has_mark_variant[edit]

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

Parameters
Name Type Default Value Description
value Integer 0 Tests for the actor's mark variant (if it has one)

killed_by_player[edit]

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

killed_by_player_or_pets[edit]

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

random_chance[edit]

Sets a random chance of the specified value.

Parameters
Name Type Default Value Description
chance Decimal 0.0 The random chance of the value.

random_chance_with_looting[edit]

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

Parameters
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.

random_difficulty_chance[edit]

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

Parameters
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.

random_regional_difficulty_chance[edit]

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

Parameters
Name Type Default Value Description
max_chance Decimal 0.0 The maximum random chance value allowed.

Functions[edit]

enchant_with_levels[edit]

Increases the likely hood of the enchants being powerful.

Example
"functions": [
    {
        "function": "enchant_with_levels",
        "treasure": true,
        "levels": {
            "min": 200,
            "max": 200
        }
    }
]

enchant_randomly[edit]

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

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

enchant_random_gear[edit]

Will only use enchantments that can be used on gear such as looting, silktouch, mending, etc., "chance" increases likely hood that it will be enchanted at all, example: 0.5 = 50%, 1.0 = 100%.

Example
"functions": [
    {
        "function": "enchant_random_gear",
        "chance": 0.5
    }
]


specific_enchants[edit]

You can specifically enchant gear.

Note
  • Note: it is possible to go above vanilla enchant values II, IV, though ingame it will still display the max vanilla value.
  • Note: See Enchants for all possible enchantments.
Examples
"functions": [
    {
      "function": "specific_enchants",
      "enchants": [
         {
            "id": "knockback",
            "level":327
         },
         {
            "id": "unbreaking",
            "level": 1000
         }
      ]
    }
]
"functions": [
    {
        "function": "specific_enchants",
        "enchants": [
            "knockback",
            "fire_aspect"
        ]
    }
]


set_damage[edit]

Will drop or give a damaged item with 0.5 = 50% damaged 0.75 = 25% damaged.

Example
"functions": [
    {
        "function": "set_damage",
        "damage": {
            "min": 0.5,
            "max": 0.75
        }
    }
]


set_data[edit]

Will drop or give a block item with a data value. Example: white wool is 0, black wool is 15.

Example
"functions": [
    {
        "function": "set_data",
        "data": {
             "min": 0,
             "max": 15
        }
    }
]

set_book_contents[edit]

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

Note
  • Note: 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 ingame after picking it up/collecting it.
Examples
"functions": [
    {
        "function": "set_book_contents",
        "author": "Book Author",
        "title": "Book Title",
        "pages": [
            "Page 1",
            "Page 2",
            "Page 3",
            "Page 4",
            "Page 5",
            "Page 6",
            "Page 7",
            "Page 8",
            "Page 9",
            "Page 10"
        ]
    }
]
  • Note: rawtext is supported pages to translate strings and do other cool stuff, see rawtext documentation for more information.
  • Note: When using rawtext remember to use \ escape for special characters like " and \
"functions": [
    {
        "function": "set_book_contents",
        "author": "Book Author",
        "title": "Book Title",
        "pages": [
            "{\"rawtext\":[ {\"translate\":\"book.line.one\"}]}",
            "{\"rawtext\":[ {\"translate\":\"book.line.two\"}]}",
            "{\"rawtext\":[ {\"translate\":\"action.interact.mount\"}]}"
         ]
    }
]


fill_container[edit]

Will drop or give a chest block, dispenser, dropper, etc with a custom loot table.

Example
"functions": [
    {
        "function": "fill_container",
        "loot_table": "loot_tables/gameplay/op_chest.json"
    }
]


set_count[edit]

Will drop 1 to 3 items in a range when used in "gives" in villager trades will give the player 1 to 3 items upon loading the trade initially.

Example
"functions": [
    {
        "function": "set_count",
        "count": {
            "min": 1,
            "max": 3
        }
    }
]


looting_enchant[edit]

Will increase the dropped amount of items using the looting enchantment.

Example
"functions": [
    {
        "function": "looting_enchant",
        "count": {
            "min": 0,
            "max": 1
        }
    }
]


furnace_smelt[edit]

Will drop a smelted item's result example, beef = cooked beef, iron ore = iron ingot, etc.

Note
  • Note: this example also shows how to access entity properties as well such as 'on_fire', 'on_ground'. Refer to Conditions for loot table conditions.
Example
"functions": [
    {
        "function": "furnace_smelt",
        "conditions": [
            {
                "condition": "entity_properties",
                "entity": "this",
                "properties": {
                     "on_fire": true
                }
            }
        ]
    }
]

minecraft:set_data_from_color_index[edit]

Will drop a sheep's color wool based on the "minecraft:color" behavior component, for example, "minecraft:color":0 would drop white wool.

Example
"functions": [
    {
        "function": "minecraft:set_data_from_color_index"
    }
]


set_banner_details[edit]

Will drop a pillager banner item or the entity banner types 0, 1, 2, 3, etc. are still unknown?

Example
"functions": [
    {
        "function": "set_banner_details",
        "type": 1
    }
]

exploration_map[edit]

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

Note
  • Note: values is /locate command name, such as "monument", "mansion", "village", "stronghold", "temple", "ruins", "shipwreck", "pillageroutpost", "buriedtreasure", "mineshaft", "endcity", and "fortress". For endcity and fortress only work in correct dimension.
Example
"functions": [
    {
        "function": "exploration_map",
        "destination": "monument"
    }
]


enchant_book_for_trading[edit]

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.

Note
  • Note: can only be used on trades will not work on chest loot or entity drops.
  • Note: "base_cost" is the min number used when generating a range for the enchantment.
  • Note: "base_random_cost" is the max number used when generating a range for the enchantment.
  • Note: "per_level_random_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.
  • /Note: "per_level_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.
Example
"functions": [
    {
        "function": "enchant_book_for_trading",
        "base_cost": 2,
        "base_random_cost": 5,
        "per_level_random_cost": 10,
        "per_level_cost": 3
    }
]

random_block_state[edit]

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

Note
  • Note: uses the internal block state names check bedrock edition's block state names for the key.
  • Note: 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.
Example
"functions": [
    {
        "function": "random_block_state",
        "block_state": "flower_type",
        "values": {
            "min": 0,
            "max": 10
        }
    }
]


random_aux_value[edit]

Will drop or give a non-block item with a data value. Example: Effects of suspicious stew, or of tipped arrow.

Example
"functions": [
    {
        "function": "random_aux_value",
        "values": {
            "min": 0,
            "max": 9
        }
    }
]

set_lore[edit]

Will drop or give an item with custom lore on it. The recommended amount of characters per line is 37 including spaces going past this may cause some characters to display off the screen on some devices, with smaller resolutions then your average computer or game console such as Xbox one, switch, etc.

Example
"functions": [
    {
        "function": "set_lore",
        "lore": [
            "Line 1",
            "Line 2",
            "Line 3"
        ]
    }
]

set_name[edit]

Will drop or give an item with a custom name.

Example
"functions": [
    {
        "function": "set_name",
        "name": "Custom Name Here!"
    }
]

set_actor_id[edit]

Will set a spawn_egg item to an entity identifier, if "id" is omitted from as a parameter then it will drop its own entity identifier.

Example
"functions": [
    {
        "function": "set_actor_id",
        "id": "minecraft:creeper"
    }
]

Enchants[edit]

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
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
silk_touch mines the blocks that can't be mined under normal means example: Grass Blocks, Pathway Blocks, Ice
smite increases attack damage against undead entities like zombies, skeletons, etc.
thorns causes damage to the attacking entities
unbreaking Increases the durability of an item