{
  "format_version": "1.10.0",
  "minecraft:client_entity": {
    "description": {
      "identifier": "minecraft:goat",
      "materials": { "default": "goat" },
      "textures": {
        "default_0": "textures/entity/goat/goat_0",
        "default_1": "textures/entity/goat/goat_1",
        "default_2": "textures/entity/goat/goat_2",
        "default_3": "textures/entity/goat/goat_3",
        "default_4": "textures/entity/goat/goat_4",

        "default_0_face": "textures/entity/goat/goat_0_face",
        "default_1_face": "textures/entity/goat/goat_1_face",
        "default_2_face": "textures/entity/goat/goat_2_face",
        "default_3_face": "textures/entity/goat/goat_3_face",
        "default_4_face": "textures/entity/goat/goat_4_face"
      },
      "geometry": {
        "default": "geometry.crl.goat",
        "face": "geometry.crl.goat.face"
      },
      "spawn_egg": {
        "texture": "spawn_egg_goat"
      },
      "scripts": {
        "initialize": [
          "v.body_scale = 1.05;",
          "variable.eye_rot.max_diff = 30;",
          "variable.vertical_adjustment_weight = 3.0;",

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

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

          "variable.time_not_in_water = 0;",
          "v.previous_health = query.health;",
          "v.last_hurt_time = 1000;"
        ],
        "pre_animation": [
          "variable.tcos_right_side = (Math.cos(query.modified_distance_moved * 38.17) * query.modified_move_speed / variable.gliding_speed_value) * 57.3;",
          "variable.tcos_left_side = -variable.tcos_right_side;",
          "variable.attack_head_rot =  Math.sin(variable.attack_time * 180.0) * -37.3;",
          "variable.ram_head_rot = Math.sin(variable.should_bow_head * 90.0) * 37.3;",

          "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": [
          "idle",
          "body_scale",
          "look_at_target",
          "vertical_adjustment",
          "walk",

          { "attack": "variable.has_target && variable.attack_time >= 0.0" },
          "ram_attack",
          "goat_idle",

          "control_eye_movement",
          "control_eyebrow_movement"
        ]
      },
      "animations": {
        "idle": "animation.crl.common.idle_body",
        "walk": "animation.crl.four_legs.walk",
        "look_at_target": "animation.crl.four_legs.look_at_target",
        "vertical_adjustment": "animation.crl.common.vertical_adjustment",
        "body_scale": "animation.crl.four_legs.scale",

        "attack": "animation.crl.goat.attack",
        "ram_attack": "animation.crl.goat.ram_attack",
        "goat_idle": "animation.crl.goat.idle",

        "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"
      },
      "render_controllers": ["controller.render.crl.goat","controller.render.crl.goat.face"]
    }
  }
}
