{
  "format_version": "1.21.0",
  "minecraft:entity": {
    "description": {
      "identifier": "cyn_hao:seahorse_small",
      "is_spawnable": true,
      "is_summonable": true,
      "is_experimental": false,

      "properties": {
        // Base Color Property
        "cyn_hao:base_id": {
          "type": "int",
          "range": [0, 7],
          "default": 0,
          "client_sync": true
        }
      }
    },

    "component_groups": {
      // tons of scale component groups since
      // we apparently can't change scale (ACTUAL scale,
      // not just animated-scale) through scripts
      "cyn_hao:group_scale_0.4": {
        "minecraft:scale": {
          "value": 0.4
        }
      },
      "cyn_hao:group_scale_0.5": {
        "minecraft:scale": {
          "value": 0.5
        }
      },
      "cyn_hao:group_scale_0.6": {
        "minecraft:scale": {
          "value": 0.6
        }
      },
      "cyn_hao:group_scale_0.7": {
        "minecraft:scale": {
          "value": 0.7
        }
      },
      "cyn_hao:group_scale_0.75": {
        "minecraft:scale": {
          "value": 0.75
        }
      },
      "cyn_hao:group_scale_0.8": {
        "minecraft:scale": {
          "value": 0.8
        }
      },
      "cyn_hao:group_scale_0.9": {
        "minecraft:scale": {
          "value": 0.9
        }
      },
      "cyn_hao:group_scale_1.0": {
        "minecraft:scale": {
          "value": 1.0
        }
      },
      "cyn_hao:group_scale_1.1": {
        "minecraft:scale": {
          "value": 1.1
        }
      },
      "cyn_hao:group_scale_1.2": {
        "minecraft:scale": {
          "value": 1.2
        }
      },
      "cyn_hao:group_scale_1.3": {
        "minecraft:scale": {
          "value": 1.3
        }
      },


      "cyn_hao:group_horse_baby": {
        "minecraft:is_baby": {
        },
        "minecraft:scale_by_age": {
          "start_scale": 0.5,
          "end_scale": 1.0
        },
        "minecraft:ageable": { 
          "duration": 1200,
          "feed_items": [
            {
              "item": "kelp",
              "growth": 0.15
            }
          ],
          "grow_up": {
            "event": "cyn_hao:ageable_grow_up",
            "target": "self"
          }
        },
        "minecraft:behavior.follow_parent": {
          "priority": 3,
          "speed_multiplier": 1.0
        }
      },



      "cyn_hao:group_water_movement": {
        "minecraft:environment_sensor": {
          "triggers": [
            {
              "event": "cyn_hao:event_land_movement",
              "target": "self",
              "filters": {
                "test": "in_water",
                "value": false
              }
            }
          ]
        },

        "minecraft:underwater_movement": {
          "value": 0.12
        },
        "minecraft:navigation.generic": {
          "is_amphibious": true,
          "can_path_over_water": false,
          "can_swim": true,
          "can_walk": true,
          "can_sink": false,
          "avoid_damage_blocks": true
        },
        "minecraft:movement.sway": {
          "sway_amplitude": 0.0
        },
        "minecraft:behavior.swim_idle": {
          "priority": 6,
          "idle_time": 5.0,
          "success_rate": 0.1
        },
        "minecraft:behavior.random_swim": { // Randomly selects points to go to, even in water
          "priority": 4,
          "speed_multiplier": 1.0,
          "xz_dist": 16,
          "y_dist": 4,
          "interval": 0
        },
        "minecraft:behavior.swim_wander": {
          "priority": 5,
          "interval": 0.1,
          "look_ahead": 2.0,
          "speed_multiplier": 1.0,
          "wander_time": 5.0
        },
        "minecraft:flocking": {
          "in_water": true,
          "match_variants": true,
          "use_center_of_mass": false,
          "low_flock_limit": 4,
          "high_flock_limit": 8,
          "goal_weight": 2.0,
          "loner_chance": 0.1,
          "influence_radius": 3.0,
          "breach_influence": 7.0,
          "separation_weight": 0.65,
          "separation_threshold": 0.15,
          "cohesion_weight": 2.75,
          "cohesion_threshold": 1.5,
          "innner_cohesion_threshold": 1.5,
          "min_height": 1.5,
          "max_height": 6.0,
          "block_distance": 2.0,
          "block_weight": 0.85
        }
      },

      "cyn_hao:group_land_movement": {
        "minecraft:environment_sensor": {
          "triggers": [
            {
              "event": "cyn_hao:event_water_movement",
              "target": "self",
              "filters": {
                "test": "in_water",
                "value": true
              }
            }
          ]
        },

        "minecraft:movement.basic": {},
        "minecraft:navigation.generic": { // Allows the mob to go through water
          "is_amphibious": false,
          "can_path_over_water": true,
          "can_swim": true,
          "can_walk": true,
          "can_breach": false,
          "can_sink": false
        },
        "minecraft:behavior.move_to_water": {
          "search_range": 16,
          "search_height": 10,
          "search_count": 10,
          "goal_radius": 0.5,
          "priority": 0
        },
        "minecraft:behavior.panic": {
          "force": true,
          "ignore_mob_damage": false,
          "prefer_water": true,
          "priority": 1,
          "speed_multiplier": 1.0
        }
      }
    },

    

    "components": {
      "minecraft:is_hidden_when_invisible": {
      },
      "minecraft:experience_reward": {
        "on_death": "query.last_hit_by_player ? Math.Random(1,3) : 0"
      },
      "minecraft:type_family": {
        "family": [ "cyn_hao:seahorse", "cyn_hao:seahorse_small", "tropicalfish", "fish" ]
      },
      "minecraft:collision_box": {
        "width": 0.4,
        "height": 0.9
      },
      "minecraft:health": {
        "value": 3,
        "max": 3
      },
      "minecraft:hurt_on_condition": {
        "damage_conditions": [
          {
            "filters": {
              "test": "in_lava",
              "subject": "self",
              "operator": "==",
              "value": true
            },
            "cause": "lava",
            "damage_per_tick": 4
          }
        ]
      },
      "minecraft:loot": {
        "table": "loot_tables/cynosia/horses/entities/cyn_sea_small.json"
      },
      "minecraft:breathable": {
        "total_supply": 15,
        "suffocate_time": 0,
        "breathes_air": false,
        "breathes_water": true
      },
      "minecraft:movement": {
        "value": 0.12
      },
      "minecraft:physics": {
      },
      "minecraft:pushable": {
        "is_pushable": true,
        "is_pushable_by_piston": true
      },
      "minecraft:despawn": {
        "despawn_from_distance": {
          "min_distance": 64,
          "max_distance": 128
        }
      },
      "minecraft:nameable": {
      },
      "minecraft:conditional_bandwidth_optimization": {
      },

      "minecraft:leashable": {
        "can_be_stolen": false,
        "hard_distance": 6,
        "max_distance": 10,
        "soft_distance": 4
      },

      "minecraft:behavior.tempt": {
        "priority": 2,
        "speed_multiplier": 1.2,
        "items": [
          "kelp"
        ]
      },
      "minecraft:behavior.breed": {
        "priority": 1,
        "speed_multiplier": 1.0
      },
      "minecraft:breedable": {
        "require_tame": false,
        "breeds_with": {
          "mate_type": "cyn_hao:seahorse_small",
          "baby_type": "cyn_hao:seahorse_small"
        },
        "breed_items": [
          "kelp"
        ]
      },
      "minecraft:healable": {
        "items": [
          {
            "item": "kelp",
            "heal_amount": 1
          }
        ]
      }
    },

    "events": {
      "minecraft:entity_spawned": {
        "sequence": [
          {
            "add": {
              "component_groups": [ 
                "cyn_hao:group_water_movement"
              ]
            }
          },
          
          // Color Properties
          // Randomly set since this entity comes from breeding,
          // in which it inherits it's parents colors anyway
          
          // Base Coats
          {
            "set_property": {
              "cyn_hao:base_id": "math.random_integer(0, 7)"
            }
          },
          {
            "randomize": [
              {
                "weight": 1,
                "add": {
                  "component_groups": [
                    "cyn_hao:group_scale_0.4"
                  ]
                }
              },
              {
                "weight": 1,
                "add": {
                  "component_groups": [
                    "cyn_hao:group_scale_0.5"
                  ]
                }
              },
              {
                "weight": 1,
                "add": {
                  "component_groups": [
                    "cyn_hao:group_scale_0.6"
                  ]
                }
              },
              {
                "weight": 1,
                "add": {
                  "component_groups": [
                    "cyn_hao:group_scale_0.7"
                  ]
                }
              },
              {
                "weight": 1,
                "add": {
                  "component_groups": [
                    "cyn_hao:group_scale_0.75"
                  ]
                }
              },
              {
                "weight": 1,
                "add": {
                  "component_groups": [
                    "cyn_hao:group_scale_0.8"
                  ]
                }
              },
              {
                "weight": 1,
                "add": {
                  "component_groups": [
                    "cyn_hao:group_scale_0.9"
                  ]
                }
              },
              {
                "weight": 1,
                "add": {
                  "component_groups": [
                    "cyn_hao:group_scale_1.0"
                  ]
                }
              },
              {
                "weight": 1,
                "add": {
                  "component_groups": [
                    "cyn_hao:group_scale_1.1"
                  ]
                }
              },
              {
                "weight": 1,
                "add": {
                  "component_groups": [
                    "cyn_hao:group_scale_1.2"
                  ]
                }
              },
              {
                "weight": 1,
                "add": {
                  "component_groups": [
                    "cyn_hao:group_scale_1.3"
                  ]
                }
              }
            ]
          }
        ]
      },

      "minecraft:entity_born": {
        "sequence": [
          {
            "add": {
              "component_groups": [ 
                "cyn_hao:group_horse_baby",
                "cyn_hao:group_water_movement"
              ]
            }
          },
          
          // Color Properties
          // Randomly set since this entity comes from breeding,
          // in which it inherits it's parents colors anyway
          
          // Base Coats
          {
            "set_property": {
              "cyn_hao:base_id": "math.random_integer(0, 7)"
            }
          },
          {
            "randomize": [
              {
                "weight": 1,
                "add": {
                  "component_groups": [
                    "cyn_hao:group_scale_0.4"
                  ]
                }
              },
              {
                "weight": 1,
                "add": {
                  "component_groups": [
                    "cyn_hao:group_scale_0.5"
                  ]
                }
              },
              {
                "weight": 1,
                "add": {
                  "component_groups": [
                    "cyn_hao:group_scale_0.6"
                  ]
                }
              },
              {
                "weight": 1,
                "add": {
                  "component_groups": [
                    "cyn_hao:group_scale_0.7"
                  ]
                }
              },
              {
                "weight": 1,
                "add": {
                  "component_groups": [
                    "cyn_hao:group_scale_0.75"
                  ]
                }
              },
              {
                "weight": 1,
                "add": {
                  "component_groups": [
                    "cyn_hao:group_scale_0.8"
                  ]
                }
              },
              {
                "weight": 1,
                "add": {
                  "component_groups": [
                    "cyn_hao:group_scale_0.9"
                  ]
                }
              },
              {
                "weight": 1,
                "add": {
                  "component_groups": [
                    "cyn_hao:group_scale_1.0"
                  ]
                }
              },
              {
                "weight": 1,
                "add": {
                  "component_groups": [
                    "cyn_hao:group_scale_1.1"
                  ]
                }
              },
              {
                "weight": 1,
                "add": {
                  "component_groups": [
                    "cyn_hao:group_scale_1.2"
                  ]
                }
              },
              {
                "weight": 1,
                "add": {
                  "component_groups": [
                    "cyn_hao:group_scale_1.3"
                  ]
                }
              }
            ]
          }
        ]
      },

      "cyn_hao:ageable_grow_up": {
        "remove": {
          "component_groups": [
            "cyn_hao:group_horse_baby"
          ]
        }
      },


      "cyn_hao:event_water_movement": {
        "remove": {
          "component_groups": [
            "cyn_hao:group_land_movement"
          ]
        },
        "add": {
          "component_groups": [
            "cyn_hao:group_water_movement"
          ]
        }
      },

      "cyn_hao:event_land_movement": {
        "remove": {
          "component_groups": [
            "cyn_hao:group_water_movement"
          ]
        },
        "add": {
          "component_groups": [
            "cyn_hao:group_land_movement"
          ]
        }
      }
    }
  }
}
