{
  "format_version": "1.26.0",
  "minecraft:entity": {
    "description": {
      "identifier": "minecraft:vindicator",
      "is_experimental": false,
      "is_summonable": true,
      "is_spawnable": true,
      "spawn_category": "monster"
    },
    "components": {
      "minecraft:attack": {
        "damage": 8
      },
      // vindicator Behaviors
      "minecraft:behavior.float": {
        "priority": 0
      },
      "minecraft:behavior.hurt_by_target": {
        "priority": 1
      },
      "minecraft:behavior.look_at_player": {
        "look_time": {
          "min": 1,
          "max": 2
        },
        "priority": 10
      },
      "minecraft:behavior.melee_attack": {
        "priority": 3
      },
      "minecraft:behavior.random_stroll": {
        "priority": 9,
        "speed_multiplier": 1
      },
      "minecraft:breathable": {
        "suffocate_time": 0,
        "total_supply": 15
      },
      "minecraft:collision_box": {
        "height": 1.9,
        "width": 0.6
      },
      "minecraft:conditional_bandwidth_optimization": {},
      "minecraft:equipment": {
        "table": "loot_tables/entities/vindicator_gear.json"
      },
      "minecraft:experience_reward": {
        "on_death": {
          "expression": "query.last_hit_by_player ? (query.is_baby ? 12 : 5) + (Math.die_roll(query.equipment_count,1,3)) : 0",
          "version": 6
        }
      },
      "minecraft:follow_range": {
        "value": 64
      },
      "minecraft:health": {
        "max": 24,
        "value": 24
      },
      "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:loot": {
        "table": "loot_tables/entities/vindication_illager.json"
      },
      "minecraft:movement": {
        "value": 0.35
      },
      "minecraft:movement.basic": {},
      "minecraft:nameable": {
        "default_trigger": {
          "event": "minecraft:stop_johnny",
          "target": "self"
        },
        "name_actions": [
          {
            "name_filter": "Johnny",
            "on_named": {
              "event": "minecraft:start_johnny",
              "target": "self"
            }
          }
        ]
      },
      "minecraft:navigation.walk": {
        "can_path_over_water": true,
        "using_door_annotation": true
      },
      "minecraft:on_target_acquired": {
        "event": "minecraft:become_aggro",
        "target": "self"
      },
      "minecraft:on_target_escape": {
        "event": "minecraft:stop_aggro",
        "target": "self"
      },
      "minecraft:physics": {},
      "minecraft:pushable": {
        "is_pushable": true,
        "is_pushable_by_piston": true
      },
      // vindicator Components
      "minecraft:type_family": {
        "family": [
          "vindicator",
          "monster",
          "illager",
          "mob"
        ]
      },
      "minecraft:variant": {
        "value": 0
      }
    },
    "component_groups": {
      "minecraft:default_targeting": {
        "minecraft:behavior.nearest_attackable_target": {
          "must_see": true,
          "within_radius": 12,
          "must_see_forget_duration": 40,
          "entity_types": [
            {
              "filters": {
                "AND": [
                  {
                    "OR": [
                      {
                        "test": "is_family",
                        "subject": 1,
                        "operator": 0,
                        "value": "player"
                      },
                      {
                        "test": "is_family",
                        "subject": 1,
                        "operator": 0,
                        "value": "snowgolem"
                      },
                      {
                        "test": "is_family",
                        "subject": 1,
                        "operator": 0,
                        "value": "irongolem"
                      },
                      {
                        "test": "is_family",
                        "subject": 1,
                        "operator": 0,
                        "value": "wandering_trader"
                      }
                    ]
                  }
                ]
              },
              "max_dist": 12
            },
            {
              "filters": {
                "AND": [
                  {
                    "test": "is_family",
                    "subject": 1,
                    "operator": 0,
                    "value": "villager"
                  },
                  {
                    "test": "has_component",
                    "subject": 1,
                    "operator": 1,
                    "value": "minecraft:is_baby"
                  }
                ]
              },
              "max_dist": 12
            }
          ],
          "priority": 2
        }
      },
      "minecraft:patrol_follower": {
        "minecraft:behavior.follow_target_captain": {
          "follow_distance": 5,
          "priority": 5,
          "speed_multiplier": 0.8,
          "within_radius": 64
        }
      },
      "minecraft:celebrate": {
        "minecraft:behavior.celebrate": {
          "celebration_sound": "celebrate",
          "duration": 30,
          "jump_interval": {
            "range_max": 3.5,
            "range_min": 1
          },
          "on_celebration_end_event": {
            "event": "minecraft:stop_celebrating",
            "target": "self"
          },
          "priority": 5,
          "sound_interval": {
            "range_max": 7,
            "range_min": 2
          }
        }
      },
      "minecraft:raid_despawn": {
        "minecraft:despawn": {
          "despawn_from_distance": {}
        }
      },
      "minecraft:illager_squad_captain": {
        "minecraft:damage_sensor": {
          "triggers": {
            "on_damage": {
              "event": "minecraft:gain_bad_omen",
              "filters": {
                "all_of": [
                  {
                    "test": "has_damage",
                    "value": "fatal"
                  },
                  {
                    "subject": "other",
                    "test": "is_family",
                    "value": "player"
                  }
                ]
              },
              "target": "other"
            }
          }
        },
        "minecraft:equipment": {
          "slot_drop_chance": [
            {
              "drop_chance": 1,
              "slot": "slot.armor.chest"
            }
          ],
          "table": "loot_tables/entities/vindicator_captain_equipment.json"
        },
        "minecraft:is_illager_captain": {},
        "minecraft:variant": {
          "value": 1
        }
      },
      "minecraft:patrol_captain": {
        "minecraft:behavior.move_to_random_block": {
          "block_distance": 512,
          "priority": 5,
          "speed_multiplier": 0.55,
          "within_radius": 8
        },
        "minecraft:damage_sensor": {
          "triggers": {
            "on_damage": {
              "event": "minecraft:gain_bad_omen",
              "filters": {
                "all_of": [
                  {
                    "test": "has_damage",
                    "value": "fatal"
                  },
                  {
                    "subject": "other",
                    "test": "is_family",
                    "value": "player"
                  }
                ]
              },
              "target": "other"
            }
          }
        },
        "minecraft:equipment": {
          "slot_drop_chance": [
            {
              "drop_chance": 1,
              "slot": "slot.armor.chest"
            }
          ],
          "table": "loot_tables/entities/vindicator_captain_equipment.json"
        },
        "minecraft:is_illager_captain": {},
        "minecraft:variant": {
          "value": 1
        }
      },
      "minecraft:raid_configuration": {
        "minecraft:ambient_sound_interval": {
          "event_name": "ambient.in.raid",
          "range": 4,
          "value": 2
        },
        "minecraft:annotation.break_door": {
          "break_time": 30,
          "min_difficulty": "normal"
        },
        "minecraft:behavior.move_to_village": {
          "goal_radius": 2,
          "priority": 4,
          "speed_multiplier": 1
        },
        "minecraft:dweller": {
          "can_find_poi": false,
          "dwelling_type": "village",
          "can_migrate": true,
          "dweller_role": "hostile",
          "first_founding_reward": 0,
          "update_interval_base": 60,
          "update_interval_variant": 40
        },
        "minecraft:loot": {
          "table": "loot_tables/entities/vindicator_raid.json"
        },
        "minecraft:navigation.walk": {
          "can_break_doors": true,
          "can_pass_doors": true,
          "can_path_over_water": true
        }
      },
      "minecraft:raid_persistence": {
        "minecraft:persistent": {}
      },
      "minecraft:vindicator_aggro": {
        "minecraft:angry": {
          "broadcast_anger": false,
          "calm_event": {
            "event": "minecraft:stop_aggro",
            "target": "self"
          },
          "duration": -1
        }
      },
      "minecraft:vindicator_johnny": {
        "minecraft:behavior.nearest_attackable_target": {
          "must_see": true,
          "within_radius": 12,
          "must_see_forget_duration": 40,
          "entity_types": [
            {
              "filters": {
                "AND": [
                  {
                    "test": "is_family",
                    "subject": 1,
                    "operator": 1,
                    "value": "illager"
                  }
                ]
              },
              "max_dist": 12
            }
          ],
          "priority": 2
        }
      }
    },
    "events": {
      "minecraft:spawn_for_raid": {
        "add": {
          "component_groups": [
            "minecraft:default_targeting",
            "minecraft:raid_configuration",
            "minecraft:raid_persistence",
            "minecraft:raid_despawn"
          ]
        }
      },
      "minecraft:become_aggro": {
        "add": {
          "component_groups": [
            "minecraft:vindicator_aggro"
          ]
        }
      },
      "minecraft:entity_spawned": {
        "add": {
          "component_groups": [
            "minecraft:default_targeting"
          ]
        }
      },
      "minecraft:raid_expired": {
        "sequence": [
          {
            "filters": {
              "test": "has_nametag",
              "value": false
            },
            "remove": {
              "component_groups": [
                "minecraft:raid_persistence"
              ]
            }
          }
        ]
      },
      "minecraft:promote_to_illager_captain": {
        "add": {
          "component_groups": [
            "minecraft:default_targeting",
            "minecraft:illager_squad_captain"
          ]
        },
        "remove": {
          "component_groups": [
            "minecraft:patrol_follower"
          ]
        }
      },
      "minecraft:spawn_as_illager_captain": {
        "add": {
          "component_groups": [
            "minecraft:default_targeting",
            "minecraft:illager_squad_captain"
          ]
        }
      },
      "minecraft:promote_to_patrol_captain": {
        "add": {
          "component_groups": [
            "minecraft:default_targeting",
            "minecraft:patrol_captain"
          ]
        },
        "remove": {
          "component_groups": [
            "minecraft:patrol_follower"
          ]
        }
      },
      "minecraft:spawn_as_patrol_follower": {
        "add": {
          "component_groups": [
            "minecraft:default_targeting",
            "minecraft:patrol_follower"
          ]
        }
      },
      "minecraft:stop_johnny": {
        "add": {
          "component_groups": [
            "minecraft:default_targeting"
          ]
        },
        "remove": {
          "component_groups": [
            "minecraft:vindicator_johnny"
          ]
        }
      },
      "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:start_johnny": {
        "add": {
          "component_groups": [
            "minecraft:vindicator_johnny"
          ]
        }
      },
      "minecraft:stop_aggro": {
        "remove": {
          "component_groups": [
            "minecraft:vindicator_aggro"
          ]
        }
      },
      "minecraft:stop_celebrating": {
        "remove": {
          "component_groups": [
            "minecraft:celebrate"
          ]
        }
      }
    }
  }
}