1. Wiki
  2. /Entities
  3. /minecraft:barter

minecraft:barter

Don't want to write this by hand? GodCraft sets minecraft:barter for you with a switch.Get GodCraft

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

FieldTypeDefaultDescription
barter_tablestring""Path to the loot table that picks the item given back.
cooldown_after_being_attackedinteger10Seconds 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
  }
}

We use cookies to improve your experience and analyse site traffic. Learn more