{
  "format_version": "1.16.0",
  "minecraft:entity": {
    "description": {
      "identifier": "legacy:the_lord_villager",
      "is_spawnable": true,
      "is_summonable": true,
      "is_experimental": false
    },
    "component_groups": {
      "minecraft:celebrate": {
        "minecraft:behavior.celebrate": {
          "priority": 5,
          "celebration_sound": "celebrate",
          "sound_interval": {
            "range_min": 2.0,
            "range_max": 7.0
          },
          "jump_interval": {
            "range_min": 1.0,
            "range_max": 3.5
          },
          "duration": 30.0,
          "on_celebration_end_event": {
            "event": "minecraft:stop_celebrating",
            "target": "self"
          }
        }
      },
      "minecraft:knockback": {
        "minecraft:behavior.knockback_roar": {
          "priority": 1,
          "duration": 1.68,
          "attack_time": 0.1,
          "knockback_damage": 8,
          "knockback_strength": 2,
          "knockback_range": 4,
          "knockback_filters": {
            "test": "is_family",
            "subject": "other",
            "operator": "!\u003d",
            "value": "villager"
          },
          "damage_filters": {
            "test": "is_family",
            "subject": "other",
            "operator": "!\u003d",
            "value": "villager"
          },
          "on_roar_end": {
            "event": "minecraft:no_knockback"
          },
          "cooldown_time": 2
        }
      },
      "minecraft:knockback_sensor": {
        "minecraft:entity_sensor": {
          "sensor_range": 3,
          "minimum_count": 6,
          "maximum_count": 64,
          "event_filters": {
            "any_of": [
              {
                "all_of": [
                  {
                    "test": "is_family",
                    "subject": "other",
                    "value": "monster"
                  },
                  {
                    "test": "is_family",
                    "subject": "other",
                    "operator": "!\u003d",
                    "value": "creeper"
                  }
                ]
              },
              {
                "test": "is_family",
                "subject": "other",
                "value": "illager"
              },
              {
                "test": "is_family",
                "subject": "other",
                "value": "undead"
              }
            ]
          },
          "event": "minecraft:knockback"
        }
      },
      "minecraft:regeneration_cast": { // Unused
        "minecraft:behavior.send_event": {
          "priority": 3,
          "event_choices": [
            {
              "min_activation_range": 0.0,
              "max_activation_range": 16.0,
              "cooldown_time": 10.0,
              "cast_duration": 1.30,
              "particle_color": "#FF86EC",
              "weight": 3,
              "filters": {
                "any_of": [
                  {
                    "test": "is_family",
                    "subject": "other",
                    "value": "villager"
                  },
                  {
                    "test": "is_family",
                    "subject": "other",
                    "value": "player"
                  },
                  {
                    "test": "is_family",
                    "subject": "other",
                    "value": "allies"
                  }
                ]
              },
              "filters": {
                "all_of": [
                  {
                    "test": "has_mob_effect",
                    "subject": "other",
                    "operator": "!=",
                    "value": "regeneration"
                  }
                ]
              },
              "start_sound_event": "cast.spell",
              "sequence": [
                {
                  "base_delay": 0.56,
                  "event": "minecraft:give_regeneration_villager",
                  "sound_event": "prepare.wololo"
                }
              ]
            }
          ]
        },
        "minecraft:timer": {
          "looping": false,
          "time": [
            2,
            2
          ],
          "time_down_event": {
            "event": "minecraft:remove_summon",
            "target": "self"
          }
        }
      },
      "minecraft:start_casting": {
        "minecraft:timer": {
          "looping": false,
          "time": [
            7,
            8
          ],
          "time_down_event": {
            "event": "minecraft:casting"
          }
        }
      },
      "minecraft:unit_summon": {
        "minecraft:behavior.summon_entity": {
          "priority": 0,
          "summon_choices": [
            {
              "min_activation_range": 3,
              "cooldown_time": 15,
              "weight": 3,
              "cast_duration": 1.30,
              "particle_color": "#1557BE",
              "start_sound_event": "cast.spell",
              "sequence": [
                {
                  "shape": "circle",
                  "target": "self",
                  "base_delay": 1,
                  "delay_per_summon": 0,
                  "num_entities_spawned": 4,
                  "entity_type": "legacy:villager_guard_gold",
                  "size": 2.5,
                  "sound_event": "prepare.wololo"
                },
                {
                  "shape": "circle",
                  "target": "self",
                  "base_delay": 0.1,
                  "delay_per_summon": 0,
                  "num_entities_spawned": 2,
                  "entity_type": "legacy:villager_guard_diamond",
                  "size": 2.5,
                  "sound_event": "prepare.wololo"
                }
              ]
            },
            {
              "min_activation_range": 3,
              "cooldown_time": 15,
              "weight": 2,
              "cast_duration": 1,
              "particle_color": "#1557BE",
              "start_sound_event": "cast.spell",
              "sequence": [
                {
                  "shape": "circle",
                  "target": "self",
                  "base_delay": 1,
                  "delay_per_summon": 0,
                  "num_entities_spawned": 5,
                  "entity_type": "legacy:villager_guard_gold",
                  "size": 2.5,
                  "sound_event": "prepare.wololo"
                },
                {
                  "shape": "circle",
                  "target": "self",
                  "base_delay": 0.1,
                  "delay_per_summon": 0,
                  "num_entities_spawned": 2,
                  "entity_type": "legacy:knight_villager_diamond",
                  "size": 2.5,
                  "sound_event": "prepare.wololo"
                }
              ]
            }
          ]
        },
        "minecraft:timer": {
          "looping": false,
          "time": [
            2,
            2
          ],
          "time_down_event": {
            "event": "minecraft:remove_summon",
            "target": "self"
          }
        }
      },
      "minecraft:unit_summon_2": {
        "minecraft:behavior.summon_entity": {
          "priority": 0,
          "summon_choices": [
            {
              "min_activation_range": 3,
              "cooldown_time": 15,
              "weight": 3,
              "cast_duration": 1.30,
              "particle_color": "#1557BE",
              "start_sound_event": "cast.spell",
              "sequence": [
                {
                  "shape": "circle",
                  "target": "self",
                  "base_delay": 1,
                  "delay_per_summon": 0,
                  "num_entities_spawned": 4,
                  "entity_type": "legacy:warrior_villager_gold",
                  "size": 2.5,
                  "sound_event": "prepare.wololo"
                },
                {
                  "shape": "circle",
                  "target": "self",
                  "base_delay": 0.1,
                  "delay_per_summon": 0,
                  "num_entities_spawned": 2,
                  "entity_type": "legacy:warrior_villager_diamond",
                  "size": 2.5,
                  "sound_event": "prepare.wololo"
                }
              ]
            },
            {
              "min_activation_range": 3,
              "cooldown_time": 15,
              "weight": 2,
              "cast_duration": 1,
              "particle_color": "#1557BE",
              "start_sound_event": "cast.spell",
              "sequence": [
                {
                  "shape": "circle",
                  "target": "self",
                  "base_delay": 1,
                  "delay_per_summon": 0,
                  "num_entities_spawned": 5,
                  "entity_type": "legacy:crossbowman_villager_gold",
                  "size": 2.5,
                  "sound_event": "prepare.wololo"
                },
                {
                  "shape": "circle",
                  "target": "self",
                  "base_delay": 0.1,
                  "delay_per_summon": 0,
                  "num_entities_spawned": 2,
                  "entity_type": "legacy:warrior_cavalry_villager_diamond",
                  "size": 2.5,
                  "sound_event": "prepare.wololo"
                }
              ]
            }
          ]
        },
        "minecraft:timer": {
          "looping": false,
          "time": [
            2,
            2
          ],
          "time_down_event": {
            "event": "minecraft:remove_summon",
            "target": "self"
          }
        }
      },
      "minecraft:countdown_to_summon": {
        "minecraft:timer": {
          "looping": false,
          "time": [
            4,
            5
          ],
          "time_down_event": {
            "event": "minecraft:on_summon"
          }
        }
      },
      "minecraft:set_angry": {
        "minecraft:angry": {
          "duration": 30,
          "broadcast_anger": true,
          "broadcast_anger_on_attack": true,
          "broadcast_anger_on_being_attacked": true,
          "broadcast_range": 16,
          "broadcast_targets": [
            "villager"
          ],
          "calm_event": {
            "event": "become_calm",
            "target": "self"
          },
          "angry_sound": "angry",
          "sound_interval": {
            "range_min": 2.0,
            "range_max": 5.0
          }
        }
      },
      "minecraft:default_targeting": {
        "minecraft:behavior.nearest_attackable_target": {
          "priority": 2,
          "must_see": true,
          "reselect_targets": true,
          "within_radius": 12.0,
          "must_see_forget_duration": 40.0,

          "entity_types": [
            {
              "filters": {
                "any_of": [
                  { "test": "is_family", "subject": "other", "value": "illager" },
                  { "test": "is_family", "subject": "other", "value": "monster" },
                  { "test": "is_family", "subject": "other", "value": "undead" }
                ]
              },
              "max_dist": 12
            },
            {
              "filters": {
                "all_of": [
                  {
                    "test": "is_family",
                    "subject": "other",
                    "value": "undead"
                  },
                  {
                    "test": "is_underwater",
                    "subject": "other",
                    "value": false
                  }
                ]
              },
              "max_dist": 16
            }
          ]
        }
      },
      "regeneration": {
        "minecraft:spell_effects": {
          "add_effects": [
            {
              "effect": "regeneration",
              "amplifier": 2,
              "visible": 1,
              "ambient": false,
              "duration": 30
            }
          ]
        }
      },
      "holy_light": {
        "minecraft:spell_effects": { // Beta
          "add_effects": [
            {
              "effect": "regeneration",
              "amplifier": 3,
              "visible": 1,
              "ambient": false,
              "duration": 25
            }
          ]
        }
      },
      "barter": {
        "minecraft:interact": {
          "interactions": [
            {
              "on_interact": {
                "filters": {
                  "all_of": [
                    {
                      "test": "has_equipment",
                      "subject": "other",
                      "domain": "hand",
                      "value": "gold_block"
                    },
                    {
                      "test": "is_family",
                      "subject": "other",
                      "value": "player"
                    },
                    {
                      "test": "has_component",
                      "subject": "self",
                      "operator": "!\u003d",
                      "value": "wild"
                    }
                  ]
                }
              },
              "barter": true,
              "admire": true,
              "use_item": true,
              "cooldown_after_being_attacked": 20,
              "interact_text": "action.interact.barter"
            }
          ]
        }
      },
      "minecraft:admire_barter": {
        "minecraft:behavior.admire_item": {
          "priority": 2,
          "admire_item_sound": "admire",
          "sound_interval": {
            "range_min": 2.0,
            "range_max": 3.0
          },
          "on_admire_item_start": {
            "event": "admire_item_started_event",
            "target": "self"
          },
          "on_admire_item_stop": {
            "event": "admire_item_stopped_event",
            "target": "self"
          }
        },
        "minecraft:admire_item": {
          "duration": 10,
          "cooldown_after_being_attacked": 30
        },
        "minecraft:barter": {
          "barter_table": "loot_tables/entities/lord_barter.json",
          "cooldown_after_being_attacked": 30
        },
        "minecraft:behavior.barter": {
          "priority": 3
        }
      },
      "minecraft:admire_interact": {
        "minecraft:behavior.admire_item": {
          "priority": 2,
          "admire_item_sound": "admire",
          "sound_interval": {
            "range_min": 2.0,
            "range_max": 3.0
          },
          "on_admire_item_start": {
            "event": "admire_item_started_event",
            "target": "self"
          },
          "on_admire_item_stop": {
            "event": "admire_item_stopped_event",
            "target": "self"
          }
        },
        "minecraft:admire_item": {
          "duration": 10,
          "cooldown_after_being_attacked": 4
        },
        "minecraft:barter": {
          "barter_table": "loot_tables/entities/lord_barter.json",
          "cooldown_after_being_attacked": 5
        },
        "minecraft:behavior.barter": {
          "priority": 3
        }
      },
      "minecraft:spawn_on_village": {
        "minecraft:preferred_path": {
          "max_fall_blocks": 1,
          "jump_cost": 20,
          "default_block_cost": 3,
          "preferred_path_blocks": [
            {
              "cost": 0,
              "blocks": [
                "grass_path"
              ]
            },
            {
              "cost": 1,
              "blocks": [
                "cobblestone",
                "stone",
                "stonebrick",
                "sandstone",
                "mossy_cobblestone",
                "stone_slab",
                "stone_slab2",
                "stone_slab3",
                "stone_slab4",
                "double_stone_slab",
                "double_stone_slab2",
                "double_stone_slab3",
                "double_stone_slab4",
                "wooden_slab",
                "double_wooden_slab",
                "planks",
                "brick_block",
                "nether_brick",
                "red_nether_brick",
                "end_bricks",
                "red_sandstone",
                "stained_glass",
                "glass",
                "glowstone",
                "prismarine",
                "emerald_block",
                "diamond_block",
                "lapis_block",
                "gold_block",
                "redstone_block",
                "purple_glazed_terracotta",
                "white_glazed_terracotta",
                "orange_glazed_terracotta",
                "magenta_glazed_terracotta",
                "light_blue_glazed_terracotta",
                "yellow_glazed_terracotta",
                "lime_glazed_terracotta",
                "pink_glazed_terracotta",
                "gray_glazed_terracotta",
                "silver_glazed_terracotta",
                "cyan_glazed_terracotta",
                "blue_glazed_terracotta",
                "brown_glazed_terracotta",
                "green_glazed_terracotta",
                "red_glazed_terracotta",
                "black_glazed_terracotta"
              ]
            },
            {
              "cost": 50,
              "blocks": [
                "bed",
                "lectern",
                "composter",
                "grindstone",
                "blast_furnace",
                "smoker",
                "fletching_table",
                "cartography_table",
                "brewing_stand",
                "smithing_table",
                "cauldron",
                "barrel",
                "loom",
                "stonecutter"
              ]
            }
          ]
        },
        "minecraft:behavior.explore_outskirts": {
          "priority": 5,
          "explore_dist": 7,
          "speed_multiplier": 0.9,
          "wait_time": 30
        },
        "minecraft:behavior.move_to_village": {
          "priority": 6,
          "speed_multiplier": 1.0
        },
        "minecraft:behavior.move_through_village": {
          "priority": 3,
          "speed_multiplier": 0.6,
          "only_at_night": true
        },
        "minecraft:pushable": {
          "is_pushable": true,
          "is_pushable_by_piston": true
        },
        "minecraft:behavior.random_stroll": {
          "priority": 5,
          "speed_multiplier": 0.7
        }
      }
    },
    "components": {
      "minecraft:is_hidden_when_invisible": {
      },
      "minecraft:experience_reward": {
        "on_death": "query.last_hit_by_player ? (query.is_baby ? 12 : 5) + (Math.die_roll(query.equipment_count,1,3)) : 0"
      },
      "minecraft:conditional_bandwidth_optimization": {
      },
      "minecraft:nameable": {
      },
      "minecraft:dweller": {
        "dwelling_type": "village",
        "dweller_role": "defender",
        "update_interval_base": 60,
        "update_interval_variant": 40,
        "can_find_poi": true,
        "can_migrate": true,
        "first_founding_reward": 15
      },
      "minecraft:type_family": {
        "family": [
          "villager",
          "iron_golem",
          "lord_villager",
          "guards",
          "mob"
        ]
      },
      "minecraft:variant": {
        "value": 0
      },
      "minecraft:breathable": {
        "total_supply": 15,
        "suffocate_time": 0
      },
      "minecraft:collision_box": {
        "width": 0.6,
        "height": 1.9
      },
      "minecraft:health": {
        "value": 580,
        "max": 580
      },
      "minecraft:boss": {
        "should_darken_sky": false,
        "hud_range": 65,
        "name": "The Lord Villager"
      },
      "minecraft:celebrate_hunt": { // Test when The Lord Illager died the villagers celebrating
        "celebration_targets": {
          "all_of": [
            {
              "test": "is_family",
              "value": "lord_illager"
            }
          ]
        },
        "broadcast": true,
        "duration": 25,
        "celebrate_sound": "celebrate",
        "sound_interval": {
          "range_min": 2.0,
          "range_max": 5.0
        },
        "jump_interval": {
          "range_min": 1.0,
          "range_max": 3.5
        },
        "radius": 16
      },
      "minecraft:knockback_resistance": {
        "value": 0.5
      },
      "minecraft:behavior.delayed_attack": {
        "priority": 3,
        "speed_multiplier": 1.0,
        "require_complete_path": false,
        "track_target": true,
        "hit_delay_pct": 0.40,
        "attack_duration": 0.79,
        "reach_multiplier": 3
      },
      "minecraft:hurt_on_condition": {
        "damage_conditions": [
          {
            "filters": { "test": "in_lava", "subject": "self", "operator": "==", "value": true },
            "cause": "lava",
            "damage_per_tick": 4
          }
        ]
      },
      "minecraft:damage_sensor": {
        "triggers": [
          {
            "on_damage": {
              "filters": {
                "test": "is_family",
                "subject": "other",
                "value": "villager"
              }
            },
            "deals_damage": false
          }
        ]
      },
      "minecraft:attack": {
        "damage": 20
      },
      "minecraft:movement": {
        "value": 0.35
      },
      "minecraft:navigation.walk": {
        "can_path_over_water": true,
        "can_pass_doors": true,
        "can_open_doors": true,
        "avoid_water": true
      },
      "minecraft:annotation.open_door": {
      },
      "minecraft:movement.basic": {
      },
      "minecraft:jump.static": {
      },
      "minecraft:follow_range": {
        "value": 64
      },
      "minecraft:loot": {
        "table": "loot_tables/entities/lord_loot.json"
      },
      "minecraft:equipment": {
        "table": "loot_tables/entities/lord/lord_gear.json",
        "slot_drop_chance": [
          {
            "slot": "slot.armor.head",
            "drop_chance": 0.1
          },
          {
            "slot": "slot.armor.chest",
            "drop_chance": 0.1
          },
          {
            "slot": "slot.armor.legs",
            "drop_chance": 0.1
          },
          {
            "slot": "slot.armor.feet",
            "drop_chance": 0.1
          }
        ]
      },
      "minecraft:behavior.float": {
        "priority": 0
      },
      "minecraft:behavior.random_stroll": {
        "priority": 9,
        "speed_multiplier": 1
      },
      "minecraft:behavior.look_at_player": {
        "priority": 10,
        "look_distance": 8,
        "probability": 0.02
      },
      "minecraft:behavior.hurt_by_target": {
        "priority": 1,
        "entity_types": {
          "filters": {
            "test": "is_family",
            "subject": "other",
            "operator": "!=",
            "value": "villager"
          },
          "max_dist": 64
        }
      },
      "minecraft:on_target_acquired": {
        "event": "become_angry",
        "target": "self"
      },
      "minecraft:on_target_escape": {
        "event": "become_calm",
        "target": "self"
      },
      "minecraft:physics": {
      },
      "minecraft:pushable": {
        "is_pushable": true,
        "is_pushable_by_piston": true
      }
    },
    "events": {
      "minecraft:entity_spawned": {
        "add": {
          "component_groups": [
            "minecraft:default_targeting",
            "minecraft:knockback_sensor",
            "minecraft:admire_barter",
            "barter"
          ]
        }
      },
      "minecraft:spawn_on_village": {
        "add": {
          "component_groups": [
            "minecraft:default_targeting",
            "minecraft:knockback_sensor",
            "minecraft:spawn_on_village",
            "minecraft:admire_barter",
            "barter"
          ]
        }
      },
      "become_angry": {
        "add": {
          "component_groups": [
            "minecraft:set_angry",
            "minecraft:start_casting"
          ]
        },
        "remove": {
          "component_groups": [
            "barter"
          ]
        }
      },
      "become_calm": {
        "remove": {
          "component_groups": [
            "minecraft:set_angry",
            "minecraft:start_casting",
            "minecraft:regeneration_cast",
            "minecraft:unit_summon"
          ]
        },
        "add": {
          "component_groups": [
            "barter"
          ]
        }
      },
      "minecraft:cast_holy_light": { // Beta
        "add": {
          "component_groups": [
            "holy_light"
          ]
        }
      },
      "minecraft:give_regeneration_villager": {
        "add": {
          "component_groups": [
            "regeneration"
          ]
        }
      },
      "minecraft:casting": {
        "sequence": [
          {
            "randomize": [
              {
                "weight": 150,
                "add": {
                  "component_groups": [
                    "minecraft:unit_summon"
                  ]
                }
              },
              {
                "weight": 150,
                "add": {
                  "component_groups": [
                    "minecraft:unit_summon_2"
                  ]
                }
              }
            ]
          }
        ]
      },
      "minecraft:knockback": {
        "remove": {
          "component_groups": [
            "minecraft:knockback_sensor"
          ]
        },
        "add": {
          "component_groups": [
            "minecraft:knockback"
          ]
        }
      },
      "minecraft:no_knockback": {
        "remove": {
          "component_groups": [
            "minecraft:knockback"
          ]
        },
        "add": {
          "component_groups": [
            "minecraft:knockback_sensor"
          ]
        }
      },
      "admire_started_event": {
        "remove": {
          "component_groups": [
            "interact"
          ]
        }
      },
      "admire_stopped_event": {
        "add": {
          "component_groups": [
            "interact"
          ]
        }
      },
      "admire_item_started_event": {
        "remove": {
          "component_groups": [
            "barter"
          ]
        }
      },
      "admire_item_stopped_event": {
        "add": {
          "component_groups": [
            "barter"
          ]
        }
      },
      "minecraft:start_celebrating": { // Event must be called exactly this for village to fire it when a raid is lost
        "sequence": [
          {
            "add": { "component_groups": [ "minecraft:celebrate" ] }
          },
          {
            "filters": { "test": "has_nametag", "value": false },
            "remove": { "component_groups": [ "minecraft:raid_persistence" ] }
          }
        ]
      },
      "minecraft:stop_celebrating": {
        "remove": { "component_groups": [ "minecraft:celebrate" ] }
      }
    }
  }
}