{
  "format_version": "1.10.0",
  "minecraft:client_entity": {
    "description": {
      "identifier": "minecraft:villager_v2",
      "materials": {
        "default": "villager_v2",
        "masked": "villager_v2_masked"
      },
      "textures": {
        // Base Textures - Vanilla Minecraft only has one such texture, rename these for resource packs desiring variety
        "male": "textures/entity/villager2/villager",
        "male1": "textures/entity/villager2/villager_1",
        "male2": "textures/entity/villager2/villager_2",
        "male_face": "textures/entity/villager2/villager_face",
        "male1_face": "textures/entity/villager2/villager_1_face",
        "male2_face": "textures/entity/villager2/villager_2_face",

        "female": "textures/entity/villager2/villager_f",
        "female1": "textures/entity/villager2/villager_f_1",
        "female2": "textures/entity/villager2/villager_f_2",
        "female_face": "textures/entity/villager2/villager_f_face",
        "female1_face": "textures/entity/villager2/villager_f_1_face",
        "female2_face": "textures/entity/villager2/villager_f_2_face",

        "hair_long_white": "textures/entity/villager2/hair/long_white",
        "hair_long_blonde": "textures/entity/villager2/hair/long_blonde",
        "hair_long_black": "textures/entity/villager2/hair/long_black",
        "hair_long_brown": "textures/entity/villager2/hair/long_brown",

        "hair_white": "textures/entity/villager2/hair/white",
        "hair_brown": "textures/entity/villager2/hair/brown",
        "hair_brown2": "textures/entity/villager2/hair/brown_2",
        "hair_black": "textures/entity/villager2/hair/black",
        "hair_black2": "textures/entity/villager2/hair/black_2",
        "hair_blonde": "textures/entity/villager2/hair/blonde",
        "hair_blonde2": "textures/entity/villager2/hair/blonde_2",
        "hair_blonde_bald": "textures/entity/villager2/hair/blonde_bald",

        // Biome Layer
        "desert": "textures/entity/villager2/biomes/biome_desert",
        "jungle": "textures/entity/villager2/biomes/biome_jungle",
        "plains": "textures/entity/villager2/biomes/biome_plains",
        "savanna": "textures/entity/villager2/biomes/biome_savanna",
        "snow": "textures/entity/villager2/biomes/biome_snow",
        "swamp": "textures/entity/villager2/biomes/biome_swamp",
        "taiga": "textures/entity/villager2/biomes/biome_taiga",

        // Profession Layer
        "armorer": "textures/entity/villager2/professions/armorer",
        "butcher": "textures/entity/villager2/professions/butcher",
        "cartographer": "textures/entity/villager2/professions/cartographer",
        "cleric": "textures/entity/villager2/professions/cleric",
        "farmer": "textures/entity/villager2/professions/farmer",
        "fisherman": "textures/entity/villager2/professions/fisherman",
        "fletcher": "textures/entity/villager2/professions/fletcher",
        "leatherworker": "textures/entity/villager2/professions/leatherworker",
        "librarian": "textures/entity/villager2/professions/librarian",
        "shepherd": "textures/entity/villager2/professions/shepherd",
        "tool_smith": "textures/entity/villager2/professions/toolsmith",
        "weapon_smith": "textures/entity/villager2/professions/weaponsmith",
        "stonemason": "textures/entity/villager2/professions/stonemason",
        "nitwit": "textures/entity/villager2/professions/nitwit",
        "unskilled": "textures/entity/villager2/professions/unskilled",

        // Levels Layer
        "level_stone": "textures/entity/villager2/levels/level_stone",
        "level_iron": "textures/entity/villager2/levels/level_iron",
        "level_gold": "textures/entity/villager2/levels/level_gold",
        "level_emerald": "textures/entity/villager2/levels/level_emerald",
        "level_diamond": "textures/entity/villager2/levels/level_diamond"
      },
      "geometry": {
        "default": "geometry.crl.villager_v2",
        "face": "geometry.crl.villager_v2.face"
      },
      "scripts": {
        "scale": "0.9375",
        "initialize": [
          "v.body_scale = 1.05;",
          "variable.eye_rot.max_diff = 30;",
          "variable.vertical_adjustment_weight = 3.0;",

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

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

          "variable.random_hair = Math.random_integer(0,50);",

          "v.is_male = (query.skin_id <= 2);",

          "variable.time_not_in_water = 0;",
          "v.previous_health = query.health;",
          "v.last_hurt_time = 1000;"
        ],
        "pre_animation": [
          "variable.num_professions = 15;",
          "variable.num_tiers = 3;",
          "variable.profession_index = (query.variant < variable.num_professions ? query.variant : 0);",
          "variable.level_index = query.trade_tier;",

          "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": [
          "general_control",
          "move_control",
          "raise_arms_control",
          "baby_control",

          "control_eye_movement",
          "control_eyebrow_movement"
        ]
      },
      "animations": {
        "general": "animation.crl.villager.general",
        "raise_arms": "animation.crl.villager.raise_arms",
        "baby_transform": "animation.crl.villager.baby_transform",
        "get_in_bed": "animation.crl.villager.get_in_bed",
        "idle": "animation.crl.two_legs.idle",

        "walk": "animation.crl.two_legs.walk",
        "look_at_target": "animation.crl.two_legs.look_at_target",
        "vertical_adjustment": "animation.crl.two_legs.vertical_adjustment",
        "body_scale": "animation.crl.two_legs.scale",

        "general_control": "controller.animation.crl.villager_v2.general",
        "move_control": "controller.animation.crl.villager_v2.move",
        "raise_arms_control": "controller.animation.crl.villager_v2.raise_arms",
        "baby_control": "controller.animation.crl.villager_v2.baby",

        "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"
      },
      "render_controllers": [
        "controller.render.crl.villager_v2_base",
        "controller.render.crl.villager_v2_face",
        "controller.render.crl.villager_v2_hair",
        "controller.render.crl.villager_v2_masked",
        "controller.render.crl.villager_v2_level"
      ],
      "spawn_egg": {
        "texture": "spawn_egg",
        "texture_index": 14
      }
    }
  }
}
