{
    "format_version": "1.10.0",
    "animation_controllers": {
		"controller.animation.ender_lord.mode": {
			"initial_state": "default",
			"states": {
				"default": {
					"on_entry": [
						"/scoreboard players set @s BeamDelay 0",
						"@s ad_setup_mode"
					],
					"animations": [
						"login_delay"
					],
					"transitions": [
						{ "swap_mode": "!q.property('ldz:is_dead') && q.all_animations_finished" },
						{ "dead": "q.property('ldz:is_dead')" }
					]
				},
				"swap_mode": {
					"transitions": [
						{ "melee": "q.property('ldz:mode') == 'melee_mode' && q.property('ldz:player_nearby')" },
						{ "summon": "q.property('ldz:mode') == 'summon_mode' && q.property('ldz:player_nearby')" },
						{ "beam": "q.property('ldz:mode') == 'beam_mode' && q.property('ldz:player_nearby')" },
						{ "dead": "q.property('ldz:is_dead')" }
					]
				},
				"melee": {
					"on_entry": [
						"/scoreboard players set @s BeamDelay 0",
						"@s set_beam_state_to_0"
					],
					"animations": [
						"attack_melee_delay"
					],
					"transitions": [
						{ "swap_mode": "!q.property('ldz:player_nearby')" },
						{ "from_melee": "q.all_animations_finished || q.property('ldz:mode') != 'melee_mode'" },
						{ "dead": "q.property('ldz:is_dead')" }
					]
				},
				"from_melee": {
					"on_entry": [
						"/scoreboard players set @s BeamDelay 0",
						"@s set_beam_state_to_0"
					],
					"transitions": [
						{ "swap_mode": "!q.property('ldz:is_dead')" },
						{ "dead": "q.property('ldz:is_dead')" }
					],
					"on_exit": [
						"@s randomize_from_melee"
					]
				},
				"summon": {
					"on_entry": [
						"/scoreboard players set @s BeamDelay 0",
						"@s set_beam_state_to_0"
					],
					"animations": [
						"attack_summon_delay"
					],
					"transitions": [
						{ "swap_mode": "!q.property('ldz:player_nearby')" },
						{ "from_summon": "q.all_animations_finished || q.property('ldz:mode') != 'summon_mode'" },
						{ "dead": "q.property('ldz:is_dead')" }
					]
				},
				"from_summon": {
					"on_entry": [
						"/scoreboard players set @s BeamDelay 0",
						"@s set_beam_state_to_0"
					],
					"transitions": [
						{ "swap_mode": "!q.property('ldz:is_dead')" },
						{ "dead": "q.property('ldz:is_dead')" }
					],
					"on_exit": [
						"@s randomize_from_summon"
					]
				},
				"beam": {
					"on_entry": [
						"/scoreboard players set @s BeamDelay 0"
					],
					"animations": [
						"attack_beam_delay"
					],
					"transitions": [
						{ "from_beam": "q.all_animations_finished || q.property('ldz:mode') != 'beam_mode'" },
						{ "dead": "q.property('ldz:is_dead')" }
					]
				},
				"from_beam": {
					"transitions": [
						{ "swap_mode": "!q.property('ldz:is_dead')" },
						{ "dead": "q.property('ldz:is_dead')" }
					],
					"on_exit": [
						"@s randomize_from_beam"
					]
				},
				"dead": {
					"on_entry": [
						"/scoreboard objectives add LordHP dummy",
						"/scoreboard objectives add Const dummy",
						"/scoreboard players set .10 Const 10",
						"/scoreboard players set @s LordHP 0",
						"/scoreboard players set \".var\" LordHP 0",
						"v.convert = q.health;",
						"v.digit = 100;",

						"@s remove_random_stroll",
						"@s remove_look_at_player"
					],
					"animations": [
						"health_to_score",
						"health_to_score",
						"health_to_score",
						"health_to_score",

						"despawn_delay"
					]
				}
			}
		},
		"controller.animation.ender_lord.beam": {
			"initial_state": "default",
			"states": {
				"default": {
					"on_entry": [
						"/stopsound @a mob.ender_lord.beam"
					],
					"transitions": [
						{ "charge": "q.is_casting && q.property('ldz:mode') == 'beam_mode'" },
						{ "dead": "q.property('ldz:is_dead')" }
					]
				},
				"charge": {
					"on_entry": [
						"@s add_before_beam",
						"@s add_look_at_player",
						"@s set_beam_state_to_1"
					],
					"animations": [
						"charge_delay",
						"face_player"
					],
					"transitions": [
						{ "beam": "q.all_animations_finished || !q.property('ldz:player_nearby')" },
						{ "default": "q.property('ldz:mode') != 'beam_mode'" },
						{ "dead": "q.property('ldz:is_dead')" }
					]
				},
				"beam": {
					"animations": [
						"beam_delay",
						"beam_sfx",
						{ "beam": "!q.property('ldz:is_dead')" }
					],
					"transitions": [
						{ "end": "q.all_animations_finished" },
						{ "default": "q.property('ldz:mode') != 'beam_mode'" },
						{ "dead": "q.property('ldz:is_dead')" }
					],
					"on_exit": [
						"/stopsound @a mob.ender_lord.beam"
					]
				},
				"end": {
					"on_entry": [
						"/scoreboard players set @s BeamDelay 0",
						"@s set_beam_state_to_3"
					],
					"animations": [
						"end_delay"
					],
					"transitions": [
						{ "default": "q.all_animations_finished || q.property('ldz:mode') != 'beam_mode'" },
						{ "dead": "q.property('ldz:is_dead')" }
					],
					"on_exit": [
						"/scoreboard players set @s BeamDelay 0",
						"@s remove_during_beam",
						"@s set_beam_state_to_0"
					]
				},
				"dead": {
					"on_entry": [
					"@s remove_random_stroll",
					"@s remove_look_at_player"
					]
				}
			}
		},
		"controller.animation.ender_lord.attack": {
			"initial_state": "default",
			"states": {
				"default": {
					"transitions": [
						{ "left_claw" : "q.property('ldz:mode') == 'melee_mode' && q.is_delayed_attacking && q.property('ldz:claw_side') == 1" },
						{ "right_claw" : "q.property('ldz:mode') == 'melee_mode' && q.is_delayed_attacking && q.property('ldz:claw_side') == 2" }
					]
				},
				"left_claw": {
					"on_entry": [
						"/event entity @s set_claw_side_to_2"
					],
					"transitions": [
						{ "default": "!q.is_delayed_attacking || q.property('ldz:mode') != 'melee_mode'" }
					]
				},
				"right_claw": {
					"on_entry": [
						"/event entity @s set_claw_side_to_1"
					],
					"transitions": [
						{ "default": "!q.is_delayed_attacking || q.property('ldz:mode') != 'melee_mode'" }
					]
				}
			}
		},
		"controller.animation.ender_lord.has_target": {
			"initial_state": "default",
			"states": {
				"default": {
					"transitions": [
						{ "summon" : "q.property('ldz:mode') == 'summon_mode'" },
						{ "melee" : "q.property('ldz:mode') == 'melee_mode'" },
						{ "dead": "q.property('ldz:is_dead')" }
					]
				},
				"summon": {
					"transitions": [
						{ "has_target" : "q.property('ldz:player_nearby') && !q.property('ldz:is_dead')" },
						{ "dead": "q.property('ldz:is_dead')" }
					]
				},
				"melee": {
					"transitions": [
						{ "has_target" : "q.property('ldz:player_nearby') && !q.property('ldz:is_dead')" },
						{ "dead": "q.property('ldz:is_dead')" }
					]
				},
				"has_target": {
					"on_entry": [
						"@s add_random_stroll"
					],
					"transitions": [
						{ "default": "!q.property('ldz:player_nearby') && !q.property('ldz:is_dead')" },
						{ "dead": "q.property('ldz:is_dead')" }
					],
					"on_exit": [
						"@s remove_random_stroll"
					]
				},
				"dead": {
					"on_entry": [
						"@s remove_random_stroll"
					]
				}
			}
		}
    }
}