Overview
minecraft:barter is an entity component: it goes in the components object of a custom mob, or in one of its component groups. Lets the mob hand out a random item in exchange for one it is given, like piglins trading for gold. Use it together with minecraft:behavior.barter.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
barter_table | string | "" | Path to the loot table that picks the item given back. |
cooldown_after_being_attacked | integer | 10 | Seconds after getting hurt during which the mob will not trade. |
Example
Inside the components object of BP/entities/<name>.json (values are the defaults or placeholders):
BP/entities/<name>.json
{
"minecraft:barter": {
"barter_table": "",
"cooldown_after_being_attacked": 10
}
}