{
  "format_version": "1.10.0",
  "minecraft:client_entity": {
    "description": {
      "identifier": "cyn_hao:pegasus",
      "materials": {
        "alphatest": "entity_alphatest",
        "alphablend": "entity_alphablend",
        "armor": "entity_alphatest_change_color"
      },

      "render_controllers": [
        "controller.render.cyn_hao.horse_carpet",
        // separate render controllers for carpets and armor,
        // since armor needs to use the entity_change_color material
        // for dyeing of leather armor
        "controller.render.cyn_hao.horse_armor",
        "controller.render.cyn_hao.unicorn_body"
      ],

      "textures": {
        // none texture
        "none": "textures/entity/horse2/armor/horse_armor_none",

        // base coat colors
        "base_0": "textures/cynosia/horses/entity/pegasus/base_0",
        "base_1": "textures/cynosia/horses/entity/pegasus/base_1",
        "base_2": "textures/cynosia/horses/entity/pegasus/base_2",

        // armor textures
        "armor_none": "textures/entity/horse2/armor/horse_armor_none",
        "armor_leather": "textures/cynosia/horses/entity/equipment/armor_leather",
        "armor_iron": "textures/cynosia/horses/entity/equipment/armor_iron",
        "armor_gold": "textures/cynosia/horses/entity/equipment/armor_gold",
        "armor_diamond": "textures/cynosia/horses/entity/equipment/armor_diamond",

        // carpet textures
        "carpet_none": "textures/entity/horse2/armor/horse_armor_none", 
        "carpet_white": "textures/cynosia/horses/entity/equipment/carpet_white", 
        "carpet_orange": "textures/cynosia/horses/entity/equipment/carpet_orange", 
        "carpet_magenta": "textures/cynosia/horses/entity/equipment/carpet_mag", 
        "carpet_light_blue": "textures/cynosia/horses/entity/equipment/carpet_Lblue", 
        "carpet_yellow": "textures/cynosia/horses/entity/equipment/carpet_yellow", 
        "carpet_lime": "textures/cynosia/horses/entity/equipment/carpet_lime", 
        "carpet_pink": "textures/cynosia/horses/entity/equipment/carpet_pink", 
        "carpet_gray": "textures/cynosia/horses/entity/equipment/carpet_gray", 
        "carpet_light_gray": "textures/cynosia/horses/entity/equipment/carpet_Lgray", 
        "carpet_cyan": "textures/cynosia/horses/entity/equipment/carpet_cyan", 
        "carpet_purple": "textures/cynosia/horses/entity/equipment/carpet_purple", 
        "carpet_blue": "textures/cynosia/horses/entity/equipment/carpet_blue", 
        "carpet_brown": "textures/cynosia/horses/entity/equipment/carpet_brown",
        "carpet_green": "textures/cynosia/horses/entity/equipment/carpet_green", 
        "carpet_red": "textures/cynosia/horses/entity/equipment/carpet_red", 
        "carpet_black": "textures/cynosia/horses/entity/equipment/carpet_black",
        "carpet_moss": "textures/cynosia/horses/entity/equipment/carpet_moss"

      },

      "particle_effects": {
        "special_breed": "cyn_hao:particle_fairy_special_breed"
      },

      "geometry": {
        "default": "geometry.cyn_hao.pegasus"
      },

      "sound_effects": {
        "flap": "mob.pegasus.flap"
      },

      "animations": {
        "look_at_target": "animation.cyn_horse.look_at_target",
        "random_scale": "animation.cyn_horse.random_scale",
        "baby_transform": "animation.cyn_pegasus.baby_transform",
        "baby_born": "animation.cyn_pegasus.baby_born",

        "wings_base": "animation.cyn_pegasus.wings_base",

        "bucking": "animation.cyn_pegasus.bucking",

        "idle_none": "animation.cyn_horse.idle_none",
        "idle_tail": "animation.cyn_pegasus.idle_tail",
        "idle_tail2": "animation.cyn_pegasus.idle_tail2",
        "idle_head": "animation.cyn_pegasus.idle_head",
        "idle_rear": "animation.cyn_pegasus.idle_rear",

        "roll_dirt": "animation.cyn_pegasus.roll_dirt",
        "sit_down": "animation.cyn_pegasus.sit_down",

        "stand_up": "animation.cyn_pegasus.stand_up",

        "sleep_stand": "animation.cyn_pegasus.sleep_stand",
        "sleep_sit": "animation.cyn_pegasus.sleep_sit",
        "sleep_lay": "animation.cyn_pegasus.sleep_lay",
        "sleep_lay_wake": "animation.cyn_pegasus.sleep_lay_wake",

        // // rear loop for when player tries equipping
        // // a wild horse
        // "rear_entry": "animation.cyn_pegasus.rear_entry",
        // "rear_loop": "animation.cyn_pegasus.rear_loop",
        // "rear_exit": "animation.cyn_pegasus.rear_exit",

        "walk": "animation.cyn_pegasus.walk",
        "run": "animation.cyn_pegasus.run",
        "jump": "animation.cyn_pegasus.jump",
        "swim": "animation.cyn_pegasus.swim",
        "fly": "animation.cyn_pegasus.fly",

        "special_breed_controller": "controller.animation.cyn_hao.special_breed_particle",

        "idle_controller": "controller.animation.cyn_hao.horse.idle",
        "move_controller": "controller.animation.cyn_hao.horse.move",
        "movement_controller": "controller.animation.cyn_hao.horse.movement_flyer"
      },
      
      "scripts": {
        "initialize": [
          "variable.idle_roll = 0;",
          "variable.babyGroundOffset = 3.0;",
          "variable.babyHeadSize = 1.2;",
          "variable.babyLegWidth = 1.28;",
          "variable.babyLegHeight = 0.9;"
          // height and density moved to behavior pack,
          // as these values change on world load
          // since the entities are being re-initialized
        ],
        "pre_animation": [
          // this whole mess of a variable is taken from vanilla horse, so we can use the same "look at target" logic vanilla horses use
          "variable.head_x_rot = query.target_x_rotation + (query.modified_move_speed > 0.2 ? (math.cos(query.modified_distance_moved * 11.46) * 11.46 * query.modified_move_speed + query.modified_move_speed * 11.46) : 0.0);",
          
          // easing formulas since I couldn't get math.lerp to work
          // multiplied by 16 since query.model_scale returns scale * 16...? I guess?
          // used in baby_transform animations, but defined as variables here
          // since we use these specific values 12 times
          // no need to run the query and do the math 12 times each frame!

          // -------------------------
          // -------------------------
          // -------------------------
          // MAKE SURE YOU UPDATE THE FORMULAS IF YOU CHANGE ANY VALUES!!!
          // -------------------------
          // -------------------------
          // -------------------------

          // formula to ease from 1.2 to 1.0, based on a scale from 0.5 to 1.0
          // y = 0.6x + 6
          // x: 0.5 -> y: 1.2
          // x: 1.0 -> y: 1.0
          "variable.babyHeadSize = ((-0.4 * (query.model_scale * 16.0)) + 1.4);",

          // formula to ease from 3.0 to 0.0, based on a scale from 0.5 to 1.0
          // y = 0.6x + 6
          // x: 0.5 -> y: 3.0
          // x: 1.0 -> y: 0.0
          "variable.babyGroundOffset = ((-6.0 * (query.model_scale * 16.0)) + 6.0);",
          
          // formula to ease from 0.9 to 1.0, based on a scale from 0.5 to 1.0
          // y = 0.2x + 0.8
          // x: 0.5 -> y: 0.9
          // x: 1.0 -> y: 1.0
          "variable.babyLegWidth = ((0.2 * (query.model_scale * 16.0)) + 0.8);",

          // formula to ease from 1.28 to 1.0, based on a scale from 0.5 to 1.0
          // y = -0.56x + 1.56
          // x: 0.5 -> y: 1.28
          // x: 1.0 -> y: 1.0
          "variable.babyLegHeight = ((-0.56 * (query.model_scale * 16.0)) + 1.56);"

        ],
        "animate": [
          "random_scale",
          "special_breed_controller",
          { "baby_born": "query.property('cyn_hao:just_born')" },
          { "baby_transform": "!query.property('cyn_hao:just_born') && query.is_baby" }, 
          { "movement_controller": "!query.property('cyn_hao:just_born')" }
        ]
      },
     
      "spawn_egg": {
        "texture": "cyn_hao.cyn_pegasus_egg"
      }
    }
  }
}