{
	"format_version": "1.19.50",
	"minecraft:entity": {
		"description": {
			"identifier": "ldz:ender_lord",
			"is_spawnable": true,
			"is_summonable": true,
			"is_experimental": false,
			"animations": {
				"login_delay": "animation.ender_lord.login_delay",
				"charge_delay": "animation.ender_lord.charge_delay",
				"beam_delay": "animation.ender_lord.beam_delay",
				"end_delay": "animation.ender_lord.end_delay",
				"despawn_delay": "animation.ender_lord.despawn_delay",
				"despawn_redundancy": "animation.ender_lord.despawn_redundancy",

				"face_player": "animation.ender_lord.face_player",
				"beam": "animation.ender_lord.beam",
				"beam_sfx": "animation.ender_lord.beam_sfx",
				"health_to_score": "animation.ender_lord.health_to_score",
				
				"attack_melee_delay": "animation.ender_lord.attack_melee_delay",
				"attack_summon_delay": "animation.ender_lord.attack_summon_delay",
				"attack_beam_delay": "animation.ender_lord.attack_beam_delay",

				"ice_timer": "animation.vanilla.ice_timer",
				"ice_damage": "animation.vanilla.ice_damage",

				"ctrl.beam": "controller.animation.ender_lord.beam",
				"ctrl.attack": "controller.animation.ender_lord.attack",
				"ctrl.mode": "controller.animation.ender_lord.mode",
				"ctrl.ice_timer": "controller.animation.vanilla.ice_timer",

				"dupe_check": "animation.ender_lord.duplication_check",
				"home_check": "animation.ender_lord.home_check",

				"give_passive_force_to_player": "animation.ender_lord.give_passive_force_to_player"
			},
			"scripts": {
				"animate": [
					"ctrl.mode",
					"ctrl.beam",
					"ctrl.attack",
					"ctrl.ice_timer",
					{ "dupe_check": "q.property('ldz:boss_fight')" },
					{ "home_check": "q.property('ldz:boss_fight')" },
					{ "give_passive_force_to_player": "q.property('ldz:boss_fight')" },
					{ "despawn_redundancy": "q.property('ldz:is_dead')" }
				]
			},
			"properties": {
				"ldz:spawned": {
					"type": "bool",
					"default": "false",
					"client_sync": true
				},
				"ldz:mode": {
					"type": "enum",
					"values": [
						"setup_mode",
						"melee_mode",
						"beam_mode",
						"summon_mode"
					],
					"default": "melee_mode",
					"client_sync": true
				},
				"ldz:beam_state": {
					"type": "int",
					"range": [ 0, 3 ],
					"default": 0,
					"client_sync": true
				},
				"ldz:claw_side": {
					"type": "int",
					"range": [1, 2],
					"default": 1,
					"client_sync": true
				},
				"ldz:has_delayed_attack": {
					"type": "bool",
					"default": false,
					"client_sync": true
				},
				"ldz:player_nearby": {
					"type": "bool",
					"default": false,
					"client_sync": true
				},
				"ldz:is_dead": {
					"type": "bool",
					"default": false,
					"client_sync": true
				},
				"ldz:ice_overlay": {
					"type": "bool",
					"client_sync": true,
					"default": false
				},
				"ldz:boss_fight": {
					"type": "bool",
					"default": false,
					"client_sync": true
				}
			}
		},
		"component_groups": {
			"dead": {
				"minecraft:boss": {
					"hud_range": 0,
					"name": "entity.ldz:ender_lord.name",
					"should_darken_sky": false
				},
				"minecraft:movement.basic": { "max_turn": 0 },
				"minecraft:movement": { "value": 0 },
				"minecraft:collision_box": {
					"width": 0,
					"height": 0
				}
			},
			"look_at_player": {
				"minecraft:behavior.look_at_player": {
					"priority": 2,
					"look_distance": 30,
					"probability": 0.5
				}
			},
			"random_stroll": {
				"minecraft:behavior.random_stroll": {
					"priority": 7
				}
			},
			"remove_during_beam": {
				"minecraft:behavior.summon_entity": {
					"priority": 1,
					"summon_choices": [
						{
							"min_activation_range": 0,
							"max_activation_range": 30,
							"cooldown_time": 8.2,
							"weight": 1,
							"cast_duration": 0.1,
							"particle_color": "#ee7fff",
							"start_sound_event": "cast.spell",
							"sequence": [
								{
									"shape": "line",
									"target": "self",
									"base_delay": 1,
									"delay_per_summon": 0,
									"num_entities_spawned": 1,
									"entity_type": "ldz:ender_lord_dummy<despawn>",
									"size": 0,
									"entity_lifespan": 0.01
								}
							]
						}
					]
				}
			},
			"melee_mode": {
				"minecraft:attack": {
					"damage": 6
				},
				"minecraft:movement.basic": { "max_turn": 36 },
				"minecraft:movement": { "value": 0.45 },
				"minecraft:behavior.delayed_attack": {
					"priority": 1,
					"track_target": true,
					"melee_fov": 70,
					"attack_duration": 1,
					"hit_delay_pct": 0.45,
					"reach_multiplier": 3,
					"cooldown_time": 0.5
				},
				"minecraft:behavior.move_towards_target": {
					"priority": 2,
					"speed_multiplier": 1,
					"within_radius": 2.5
				},
				"minecraft:behavior.random_look_around": {
					"priority": 9
				}
			},
			"beam_mode": {
				"minecraft:attack": {
					"damage": 0
				},
				"minecraft:movement.basic": { "max_turn": 0 },
				"minecraft:movement": { "value": 0 }
			},
			"summon_mode": {
				"minecraft:attack": {
					"damage": 0
				},
				"minecraft:movement.basic": { "max_turn": 30 },
				"minecraft:movement": { "value": 0 },
				"minecraft:behavior.summon_entity": {
					"priority": 1,
					"summon_choices": [
						{
							"min_activation_range": 0,
							"max_activation_range": 30,
							"cooldown_time": 0.1,
							"weight": 1,
							"cast_duration": 2,
							"particle_color": "#ee7fff",
							"start_sound_event": "cast.spell",
							"sequence": [
								{
									"shape": "line",
									"target": "self",
									"base_delay": 1,
									"summon_cap": 12,
									"delay_per_summon": 0.2,
									"num_entities_spawned": 3,
									"entity_type": "ldz:ender_lord_wisp",
									"size": 2,
									"entity_lifespan": -1
								}
							]
						}
					]
				},
				"minecraft:behavior.move_towards_target": {
					"priority": 2,
					"speed_multiplier": 1,
					"within_radius": 5
				},
				"minecraft:behavior.random_look_around": {
					"priority": 9
				}
			},
			"ice_overlay": {				
				"minecraft:is_shaking": {}
			},
			"instant_despawn": {
				"minecraft:instant_despawn": {}
			},
			"boss_battle": {
				"minecraft:type_family": {
					"family": [
						"ldz",
						"ender",
						"ender_lord",
						"monster",
						"mob",
						"boss_fight"
					]
				}
			}
		},
		"components": {
			"minecraft:boss": {
				"hud_range": 30,
				"name": "entity.ldz:ender_lord.name",
				"should_darken_sky": false
			},
			"minecraft:type_family": {
				"family": [
					"ldz",
					"ender",
					"ender_lord",
					"monster",
					"mob"
				]
			},
			"minecraft:health": {
				"value": 300,
				"max": 300
			},
			"minecraft:collision_box": {
				"width": 1.3,
				"height": 3.2
			},
			"minecraft:movement": {
				"value": 0.2
			},
			"minecraft:attack": {
				"damage": 0
			},
			"minecraft:follow_range": {
				"value": 60,
				"max": 60
			},
			"minecraft:knockback_resistance": {
				"value": 0.6,
				"maximum": 0.6
			},
			"minecraft:nameable": {
				"always_show": false
			},
			"minecraft:loot": {
				"table": "loot_tables/entities/ender_lord.json"
			},
			"minecraft:navigation.generic": {
				"avoid_damage_blocks": true,
				"avoid_portals": true,
				"can_path_from_air": true,
				"can_sink": false,
				"can_swim": true,
				"can_walk": true
			},
			"minecraft:jump.static": {},
			"minecraft:can_climb": {},
			"minecraft:environment_sensor": {
				"triggers": [
					{
						"event": "set_player_nearby_to_true",
						"filters": [
							{
								"all_of": [
									{
										"test": "distance_to_nearest_player",
										"operator": "<=",
										"value": 30
									},
									{ 
										"test": "bool_property", 
										"domain": "ldz:player_nearby", 
										"value": false 
									}
								]
							}
						]
					},
					{
						"event": "set_player_nearby_to_false",
						"filters": [
							{
								"all_of": [
									{
										"test": "distance_to_nearest_player",
										"operator": ">",
										"value": 30
									},
									{ 
										"test": "bool_property", 
										"domain": "ldz:player_nearby", 
										"value": true
									}
								]
							}
						]
					}
				]
			},
			"minecraft:behavior.nearest_prioritized_attackable_target": {
				"priority": 3,
				"must_reach": false,
				"must_see": true,
				"reselect_targets": true,
				"entity_types": [
					{
						"max_dist": 60,
						"filters": {
							"all_of": [
								{
									"test": "is_family",
									"subject": "other",
									"value": "player"
								}
							]
						}
					}
				]
			},
			"minecraft:behavior.random_stroll": {
				"priority": 7
			},
			"minecraft:behavior.look_at_player": {
				"priority": 8,
				"look_distance": 16,
				"probability": 1
			},
			"minecraft:behavior.random_look_around": {
				"priority": 9
			},
			"minecraft:damage_sensor": {
				"triggers": [
					{
						"cause": "projectile",
						"deals_damage": false
					},
					{
						"on_damage": {
							"filters": [
								{
									"all_of": [
										{
											"test": "has_damage",
											"value": "fatal"
										},
										{
											"test": "bool_property",
											"domain": "ldz:is_dead",
											"value": false
										}
									]
								}
							],
							"event": "set_is_dead_to_true"
						},
						"deals_damage": false
					},
					{
						"on_damage": {
							"filters": [
								{
									"all_of": [
										{
											"test": "bool_property",
											"domain": "ldz:is_dead"
										},
										{
											"test": "has_damage",
											"operator": "!=",
											"value": "suicide"
										}
									]
								}
							]
						},
						"deals_damage": false
					},
					{
						"on_damage": {
							"filters": {
								"test": "has_damage",
								"value": "void"
							},
							"event": "despawn"
						},
						"deals_damage": false
					},
					{
						"on_damage": {
							"filters": {
								"any_of":[
									{ "test": "has_equipment", "subject": "other", "domain": "hand", "value": "minecraft:iron_axe" },
									{ "test": "has_equipment", "subject": "other", "domain": "hand", "value": "minecraft:iron_sword" },
									{ "test": "has_equipment", "subject": "other", "domain": "hand", "value": "minecraft:gold_sword" },
									{ "test": "has_equipment", "subject": "other", "domain": "hand", "value": "minecraft:diamond_sword" },
									{ "test": "has_equipment", "subject": "other", "domain": "hand", "value": "minecraft:netherite_sword" }
								]
							}
						},
						"damage_multiplier": 0.75
					},
					{
						"on_damage": {
							"filters": {
								"test": "is_family",
								"subject": "other",
								"value": "player_lord_wisp"
							},
							"target": "other",
							"event": "add_1_to_hits"
						}
					}
				]
			},
			"minecraft:persistent": {},
			"minecraft:physics": {},
			"minecraft:pushable": {
				"is_pushable": true,
				"is_pushable_by_piston": true
			}
		},
		"events": {
			"minecraft:entity_spawned": {
				"trigger": "add_melee_mode"
			},

			
			"randomize_from_melee": {
				"randomize": [
					{
						"trigger": "add_summon_mode",
						"weight": 14
					},
					{
						"trigger": "add_beam_mode",
						"weight": 12
					}
				]
			},

			"randomize_from_summon": {
				"randomize": [
					{
						"trigger": "add_melee_mode",
						"weight": 16
					},
					{
						"trigger": "add_beam_mode",
						"weight": 12
					}
				]
			},

			"randomize_from_beam": {
				"randomize": [
					{
						"trigger": "add_melee_mode",
						"weight": 10
					}
				]
			},

			"set_beam_state_to_0"		: { "set_property": { "ldz:beam_state": 0 } },
			"set_beam_state_to_1"		: { "set_property": { "ldz:beam_state": 1 } },
			"set_beam_state_to_2"		: { "set_property": { "ldz:beam_state": 2 } },
			"set_beam_state_to_3"		: { "set_property": { "ldz:beam_state": 3 } },
			
			"set_claw_side_to_1": { "set_property": { "ldz:claw_side": 1 } },
			"set_claw_side_to_2": { "set_property": { "ldz:claw_side": 2 } },
			
			"set_player_nearby_to_true": { "set_property": { "ldz:player_nearby": true } },
			"set_player_nearby_to_false": { "set_property": { "ldz:player_nearby": false } },

			"set_is_dead_to_true": { 
				"set_property": { "ldz:is_dead": true },
				"remove": { "component_groups": [ "melee_mode", "summon_mode", "beam_mode", "random_stroll", "look_at_player", "remove_during_beam" ] },
				"add": { "component_groups": [ "dead" ] }
			},

			"add_setup_mode": { 
				"set_property": { "ldz:mode": "setup_mode" },
				"remove": { "component_groups": [ "melee_mode", "summon_mode", "beam_mode", "random_stroll", "look_at_player", "remove_during_beam" ] }
			},

			"add_look_at_player": {
				"add": { "component_groups": [ "look_at_player" ] }
			},

			"remove_look_at_player": {
				"remove": { "component_groups": [ "look_at_player" ] }
			},
			
			"add_before_beam": {
				"add": { "component_groups": [ "remove_during_beam" ] }
			},
			
			"remove_during_beam": {
				"remove": { "component_groups": [ "remove_during_beam" ] }
			},

			"add_random_stroll": {
				"add": { "component_groups": [ "random_stroll" ] }
			},

			"remove_random_stroll": {
				"remove": { "component_groups": [ "random_stroll" ] }
			},

			"add_melee_mode": {
				"set_property": { "ldz:mode": "melee_mode" },
				"remove": { "component_groups": [ "beam_mode", "summon_mode", "remove_during_beam" ] },
				"add": { "component_groups": [ "melee_mode", "random_stroll", "look_at_player" ] }
			},
			
			"add_beam_mode": {
				"set_property": { "ldz:mode": "beam_mode" },
				"remove": { "component_groups": [ "melee_mode", "summon_mode", "random_stroll" ] },
				"add": { "component_groups": [ "beam_mode", "look_at_player", "remove_during_beam" ] }
			},

			"add_summon_mode": {
				"set_property": { "ldz:mode": "summon_mode" },
				"remove": { "component_groups": [ "beam_mode", "melee_mode", "remove_during_beam" ] },
				"add": { "component_groups": [ "summon_mode", "random_stroll", "look_at_player" ] }
			},
			"set_ice_overlay_to_true": {
				"set_property": {
					"ldz:ice_overlay": true
				},
				"add": {
					"component_groups": [
						"ice_overlay"
					]
				}
			},
			"set_ice_overlay_to_false": {
				"set_property": {
					"ldz:ice_overlay": false
				},
				"remove": {
					"component_groups": [
						"ice_overlay"
					]
				}
			},
			"set_boss_fight_to_true": {
				"sequence": [
					{
						"trigger": "minecraft:entity_spawned"
					},
					{
						"set_property": {
							"ldz:boss_fight": true
						}
					},
					{
						"add": {
							"component_groups": [
								"boss_battle"
							]
						}
					}
				]
			},
			"set_boss_fight_to_false": { "trigger": "minecraft:entity_spawned", "set_property": { "ldz:boss_fight": false } },
			"despawn": {
				"add": {
					"component_groups": [
						"instant_despawn"
					]
				}
			}
		}
	}
}