// Copyright (c) JaylyMC.
// Licensed under the GPL-3.0 License.

{
  "format_version": "1.10.0",
  "minecraft:client_entity": {
    "description": {
      "identifier": "entity:terminator",
      "spawn_egg": {
        "overlay_color": "#16abd8",
        "base_color": "#4f8cd3"
      },
      "materials": {
        "default": "entity_alphatest",
        "cape": "entity_alphatest",
        "animated": "player_animated"
      },
      "textures": {
        "steve": "textures/entity/terminator/steve_default",
        "alex": "textures/entity/terminator/alex_default",
        "steve_xmas": "textures/entity/terminator/steve_xmas",
        "alex_xmas": "textures/entity/terminator/alex_xmas",
        "custom": "textures/entity/steve",
        "customSlim": "textures/entity/alex",
        "cape_default": "textures/entity/cape_invisible",
        "cape": "textures/entity/cape_custom"
      },
      "geometry": {
        "default": "geometry.terminator",
        "slim": "geometry.terminatorSlim",
        "cape": "geometry.cape"
      },
      "scripts": {
        "scalex": "variable.entity_scale",
        "scaley": "variable.entity_scale",
        "scalez": "variable.entity_scale",
        "initialize": ["variable.hand_bob = 0.0;"],
        "pre_animation": [
          "variable.charge_amount = math.clamp((query.main_hand_item_max_duration - (query.main_hand_item_use_duration - query.frame_alpha + 1.0)) / 10.0, 0.0, 1.0f);",
          "variable.crossbow_charge = query.get_animation_frame;",
          "variable.entity_scale = 0.975;",
          "variable.item_use_normalized = query.main_hand_item_use_duration / query.main_hand_item_max_duration;",
          "variable.terminator_variant = q.variant;",
          "variable.attack_body_rot_y = Math.sin(360*Math.sqrt(variable.attack_time)) * 5.0;",
          "variable.tcos0 = (math.cos(q.modified_distance_moved * 38.17) * q.modified_move_speed / variable.gliding_speed_value) * 57.3;",
          "variable.hand_bob = q.life_time < 0.01 ? 0.0 : variable.hand_bob + ((q.is_on_ground && q.is_alive ? math.clamp(math.sqrt(math.pow(q.position_delta(0), 2.0) + math.pow(q.position_delta(2), 2.0)), 0.0, 0.1) : 0.0) - variable.hand_bob) * 0.02;"
        ],
        "animate": [
          "cape",
          "look_at_target",
          "holding",
          "bob",
          "move.arms",
          "move.legs",
          "attack.positions",
          "attack.rotations",
          { "move.arms": "q.ground_speed > 0.0" },
          { "move.legs": "q.ground_speed > 0.0" },
          { "riding.arms": "q.is_riding > 0.0" },
          { "riding.legs": "q.is_riding > 0.0" },
          {
            "sitting": "q.is_sitting > 0.0 || q.is_riding > 0.0 || q.sit_amount > 0.0"
          },
          { "attack.positions": "variable.attack_time > 0.0" },
          { "attack.rotations": "variable.attack_time > 0.0" },
          { "sneaking": "q.is_sneaking > 0.0" },
          { "sleeping": "q.is_sleeping > 0.0" },
          {
            "use_item_progress": "( variable.use_item_interval_progress > 0.0 ) || ( variable.use_item_startup_progress > 0.0 )"
          },
          { "swimming": "variable.swim_amount > 0.0 && q.is_in_water" },
          {
            "third_person_bow_equipped": "q.get_equipped_item_name == 'bow' && q.has_target"
          },
          {
            "bow_and_arrow": "q.get_equipped_item_name == 'bow' && q.has_target"
          },
          { "charging": "q.is_charging" },
          { "brandish_spear": "variable.is_brandishing_spear" },
          {
            "shield_block_main_hand": "q.get_equipped_item_name('main_hand') == 'shield' && q.get_equipped_item_name('off_hand') != 'shield' && q.property('terminator:is_using_shield')"
          },
          {
            "shield_block_off_hand": "q.get_equipped_item_name('off_hand') == 'shield' && q.property('terminator:is_using_shield')"
          },
          {
            "third_person_crossbow_equipped": "q.get_equipped_item_name('main_hand') == 'crossbow'"
          },
          {
            "crossbow_hold": "q.get_equipped_item_name('main_hand') == 'crossbow'"
          },
          {
            "crossbow_charge": "q.get_equipped_item_name('main_hand') == 'crossbow'"
          },
          {
            "crossbow_controller": "q.get_equipped_item_name('main_hand') == 'crossbow'"
          }
        ]
      },
      "animations": {
        "look_at_target": "animation.terminator.look_at_target",
        "holding": "animation.humanoid.holding",
        "bob": "animation.player.bob",
        "move.arms": "animation.player.move.arms",
        "move.legs": "animation.player.move.legs",
        "riding.arms": "animation.player.riding.arms",
        "riding.legs": "animation.player.riding.legs",
        "sitting": "animation.terminator.sitting",
        "attack.positions": "animation.player.attack.positions",
        "attack.rotations": "animation.player.attack.rotations",
        "sneaking": "animation.player.sneaking",
        "sleeping": "animation.player.sleeping",
        "use_item_progress": "animation.humanoid.use_item_progress",
        "swimming": "animation.player.swim",
        "swimming.legs": "animation.player.swim.legs",
        "third_person_bow_equipped": "animation.player.bow_equipped",
        "bow_and_arrow": "animation.humanoid.bow_and_arrow",
        "charging": "animation.humanoid.charging.v1.0",
        "brandish_spear": "animation.humanoid.brandish_spear",
        "cape": "animation.terminator.cape",
        "shield_block_main_hand": "animation.terminator.shield_block_main_hand",
        "shield_block_off_hand": "animation.terminator.shield_block_off_hand",
        "third_person_crossbow_equipped": "animation.player.crossbow_equipped",
        "crossbow_hold": "animation.pillager.crossbow.hold",
        "crossbow_charge": "animation.pillager.crossbow.charge",
        "crossbow_controller": "controller.animation.player.crossbow"
      },
      "render_controllers": [
        "controller.render.terminator",
        "controller.render.player.cape"
      ],
      "enable_attachables": true
    }
  }
}
