World - Trade Tables Module
anvil.api.world.trade_tables
TradeTable
Bases: JsonFile[_TradeTableFile]
A trade table: the trades of a villager or wandering trader, in tiers unlocked by the trader's experience.
table = TradeTable("fisher")
trade = table.tier(0).group().trade()
trade.wants("minecraft:emerald", 3)
trade.gives("minecraft:fishing_rod").EnchantWithLevels((5, 19))
table.queue()
Documentation reference
identifier
property
The file's identifier.
name
property
The identifier's name, without its namespace.
table_path
property
The trade table's path from the behavior pack root, as entities reference it.
__export__()
Exports the addon object after potentially shortening its content and replacing backslashes. Logs the event and writes the object to a file.
__init__(name)
Initializes a trade table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The trade table name. |
required |
__schema__()
classmethod
The JSON Schema (draft 2020-12) of this file: the schema of its _document_type, with
the file's type as title and where it is written under x-anvil-file.
Raises:
| Type | Description |
|---|---|
TypeError
|
When the class is an abstract file base, with no document type. |
queue()
Queues the trade table for export.
tier(total_exp_required)
Adds a tier of trades.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
total_exp_required
|
int
|
The trader experience that unlocks the tier. The first tier is always unlocked. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
_TradeTier |
_TradeTier
|
The tier, to add groups of trades to. |