{
  "format_version": "1.10.0",
  "minecraft:client_entity": {
    "description": {
      "identifier": "minecraft:mooshroom",
      "min_engine_version": "1.8.0",
      "materials": {
        "default": "cow",
        "tail": "entity_alphatest",
        "face": "entity_alphatest"
      },
      "textures": {
        "default": "textures/entity/cow/mooshroom",
        "brown": "textures/entity/cow/brown_mooshroom",
        "face": "textures/entity/cow/mooshroom_face",
        "face_brown": "textures/entity/cow/brown_mooshroom_face"
      },
      "geometry": {
        "default": "geometry.crl.mooshroom",
        "face": "geometry.crl.mooshroom.face"
      },
      "animations": {
        "idle": "animation.crl.common.idle_body",
        "walk": "animation.crl.four_legs.walk",
        "cow_walk": "animation.crl.cow.walk",
        "look_at_target": "animation.crl.four_legs.look_at_target",
        "baby_transform": "animation.crl.cow.baby_transform",
        "scale": "animation.crl.four_legs.scale",

        "blink": "animation.crl.face.blink",
        "blink_long": "animation.crl.face.blink_long",
        "eye_movement": "controller.animation.crl.eye_movement",
        "eyebrow_movement": "controller.animation.crl.eyebrow_movement",
        "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"
      },
      "scripts": {
        "animate": [
          "scale",
          "idle",
          "walk",
          "cow_walk",
          "look_at_target",

          "eye_movement",
          "eyebrow_movement",
          { "baby_transform": "query.is_baby" }
        ],
        "initialize": [
          "variable.eye_rot.max_diff = 30;",

          "variable.time_not_in_water = 0;",
          "v.previous_health = query.health;",
          "v.last_hurt_time = 1000;"
        ],
        "pre_animation": [
          "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.mooshroom", "controller.render.crl.mooshroom.face"],
      "spawn_egg": {
        "texture": "spawn_egg",
        "texture_index": 5
      }
    }
  }
}
