{
  "format_version": "1.10.0",
  "minecraft:client_entity": {
    "description": {
      "identifier": "minecraft:piglin_brute",
      "materials": {
        "default": "entity_alphatest",
        "multi": "entity_multitexture_alpha_test",
        "masked": "villager_v2_masked"
      },
      "textures": {
        "quiver": "textures/entity/skeleton/quiver",

        "body": "textures/entity/piglin/body",
        "head": "textures/entity/piglin/brute/head",
        "face": "textures/entity/piglin/brute/face",

        "pants": "textures/entity/piglin/brute/pants",
        "top": "textures/entity/piglin/brute/top"
      },
      "geometry": {
        // The geometry with item bones needs to have the name default. Do not ask me why :(
        "default": "geometry.crl.humanoid.base",
        "head": "geometry.crl.piglin.head",
        "face": "geometry.crl.piglin.face",

        "quiver": "geometry.crl.humanoid.quiver"
      },
      "spawn_egg": {
        "texture": "spawn_egg_piglin_brute"
      },
      "scripts": {
        "initialize": [
          "v.body_scale = 1.05;",
          "variable.eye_rot.max_diff = 30;",
          "variable.vertical_adjustment_weight = 3.0;",

          "v.distance_moved_weight = 2.0;",
          "v.modified_move_speed_weight = 1.25;",

          "variable.time_not_in_water = 0;",
          "v.previous_health = query.health;",
          "v.last_hurt_time = 1000;",

          "variable.random_pants = Math.random_integer(0,1000);",
          "variable.random_tops = Math.random_integer(0,1000);",
          "variable.random_hair = Math.random_integer(0,1000);",
          "variable.random_head = Math.random_integer(0,1000);",
          "variable.random_face_item = Math.random_integer(0,1000);",
          "variable.random_headwear = Math.random_integer(0,1000);",
          "variable.random_top_mask = 1;",
          "variable.random_pants_mask = 1;",

          "variable.visibility_headwear = Math.random_integer(0,10);"
        ],
        "pre_animation": [
          "variable.tcos0 = (Math.cos(query.modified_distance_moved * 38.17) * query.modified_move_speed / variable.gliding_speed_value) * 57.3;",
          "variable.attack = Math.sin((1.0 - (1.0 - variable.attack_time) * (1.0 - variable.attack_time)) * 180.0) * 57.3;",
          "variable.attack2 = Math.sin(variable.attack_time * 180.0) * 57.3;",
          "variable.z_bob = Math.cos(query.life_time * 103.13244) * 2.865 + 2.865;",
          "variable.x_bob = Math.sin(query.life_time * 76.776372) * 2.865;",

          "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": [
          { "admire": "query.is_admiring" },
          { "humanoid_big_head": "query.is_baby" },
          { "celebrate_hunt": "query.is_celebrating" },
          { "celebrate_hunt_special": "query.is_celebrating_special" },

          "piglin_move",
          "bob",
          "look_at_target_controller",
          "piglin_attack_controller",
          "riding_controller",

          "zombie_vertical_adjustment",

          "control_eye_movement",
          "control_eyebrow_movement",

          "vertical_adjustment",
          "body_scale",
          "idle"
        ]
      },
      "animations": {
        "piglin_move": "animation.crl.piglin.move",
        "bob": "animation.humanoid.bob",
        "humanoid_big_head": "animation.humanoid.big_head",
        "admire": "animation.crl.piglin.admire",
        "celebrate_hunt": "animation.crl.piglin.celebrate_hunt",
        "celebrate_hunt_special": "animation.crl.piglin.celebrate_hunt_special",

        "look_at_target_controller": "controller.animation.humanoid.look_at_target",
        "look_at_target_gliding": "animation.humanoid.look_at_target.gliding",
        "look_at_target_swimming": "animation.humanoid.look_at_target.swimming",

        "piglin_attack_controller": "controller.animation.crl.piglin.attack",
        "crossbow_hold": "animation.crl.piglin.crossbow.hold",
        "crossbow_charge": "animation.crl.piglin.crossbow.charge",
        "melee_attack": "animation.crl.piglin.sword.attack",
        "hand_attack": "animation.crl.piglin.hand.attack",

        "riding_controller": "controller.animation.humanoid.riding",
        "riding.arms": "animation.humanoid.riding.arms",
        "riding.legs": "animation.humanoid.riding.legs",

        "control_eye_movement": "controller.animation.crl.eye_movement",
        "control_eyebrow_movement": "controller.animation.crl.eyebrow_movement",

        "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",

        "walk_with_arms": "animation.crl.two_legs.walk_with_arms",
        "walk": "animation.crl.two_legs.walk",
        "look_at_target_default": "animation.crl.two_legs.look_at_target",
        "swimming": "animation.crl.zombie.swimming",

        "vertical_adjustment": "animation.crl.two_legs.vertical_adjustment",
        "body_scale": "animation.crl.two_legs.scale",
        "idle": "animation.crl.two_legs.idle",

        "zombie_vertical_adjustment": "animation.crl.zombie.vertical_adjustment"
      },
      "render_controllers": [
        "controller.render.crl.piglin_brute.pants",
        "controller.render.crl.piglin_brute.tops",
        "controller.render.crl.piglin_brute.body",
        "controller.render.crl.piglin_brute.head",
        "controller.render.crl.piglin_brute.head.face",
        "controller.render.crl.humanoid.quiver"
      ],
      "enable_attachables": true
    }
  }
}
