{
  "format_version": "1.10.0",
  "minecraft:client_entity": {
    "description": {
      "identifier": "minecraft:camel",
      "materials": {
        "default": "camel"
      },
      "textures": {
        "saddle": "textures/entity/camel/saddle",
        "sand": "textures/entity/camel/sand",
        "sand_face": "textures/entity/camel/sand_face",

        "white": "textures/entity/camel/white",
        "white_face": "textures/entity/camel/white_face",

        "brown": "textures/entity/camel/brown",
        "brown_face": "textures/entity/camel/brown_face",

        "dark_brown": "textures/entity/camel/dark_brown",
        "dark_brown_face": "textures/entity/camel/dark_brown_face"
      },
      "geometry": {
        "default": "geometry.crl.camel",
        "saddle": "geometry.crl.camel.saddle",
        "face": "geometry.crl.camel.face"
      },
      "spawn_egg": {
        "texture": "spawn_egg_camel"
      },
      "scripts": {
        "initialize": [
          "v.time_in_air = 0;",

          "variable.random_variant = Math.random_integer(0,20);",

          "variable.eye_rot.max_diff = 40;",

          "variable.time_not_in_water = 0;",
          "v.previous_health = query.health;",
          "v.last_hurt_time = 1000;",

          "v.distance_moved_weight = 1;",
          "v.modified_move_speed_weight = 1.5;",

          "variable.vertical_adjustment_weight = 2.0;"
        ],
        "pre_animation": [
          "variable.time_in_air = (query.is_on_ground ? 0 : (variable.time_in_air + query.delta_time));",
          "variable.time_in_air = math.clamp(variable.time_in_air, 0, 100);",

          "variable.dash_cooldown = (!(variable.last_dash_cooldown ?? true) && query.has_dash_cooldown) ? 2.75 : ( variable.dash_cooldown ?? 0 );",
          "variable.dash_cooldown = math.max(0, variable.dash_cooldown-query.delta_time);",
          "variable.dash_cooldown_progress = (2.75 - variable.dash_cooldown) / 2.75;",
          "variable.last_dash_cooldown = query.has_dash_cooldown;",
          "variable.moving = query.modified_move_speed > 0.05 || query.vertical_speed > 0.05;",
          "variable.xTargetRot = math.clamp(query.target_x_rotation, -30, 30);",
          "variable.xHeadRot = variable.dash_cooldown_progress > 0 ? math.clamp(variable.xTargetRot + (45 * (1 - variable.dash_cooldown_progress)), -25, 70) : variable.xTargetRot;",
          "variable.yHeadRot = math.clamp(query.target_y_rotation, -30, 30);",

          "variable.body_rot.x = query.body_x_rotation;",
          "variable.body_rot.y = query.body_y_rotation;",

          "variable.eye_rot.x = (query.target_x_rotation - this);",
          "variable.eye_rot.y = (query.target_y_rotation - this);",
          "variable.eye_rot_clamp.x = math.clamp(variable.eye_rot.x, -variable.eye_rot.max_diff, variable.eye_rot.max_diff);",
          "variable.eye_rot_clamp.y = math.clamp(variable.eye_rot.y, -variable.eye_rot.max_diff, variable.eye_rot.max_diff);",

          "variable.eye_ratio.x = (variable.eye_rot_clamp.x / variable.eye_rot.max_diff);",
          "variable.eye_ratio.y = (variable.eye_rot_clamp.y / variable.eye_rot.max_diff);",

          "variable.time_not_in_water = (query.is_in_water ? 0 : (variable.time_not_in_water + query.delta_time));",
          "variable.time_not_in_water = math.clamp(variable.time_not_in_water, 0, 100);",

          "v.last_hurt_time = (query.health < v.previous_health ? 0 :  Math.clamp(v.last_hurt_time + query.delta_time, 0,1000) );",

          "v.previous_health=query.health;"
        ],
        "animate": [
          "control_general",
          "control_vertical_adjustment",
          "camel_idle",

          "scale",
          "idle",
          { "look_at_target_no_head": "!query.is_sitting" },

          "control_eye_movement",
          "control_eyebrow_movement"
        ]
      },
      "animations": {
        "moving": "animation.crl.camel.walk",
        "sit_down": "animation.crl.camel.sit_down",
        "sitting": "animation.crl.camel.sit",
        "stand_up": "animation.crl.camel.stand_up",
        "dashing": "animation.crl.camel.dash",
        "dashing_sound": "animation.camel.dash_sound",
        "camel_idle": "animation.crl.camel.idle",

        "control_general": "controller.animation.crl.camel.general",
        "control_vertical_adjustment": "controller.animation.crl.camel.vertical_adjustment",

        "look_at_target_no_head": "animation.crl.four_legs.look_at_target.no_head",
        "scale": "animation.crl.four_legs.scale",
        "vertical_adjustment": "animation.crl.four_legs.vertical_adjustment",
        "idle": "animation.crl.common.idle_body",

        "blink": "animation.crl.face.blink",
        "blink_long": "animation.crl.face.blink_long",
        "move_eyes": "animation.crl.face.sideways.move_eyes",
        "move_eyebrows": "animation.crl.face.move_eyebrows",
        "scared_eyebrows": "animation.crl.face.sideways.scared_eyebrows",
        "sleep_eyes": "animation.crl.face.sleep_eyes",
        "angry_eyebrows": "animation.crl.face.sideways.angry_eyebrows",

        "control_eye_movement": "controller.animation.crl.eye_movement",
        "control_eyebrow_movement": "controller.animation.crl.eyebrow_movement"
      },
      "sound_effects": {
        "sit_down": "mob.camel.sit",
        "stand_up": "mob.camel.stand",
        "dashing": "mob.camel.dash"
      },
      "render_controllers": [
        "controller.render.crl.camel",
        "controller.render.crl.camel.saddle",
        "controller.render.crl.camel.face"
      ]
    }
  }
}
