{
	"format_version": "1.10.0",
	"minecraft:client_entity": {
		"description": {
			"identifier": "shapescape_mb:mammoth_boss",
			"materials": {
				"default": "entity_emissive_alpha"
			},
			"textures": {
				"phase_1": "textures/shapescape/mb/entity/mammoth_boss/mammoth_boss_1",
				"phase_2": "textures/shapescape/mb/entity/mammoth_boss/mammoth_boss_2",
				"phase_3": "textures/shapescape/mb/entity/mammoth_boss/mammoth_boss_3",
				"pikes": "textures/shapescape/mb/entity/mammoth_boss/mammoth_boss_pikes"
			},
			"geometry": {
				"default": "geometry.shapescape_mb.mammoth_boss"
			},
			"scripts": {
				"initialize": [
					"v.custom_y_rotation = q.body_y_rotation;",
					"v.charge_attack_y_rotation = q.body_y_rotation;",
					"v.is_charge_attacking = 0;",
					"v.smooth_modified_move_speed = 0;"
				],
				"pre_animation": [
					"v.smooth_modified_move_speed = math.lerp(v.smooth_modified_move_speed, q.modified_move_speed, math.exp(-2 * q.delta_time));",
					"v.should_snap_aim = q.property('shapescape_mb:mammoth_state') == 'projectile';",
					"v.is_charge_attacking = q.property('shapescape_mb:mammoth_state') == 'charge';",
					// If 'is_charge_attacking' changes from 0 to 1, save the current body rotation
					"v.charge_attack_y_rotation = v.is_charge_attacking == 1.0 ? q.property('shapescape_mb:charge_body_rotation') : v.charge_attack_y_rotation;",
					"v.is_charge_attacking = v.is_charge_attacking;",
					// Result rotation before smoothing
					"v.custom_y_rotation = v.is_charge_attacking ? v.charge_attack_y_rotation : q.target_y_rotation+q.body_y_rotation;",
					// Smoothed rotation
					// Framerate-independent lerp smoothing: https://www.youtube.com/watch?v=LSNQuFEDOyQ
					"v.custom_y_rotation = math.lerprotate(v.custom_y_rotation, v.custom_y_rotation, math.exp(-2 * q.delta_time));",
					"v.custom_y_rotation = v.should_snap_aim ? q.target_y_rotation+q.body_y_rotation : v.custom_y_rotation;"
				],
				"animate": [
					"ac.general",
					"ac.phase_3_shield",
					"ac.change_phase",
					{
						"spikes_hide": "q.property('shapescape_mb:mammoth_phase') == 1 || (q.property('shapescape_mb:mammoth_phase') == 2 && !q.is_illager_captain)"
					},
					{
						"eyelids_hide": "q.property('shapescape_mb:mammoth_state') != 'death'"
					}
				]
			},
			"animations": {
				"ac.general": "controller.animation.shapescape_mb.mammoth_boss.general",
				"ac.idle_walk": "controller.animation.shapescape_mb.mammoth_boss.idle_walk",
				"ac.change_phase": "controller.animation.shapescape_mb.mammoth_boss.change_phase",

				"charge": "animation.shapescape_mb.mammoth_boss.charge",
				"walk": "animation.shapescape_mb.mammoth_boss.walk",
				"charge_sound": "animation.shapescape_mb.mammoth_boss.charge_sound",
				"charge_walk": "animation.shapescape_mb.mammoth_boss.charge_walk",
				"charge_head": "animation.shapescape_mb.mammoth_boss.charge_head",
				"idle": "animation.shapescape_mb.mammoth_boss.idle",
				// Attacks
				"ac.phase_3_shield": "controller.animation.shapescape_mb.mammoth_boss.phase_3_shield",
				"a.phase_3_shield": "animation.shapescape_mb.mammoth_boss.phase_3_shield",
				"attack_right": "animation.shapescape_mb.mammoth_boss.attack_right",
				"attack_left": "animation.shapescape_mb.mammoth_boss.attack_left",
				"stomp": "animation.shapescape_mb.mammoth_boss.stomp",
				"magma": "animation.shapescape_mb.mammoth_boss.magma",
				"rotate_towards_target": "animation.shapescape_mb.mammoth_boss.rotate_towards_target",
				"death": "animation.shapescape_mb.mammoth_boss.death",

				"spikes_hide": "animation.shapescape_mb.mammoth_boss.spikes_hide",
				"initialize_phase_2": "animation.shapescape_mb.mammoth_boss.initialize_phase_2",
				"initialize_phase_3": "animation.shapescape_mb.mammoth_boss.initialize_phase_3",
				"eyelids_hide": "animation.shapescape_mb.mammoth_boss.eyelids_hide",

				"lock_rotation": "animation.shapescape_mb.mammoth_boss.lock_rotation"
			},
			"render_controllers": [
				// Making separate render controllers as we might want to display different materials later on.
				{
					"controller.render.shapescape_mb.mammoth_boss.phase_1": "q.property('shapescape_mb:mammoth_phase') == 1"
				},
				{
					"controller.render.shapescape_mb.mammoth_boss.phase_2": "q.property('shapescape_mb:mammoth_phase') == 2"
				},
				{
					"controller.render.shapescape_mb.mammoth_boss.phase_3": "q.property('shapescape_mb:mammoth_phase') == 3"
				}
			],
			"particle_effects": {
				"phase_3_shield_0": "shapescape_mb:mammoth_phase_3_shield_0",
				"lava_leaks": "shapescape_mb:lava_leaks"
			},
			"sound_effects": {
				"phase_3_shield": "shapescape_mb.mammoth_boss.phase_3_shield",
				"step": "shapescape_mb.mammoth_boss.step",
				"attack": "shapescape_mb.mammoth_boss.attack",
				"charge_attack": "shapescape_mb.mammoth_boss.charge_attack",
				"change_phase": "shapescape_mb.mammoth_boss.stomp_start",
				"death": "shapescape_mb.mammoth_boss.death",
				"death_fire_leak": "shapescape_mb.mammoth_boss.death_fire_leak"
			},
			"spawn_egg": {
				"base_color": "#3b0b0b",
				"overlay_color": "#000000"
			}
		}
	}
}
