Skip to content

World - Loot Tables Module

anvil.api.world.loot_tables

LootTable

Bases: AddonObject

A Minecraft Bedrock loot table for defining random item/block drops and rewards.

Loot tables are used throughout Minecraft to define what items drop when: - Entities die - Blocks are broken - Chests generate - Fishing occurs - Trading with villagers

Each loot table contains one or more pools, and each pool contains weighted entries that can have functions applied to modify the resulting items.

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

path property

Get the relative path of this loot table for referencing.

Returns:

Name Type Description
str

Relative path from behavior pack root.

__init__(name)

Initialize a LootTable instance.

Parameters:

Name Type Description Default
name str

The name of the loot table (used for filename and referencing).

required

__str__()

Return the loot table path for string representation.

Returns:

Name Type Description
str

The relative path of this loot table.

content(content)

Sets the content of the addon object and returns the object.

Parameters:

Name Type Description Default
content any

The content to be set for the addon object.

required

Returns:

Name Type Description
self AddonObject

The instance of the current AddonObject.

do_not_shorten()

Setter property that disables shortening of dict when exporting.

pool(rolls=1)

Create a new loot pool in this loot table.

Pools are rolled independently, so multiple pools allow for multiple categories of loot with different roll counts and mechanics.

Parameters:

Name Type Description Default
rolls int | list[int, int]

Number of times to roll this pool. Can be exact number or [min, max] range. Defaults to 1.

1

Returns:

Name Type Description
_LootPool

The created pool for adding entries and configuration.

queue()

Queue this loot table for generation in the behavior pack.

Exports all pools and their entries to JSON format and adds the loot table file to the generation queue.

Returns:

Name Type Description
LootTable

Self for method chaining.