{
  "format_version": "1.10.0",
  "minecraft:client_entity": {
    "description": {
      "identifier": "minecraft:fox",
      "materials": { "default": "fox", "face": "entity_alphatest" },
      "textures": {
        "red": "textures/entity/fox/red",
        "red_face": "textures/entity/fox/red_face",
        "arctic": "textures/entity/fox/arctic_fox",
        "arctic_face": "textures/entity/fox/arctic_face",

        "kabul": "textures/entity/fox/kabul",
        "gold": "textures/entity/fox/gold",
        "silver": "textures/entity/fox/silver",
        "full_black": "textures/entity/fox/full_black",
        "dark_red": "textures/entity/fox/dark_red",
        "brown": "textures/entity/fox/brown",
        "black": "textures/entity/fox/black",

        "kabul_face": "textures/entity/fox/kabul_face",
        "gold_face": "textures/entity/fox/gold_face",
        "silver_face": "textures/entity/fox/silver_face",
        "full_black_face": "textures/entity/fox/full_black_face",
        "dark_red_face": "textures/entity/fox/dark_red_face",
        "brown_face": "textures/entity/fox/brown_face",
        "black_face": "textures/entity/fox/black_face"
      },
      "geometry": {
        "default": "geometry.crl.fox",
        "face": "geometry.crl.fox.face"
      },
      "animations": {
        "idle": "animation.crl.common.idle_body",
        "walk": "animation.crl.four_legs.walk",
        "look_at_target_plus_body": "animation.crl.four_legs.look_at_target",
        "vertical_adjustment": "animation.crl.common.vertical_adjustment",
        "body_scale": "animation.crl.four_legs.scale",

        "baby_transform": "animation.crl.fox.baby_transform",
        "crouch": "animation.crl.fox.crouch",
        "sleep": "animation.crl.fox.sleep",
        "sit": "animation.crl.fox.sit",
        "wiggle": "animation.crl.fox.wiggle",
        "stuck": "animation.crl.fox.stuck",
        "fox_idle": "animation.crl.fox.idle",

        "control_move": "controller.animation.crl.fox.move",

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

        "control_eye_movement": "controller.animation.crl.eye_movement",
        "control_eyebrow_movement": "controller.animation.crl.eyebrow_movement"
      },
      "scripts": {
        "animate": [
          "idle",
          "body_scale",
          "vertical_adjustment",
          { "fox_idle": "!query.is_sleeping" },
          { "baby_transform": "query.is_baby" },
          "control_move",
          "control_eye_movement",
          "control_eyebrow_movement"
        ],
        "initialize": [
          "variable.random_variant = Math.random_integer(0,20);",

          "v.body_scale = 1.05;",
          "variable.eye_rot.max_diff = 30;",
          "variable.vertical_adjustment_weight = 5.0;",

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

          "variable.time_not_in_water = 0;",
          "v.previous_health = query.health;",
          "v.last_hurt_time = 1000;"
        ],
        "pre_animation": [
          "v.speed = query.modified_move_speed;",

          "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;"
        ]
      },
      "render_controllers": [
        "controller.render.crl.fox",
        "controller.render.crl.fox.face"
      ],
      "spawn_egg": {
        "texture": "spawn_egg",
        "texture_index": 55
      }
    }
  }
}
