{
	"format_version": "1.16.0",
	"minecraft:entity": {
		"description": {
			"identifier": "cc_fairytales:mega_crab",
			"is_spawnable": true,
			"is_summonable": true,
			"is_experimental": false
		},
		"component_groups": {
			"inicial":{
				"minecraft:mark_variant": {
					"value": 0
				}
			},
			// --------	 ETAPA 1 ----------
			"mode_switcher": {
				"minecraft:target_nearby_sensor": {
					"inside_range": 2.9,
					"outside_range": 3.0,
					"must_see": true,
					"on_inside_range": {
						"event": "switch_to_melee",
						"target": "self"
					},
					"on_outside_range": {
						"event": "switch_to_ranged",
						"target": "self"
					}
				},
				"minecraft:behavior.move_towards_target": {
					"priority": 2,
					"speed_multiplier": 0.9,
					"within_radius": 10
				}
			},
			"ranged_mode_e1": {
				"minecraft:shooter": {
					"def": "cc_fairytales:sand_ball"
				},
				"minecraft:behavior.ranged_attack": {
					"priority": 0,
					"burst_shots": 1,
					"attack_interval_min": 1.0,
					"attack_interval_max": 3.0,
					"attack_radius": 20.0
				}
			},
			"melee_mode_e1": {
				"minecraft:attack": {
					"damage": 12
				},
				"minecraft:behavior.melee_box_attack": {
					"priority": 0,
					"track_target": true
				}
			},
			"periodo_gracia": {
				"minecraft:environment_sensor": {
					"triggers": [
						{
							"event": "quedarse_quieto",
							"filters": {
								"all_of": [
									{
										"test": "actor_health",
										"subject": "self",
										"value": 25,
										"operator": "<="
									}
								]
							}
						}
					]
				},
				
				"minecraft:damage_sensor": {
					"triggers": [
						{
							"on_damage": {
								"filters": {
									"all_of": [
										{
											"test": "has_damage",
											"subject": "self",
											"value": "fatal"
										}
									]
								}
							},
							"deals_damage": false
						}
					]
				}
			},
			// --------	 ETAPA 2 ----------
			"spawn_cangrejitos": {
				"minecraft:spawn_entity": {
					"entities": [
						{
							"min_wait_time": 10,
							"max_wait_time": 10,
							"spawn_entity": "cc_fairytales:mini_crab",
							"single_use": false,
							"num_to_spawn": 10
						}
					]
				}
			},
			"regeneracion": {
				"minecraft:spell_effects": {
					"add_effects": [
						{
							"effect": "regeneration",
							"duration": 56,
							"amplifier": 3
						}
					]
				}
			},
			"quieto": {
				"minecraft:mark_variant": {
					"value": 1
				},
				"minecraft:movement": {
					"value": 0
				},
				"minecraft:damage_sensor": {
					"triggers": [
						{
							"cause": "all",
							"deals_damage": false
						}
					]
				}
			},
			"timer_vida": {
				"minecraft:timer": {
					"time": 56,
					"looping": false,
					"time_down_event": {
						"event": "vuelta_ataque",
						"target": "self"
					}
				}
			},
			// --------	 ETAPA 3 ----------
			"spawn_cangrejitos2": {
				"minecraft:spawn_entity": {
					"entities": [
						{
							"min_wait_time": 5,
							"max_wait_time": 5,
							"spawn_entity": "cc_fairytales:mini_crab",
							"single_use": false,
							"num_to_spawn": 10
						}
					]
				}
			},
			"moverse_denuevo": {
				"minecraft:movement": {
					"value": 0.3
				},
				"minecraft:damage_sensor": {
					"triggers": [
						{
							"on_damage": {
								"filters": {
									"all_of": [
										{
											"test": "has_damage",
											"subject": "self",
											"value": "fatal"
										}
									]
								},
								"event": "activar_explosion"
							},
							"deals_damage": false
						}
					]
				}
			},
			"explosion": {
				"minecraft:mark_variant": {
					"value": 2
				},
				"minecraft:ambient_sound_interval": {
					"event_name": "fuse",
					"range": 7,
					"value": 6
				},
				"minecraft:movement": {
					"value": 0.0
				},
				"minecraft:explode": {
					"breaks_blocks": true,
					"causes_fire": false,
					"destroy_affected_by_griefing": true,
					"fire_affected_by_griefing": true,
					"fuse_lit": true,
					"power": 15,
					"fuse_length": 5
				},
				"minecraft:damage_sensor": {
					"triggers": [
						{
							"cause": "all",
							"deals_damage": false
						}
					]
				},
				"minecraft:spawn_entity": {
					"entities": [
						{
							"min_wait_time": 0,
							"max_wait_time": 1,
							"spawn_entity": "cc_fairytales:crab_loot",
							"single_use": true,
							"num_to_spawn": 1
						}
					]
				}
			}
		},
		"components": {
			"minecraft:type_family": {
				"family": [
					"mob",
					"mega_crab",
					"monster"
				]
			},
			"minecraft:behavior.hurt_by_target": {
				"priority": 3
			},
			"minecraft:nameable": {},
			"minecraft:movement.basic": {},
			"minecraft:jump.static": {},
			"minecraft:can_climb": {},
			"minecraft:collision_box": {
				"width": 3,
				"height": 3
			},
			"minecraft:boss": {
				"name": "MEGA CRAB",
				"hud_range": 55
			},"minecraft:experience_reward": {
				"on_death": "100"
			},
			"minecraft:health": {
				"value": 200
			},
			"minecraft:navigation.climb": {
				"can_path_over_water": true
			},
			"minecraft:movement": {
				"value": 0.35
			},
			"minecraft:despawn": {
				"despawn_from_distance": {}
			},
			"minecraft:behavior.float": {
				"priority": 0
			},
			"minecraft:behavior.random_stroll": {
				"priority": 6,
				"speed_multiplier": 0.8
			},
			"minecraft:behavior.look_at_player": {
				"priority": 7,
				"look_distance": 6,
				"probability": 0.02
			},
			"minecraft:behavior.random_look_around": {
				"priority": 9
			},
			"minecraft:physics": {},
			"minecraft:conditional_bandwidth_optimization": {},
			"minecraft:behavior.nearest_attackable_target": {
				"attack_owner": false,
				"must_reach": true,
				"must_see": true,
				"must_see_forget_duration": 3,
				"persist_time": 3,
				"reselect_targets": true,
				"scan_interval": 10,
				"set_persistent": true,
				"target_invisible_multiplier": 0.5,
				"target_search_height": -1,
				"target_sneak_visibility_multiplier": 0.8,
				"entity_types": [
					{
						"filters": {
							"test": "is_family",
							"subject": "other",
							"value": "player"
						},
						"max_dist": 30
					}
				]
			},
			"minecraft:knockback_resistance": {
				"value": 100
			},
			"minecraft:damage_sensor": {
				"triggers": [
					{
						"cause": "projectile",
						"deals_damage": false
					}
				]
			}
		},
		"events": {
			"minecraft:entity_spawned": {
				"add": {
					"component_groups": [
						"mode_switcher",
						"periodo_gracia",
						"inicial"
					]
				}
			},
			"switch_to_melee": {
				"remove": {
					"component_groups": [
						"ranged_mode_e1"
					]
				},
				"add": {
					"component_groups": [
						"melee_mode_e1"
					]
				}
			},
			"switch_to_ranged": {
				"remove": {
					"component_groups": [
						"melee_mode_e1"
					]
				},
				"add": {
					"component_groups": [
						"ranged_mode_e1"
					]
				}
			},
			"quedarse_quieto": {
				"add": {
					"component_groups": [
						"quieto",
						"regeneracion",
						"spawn_cangrejitos",
						"timer_vida",
						"melee_mode_e1"
					]
				},
				"remove": {
					"component_groups": [
						"mode_switcher",
						"ranged_mode_e1",
						"inicial"
					]
				}
			},
			"vuelta_ataque": {
				"add": {
					"component_groups": [
						"ranged_mode_e1",
						"spawn_cangrejitos2",
						"moverse_denuevo",
						"inicial"
					]
				},
				"remove": {
					"component_groups": [
						"regeneracion",
						"quieto",
						"spawn_cangrejitos",
						"melee_mode_e1",
						"periodo_gracia",
						"mode_switcher"
					]
				}
			},
			"activar_explosion": {
				"remove": {
					"component_groups": [
						"moverse_denuevo"
					]
				},
				"add": {
					"component_groups": [
						"explosion"
					]
				}
			}
		}
	}
}