{
  "format_version": "1.26.0",
  "minecraft:entity": {
    "description": {
      "identifier": "minecraft:wandering_trader",
      "is_experimental": false,
      "is_summonable": true,
      "is_spawnable": true,
      "spawn_category": "creature"
    },
    "components": {
      "minecraft:behavior.avoid_mob_type": {
        "max_dist": 6,
        "entity_types": [
          {
            "filters": {
              "AND": [
                {
                  "OR": [
                    {
                      "test": "is_family",
                      "subject": 1,
                      "operator": 0,
                      "value": "zombie"
                    },
                    {
                      "test": "is_family",
                      "subject": 1,
                      "operator": 0,
                      "value": "zombie_villager"
                    },
                    {
                      "test": "is_family",
                      "subject": 1,
                      "operator": 0,
                      "value": "zombie_pigman"
                    },
                    {
                      "test": "is_family",
                      "subject": 1,
                      "operator": 0,
                      "value": "illager"
                    },
                    {
                      "test": "is_family",
                      "subject": 1,
                      "operator": 0,
                      "value": "vex"
                    },
                    {
                      "test": "is_family",
                      "subject": 1,
                      "operator": 0,
                      "value": "zoglin"
                    }
                  ]
                }
              ]
            },
            "walk_speed_multiplier": 0.6,
            "sprint_speed_multiplier": 0.6
          }
        ],
        "priority": 2
      },
      "minecraft:behavior.drink_milk": {
        "filters": {
          "AND": [
            {
              "test": "is_daytime",
              "subject": 0,
              "operator": 0,
              "value": true
            },
            {
              "test": "is_visible",
              "subject": 0,
              "operator": 0,
              "value": false
            },
            {
              "test": "is_avoiding_mobs",
              "subject": 0,
              "operator": 0,
              "value": false
            }
          ]
        },
        "priority": 5
      },
      "minecraft:behavior.drink_potion": {
        "potions": [
          {
            "chance": 1,
            "filters": {
              "all_of": [
                {
                  "any_of": [
                    {
                      "operator": ">=",
                      "test": "hourly_clock_time",
                      "value": 18000
                    },
                    {
                      "operator": "<",
                      "test": "hourly_clock_time",
                      "value": 12000
                    }
                  ]
                },
                {
                  "subject": "self",
                  "test": "is_visible",
                  "value": true
                },
                {
                  "any_of": [
                    {
                      "subject": "self",
                      "test": "is_avoiding_mobs",
                      "value": true
                    },
                    {
                      "all_of": [
                        {
                          "subject": "self",
                          "test": "has_component",
                          "value": "minecraft:angry"
                        },
                        {
                          "operator": "!=",
                          "test": "is_family",
                          "subject": "target",
                          "value": "player"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            "id": 7 // Short invisibility
          },
          {
            "chance": 1,
            "filters": {
              "all_of": [
                {
                  "operator": ">=",
                  "test": "hourly_clock_time",
                  "value": 12000
                },
                {
                  "operator": "<",
                  "test": "hourly_clock_time",
                  "value": 18000
                },
                {
                  "subject": "self",
                  "test": "is_visible",
                  "value": true
                },
                {
                  "any_of": [
                    {
                      "subject": "self",
                      "test": "is_avoiding_mobs",
                      "value": true
                    },
                    {
                      "subject": "self",
                      "test": "has_component",
                      "value": "minecraft:angry"
                    }
                  ]
                }
              ]
            },
            "id": 8 // Long invisibility
          }
        ],
        "priority": 1,
        "speed_modifier": -0.2
      },
      "minecraft:behavior.float": {
        "priority": 0
      },
      "minecraft:behavior.look_at_player": {
        "look_time": {
          "min": 1,
          "max": 2
        },
        "priority": 8
      },
      "minecraft:behavior.look_at_trading_player": {
        "look_time": {
          "min": 1,
          "max": 2
        },
        "priority": 4
      },
      "minecraft:behavior.move_towards_home_restriction": {
        "speed_multiplier": 0.6,
        "priority": 6
      },
      "minecraft:behavior.panic": {
        "damage_sources": [
          "all"
        ],
        "priority": 1,
        "speed_multiplier": 0.6
      },
      "minecraft:behavior.random_look_around": {
        "priority": 9
      },
      "minecraft:behavior.random_stroll": {
        "priority": 7,
        "speed_multiplier": 0.6
      },
      "minecraft:behavior.trade_interest": {
        "carried_item_switch_time": 2,
        "cooldown": 2,
        "interest_time": 45,
        "within_radius": 6,
        "priority": 3,
        "remove_item_time": 1
      },
      "minecraft:behavior.trade_with_player": {
        "filters": {
          "all_of": [
            {
              "all_of": [
                {
                  "test": "in_water",
                  "value": false
                }
              ]
            },
            {
              "any_of": [
                {
                  "test": "on_ground",
                  "value": true
                },
                {
                  "test": "is_sleeping",
                  "value": true
                }
              ]
            }
          ]
        },
        "priority": 1
      },
      "minecraft:breathable": {
        "suffocate_time": 0,
        "total_supply": 15
      },
      "minecraft:can_climb": {},
      "minecraft:collision_box": {
        "height": 1.9,
        "width": 0.6
      },
      "minecraft:conditional_bandwidth_optimization": {},
      "minecraft:damage_sensor": {
        "triggers": [
          {
            "cause": "entity_attack",
            "on_damage": {
              "event": "minecraft:become_scared"
            },
            "deals_damage": "yes"
          },
          {
            "cause": "projectile",
            "on_damage": {
              "event": "minecraft:become_scared"
            },
            "deals_damage": "yes"
          },
          {
            "cause": "magic",
            "on_damage": {
              "event": "minecraft:become_scared"
            },
            "deals_damage": "yes"
          }
        ]
      },
      "minecraft:despawn": {
        "filters": {
          "all_of": [
            {
              "any_of": [
                {
                  "subject": "self",
                  "test": "is_family",
                  "value": "wandering_trader_despawning"
                },
                {
                  "subject": "self",
                  "test": "has_trade_supply",
                  "value": false
                }
              ]
            },
            {
              "operator": ">",
              "test": "distance_to_nearest_player",
              "value": 24
            }
          ]
        },
        "remove_child_entities": true
      },
      "minecraft:economy_trade_table": {
        "display_name": "entity.wandering_trader.name",
        "new_screen": true,
        "table": "trading/economy_trades/wandering_trader_trades.json"
      },
      "minecraft:health": {
        "max": 20,
        "value": 20
      },
      "minecraft:home": {
        "restriction_radius": 16,
        "restriction_type": "random_movement"
      },
      "minecraft:hurt_on_condition": {
        "damage_conditions": [
          {
            "cause": "lava",
            "damage_per_tick": 4,
            "filters": {
              "operator": "==",
              "test": "in_lava",
              "subject": "self",
              "value": true
            }
          }
        ]
      },
      "minecraft:is_hidden_when_invisible": {},
      "minecraft:jump.static": {},
      "minecraft:movement": {
        "value": 0.5
      },
      "minecraft:movement.basic": {},
      "minecraft:nameable": {},
      "minecraft:navigation.walk": {
        "avoid_water": true,
        "can_open_doors": false,
        "using_door_annotation": true,
        "can_pass_doors": true,
        "can_path_over_water": true
      },
      "minecraft:physics": {},
      "minecraft:pushable": {
        "is_pushable": true,
        "is_pushable_by_piston": true
      },
      "minecraft:spawn_entity": {
        "entities": [
          {
            "max_wait_time": 0,
            "min_wait_time": 0,
            "num_to_spawn": 2,
            "single_use": true,
            "should_leash": true,
            "spawn_entity": "trader_llama",
            "spawn_event": "minecraft:from_wandering_trader"
          }
        ]
      },
      "minecraft:timer": {
        "looping": false,
        "random_time_choices": [
          {
            "value": 2400,
            "weight": 50
          },
          {
            "value": 3600,
            "weight": 50
          }
        ],
        "time_down_event": {
          "event": "minecraft:start_despawn",
          "target": "self"
        }
      },
      "minecraft:type_family": {
        "family": [
          "wandering_trader",
          "mob"
        ]
      }
    },
    "component_groups": {
      "despawning": {
        "minecraft:type_family": {
          "family": [
            "wandering_trader",
            "wandering_trader_despawning",
            "mob"
          ]
        }
      },
      "managed": {
        "minecraft:managed_wandering_trader": {}
      },
      "minecraft:scared": {
        "minecraft:angry": {
          "broadcastAnger": true,
          "broadcastRange": 10,
          "calm_event": {
            "event": "minecraft:become_calm",
            "target": "self"
          },
          "broadcast_filters": {
            "subject": "other",
            "test": "is_leashed_to",
            "value": true
          },
          "broadcast_targets": [
            "llama",
            "trader_llama"
          ],
          "duration": 5
        }
      }
    },
    "events": {
      "minecraft:become_calm": {
        "remove": {
          "component_groups": [
            "minecraft:scared"
          ]
        }
      },
      "minecraft:become_scared": {
        "add": {
          "component_groups": [
            "minecraft:scared"
          ]
        }
      },
      "minecraft:scheduled": {
        "add": {
          "component_groups": [
            "managed"
          ]
        }
      },
      "minecraft:start_despawn": {
        "add": {
          "component_groups": [
            "despawning"
          ]
        }
      }
    }
  }
}