{
  "format_version": "1.10.0",
  "minecraft:client_entity": {
    "description": {
      "identifier": "minecraft:armadillo",
      "materials": {
        "default": "armadillo"
      },
      "geometry": {
        "default": "geometry.crl.armadillo"
      },
      "textures": {
        "brown": "textures/entity/armadillo/brown",
        "black": "textures/entity/armadillo/black",
        "white": "textures/entity/armadillo/white"
      },
      "render_controllers": ["controller.render.crl.armadillo"],
      "scripts": {
        "initialize": [
          "variable.random_variant = Math.random_integer(0,50);",

          "variable.eye_rot.max_diff = 55;",

          "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 = 7.0;"
        ],
        "pre_animation": [
          "variable.x_head_rotation = math.clamp(query.target_x_rotation, -32.5, 32.5);",
          "variable.y_head_rotation = math.clamp(query.target_y_rotation, -22.5, 25);",
          "variable.is_rolled_up = query.property('minecraft:armadillo_state') != 'unrolled';",
          "variable.rolled_up_time = variable.is_rolled_up ? ((variable.rolled_up_time ?? 0.0) + query.delta_time) : 0.0;",
          "variable.is_peeking = query.property('minecraft:armadillo_state') == 'rolled_up_peeking';",
          "variable.is_unrolling = query.property('minecraft:armadillo_state') == 'rolled_up_unrolling';",
          "variable.unrolling_time = variable.is_unrolling ? ((variable.unrolling_time ?? 0.0) + query.delta_time) : 0.0;",
          "variable.use_rolled_up_model = variable.rolled_up_time >= 0.2083 && (variable.unrolling_time == 0.0 || variable.unrolling_time <= 1.25 );",
          "variable.walking = query.modified_move_speed > 0.01 && !variable.is_rolled_up;",
          "variable.walk_anim_time_update = query.anim_time + math.min(3.0, math.lerp(2.0, 5.0, query.modified_move_speed)) * query.delta_time;",

          "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": [
          "look_at_target_controller",
          "walk_controller",
          "idle",
          "vertical_adjustment",
          "roll_up_controller"
        ],
        "should_update_effects_offscreen": "1.0"
      },
      "animations": {
        "look_at_target_controller": "controller.animation.crl.armadillo.look_at_target",
        "roll_up": "animation.crl.armadillo.roll_up",
        "rolled_up": "animation.crl.armadillo.rolled_up",
        "peek": "animation.crl.armadillo.peek",
        "unroll": "animation.crl.armadillo.unroll",
        "unroll_fast": "animation.crl.armadillo.unroll_fast",
        "roll_up_controller": "controller.animation.crl.armadillo.roll_up",
        "walk": "animation.crl.armadillo.walk",
        "walk_controller": "controller.animation.crl.armadillo.walk",

        "idle": "animation.crl.common.idle_body",
        "look_at_target": "animation.crl.four_legs.look_at_target",
        "vertical_adjustment": "animation.crl.four_legs.vertical_adjustment"
      },
      "sound_effects": {
        "roll": "mob.armadillo.roll",
        "land": "mob.armadillo.land",
        "peek": "mob.armadillo.peek",
        "unroll_start": "mob.armadillo.unroll_start",
        "unroll_finish": "mob.armadillo.unroll_finish"
      },
      "spawn_egg": {
        "texture": "spawn_egg_armadillo"
      }
    }
  }
}
