// scripts/main.ts
import { ItemStack as ItemStack8, EquipmentSlot as EquipmentSlot4, world as world8, EntityComponentTypes as EntityComponentTypes4, system as system4 } from "@minecraft/server";

// scripts/umbrella.ts
import {
  world
} from "@minecraft/server";
var Umbrella = class {
  static UmbrellaName = "hoh_mw2:vamanas_umbrella";
  static Initialize() {
    world.afterEvents.itemStartUse.subscribe((arg) => {
      const stack = arg.itemStack;
      if (stack && stack.typeId === this.UmbrellaName) {
        this.UmbrellaUsed(arg.source);
      }
    });
    world.afterEvents.itemStopUse.subscribe((arg) => {
      const stack = arg.itemStack;
      if (stack && stack.typeId === this.UmbrellaName) {
        this.UmbrellaStopUsed(arg.source);
      }
    });
  }
  static UmbrellaUsed(player) {
    player.addEffect("slow_falling", 6e3, { showParticles: false, amplifier: 1 });
    player.addEffect("jump_boost", 6e3, { showParticles: false, amplifier: 2 });
  }
  static UmbrellaStopUsed(player) {
    player.removeEffect("slow_falling");
    player.removeEffect("jump_boost");
  }
};

// scripts/book.ts
import {
  world as world2,
  EntityProjectileComponent
} from "@minecraft/server";
var Book = class {
  static BookName = "hoh_mw2:book_of_thoth";
  static Initialize() {
    world2.afterEvents.itemStartUse.subscribe((arg) => {
      const stack = arg.itemStack;
      if (stack && stack.typeId === this.BookName) {
        this.BookUsed(arg.source);
      }
    });
    world2.afterEvents.itemReleaseUse.subscribe((arg) => {
      const stack = arg.itemStack;
      if (stack && stack.typeId === this.BookName) {
        this.BookRelease(arg.source);
      }
    });
    world2.afterEvents.entitySpawn.subscribe((arg) => {
      this.MoonImpact(arg);
    });
  }
  static MoonImpact = (arg) => {
    if (arg.entity.typeId == "hoh_mw2:thoth_moon_shockwave") {
      const nearbyEntities = arg.entity.dimension.getEntities({
        location: arg.entity.location,
        families: ["mob"],
        maxDistance: 3,
        excludeFamilies: ["player"]
      });
      nearbyEntities.forEach((entity) => {
        entity.applyDamage(6);
        entity.addEffect("levitation", 40, { amplifier: 2, showParticles: false });
      });
      arg.entity.triggerEvent("hoh_mw2:time_to_despawn");
    }
  };
  static BookUsed(player) {
    if (player.isSneaking) {
      const CurrentBookMode = player.getDynamicProperty("hoh_current_book_mode");
      if (CurrentBookMode == 1 || CurrentBookMode == void 0) {
        player.setDynamicProperty("hoh_current_book_mode", 2);
      } else if (CurrentBookMode == 2) {
        player.setDynamicProperty("hoh_current_book_mode", 3);
      } else if (CurrentBookMode == 3) {
        player.setDynamicProperty("hoh_current_book_mode", 1);
      }
      player.setDynamicProperty("hoh_sneak_mode", 1);
    }
  }
  static BookRelease(player) {
    const CurrentBookMode = player.getDynamicProperty("hoh_current_book_mode");
    if (player.getDynamicProperty("hoh_sneak_mode")) {
      player.setDynamicProperty("hoh_sneak_mode", 0);
      return;
    }
    if (CurrentBookMode == 1 || CurrentBookMode == void 0) {
      const direction = player.getViewDirection();
      const velocitymultiplier = 2;
      const calculatedvelocity = { x: direction.x * velocitymultiplier, y: direction.y * velocitymultiplier, z: direction.z * velocitymultiplier };
      const moon = player.dimension.spawnEntity("hoh_mw2:thoth_moon", player.getHeadLocation());
      const projectileComp = moon.getComponent(EntityProjectileComponent.componentId);
      projectileComp.gravity = -0.1;
      projectileComp?.shoot(calculatedvelocity);
    } else if (CurrentBookMode == 2) {
      const nearbyEntities = player.dimension.getEntities({
        location: player.location,
        maxDistance: 15,
        families: ["mob"],
        excludeTypes: ["minecraft:ender_dragon", "minecraft:wither", "minecraft:warden", "minecraft:elder_guardian"],
        excludeFamilies: ["player"]
      });
      nearbyEntities.forEach((entity) => {
        entity.dimension.spawnParticle("hoh_mw2:sleep_zzz", entity.location);
        entity.addEffect("slowness", 120, { amplifier: 5, showParticles: false });
      });
    } else if (CurrentBookMode == 3) {
      player.addEffect("regeneration", 120, { amplifier: 1, showParticles: true });
    }
  }
};

// node_modules/@minecraft/math/lib/general/clamp.js
function clampNumber(val, min, max) {
  return Math.min(Math.max(val, min), max);
}

// node_modules/@minecraft/math/lib/vector3/coreHelpers.js
var Vector3Utils = class _Vector3Utils {
  /**
   * equals
   *
   * Check the equality of two vectors
   */
  static equals(v1, v2) {
    return v1.x === v2.x && v1.y === v2.y && v1.z === v2.z;
  }
  /**
   * add
   *
   * Add two vectors to produce a new vector
   */
  static add(v1, v2) {
    return { x: v1.x + v2.x, y: v1.y + v2.y, z: v1.z + v2.z };
  }
  /**
   * subtract
   *
   * Subtract two vectors to produce a new vector (v1-v2)
   */
  static subtract(v1, v2) {
    return { x: v1.x - v2.x, y: v1.y - v2.y, z: v1.z - v2.z };
  }
  /** scale
   *
   * Multiple all entries in a vector by a single scalar value producing a new vector
   */
  static scale(v1, scale) {
    return { x: v1.x * scale, y: v1.y * scale, z: v1.z * scale };
  }
  /**
   * dot
   *
   * Calculate the dot product of two vectors
   */
  static dot(a, b) {
    return a.x * b.x + a.y * b.y + a.z * b.z;
  }
  /**
   * cross
   *
   * Calculate the cross product of two vectors. Returns a new vector.
   */
  static cross(a, b) {
    return {
      x: a.y * b.z - a.z * b.y,
      y: a.z * b.x - a.x * b.z,
      z: a.x * b.y - a.y * b.x
    };
  }
  /**
   * magnitude
   *
   * The magnitude of a vector
   */
  static magnitude(v) {
    return Math.sqrt(v.x ** 2 + v.y ** 2 + v.z ** 2);
  }
  /**
   * distance
   *
   * Calculate the distance between two vectors
   */
  static distance(a, b) {
    return _Vector3Utils.magnitude(_Vector3Utils.subtract(a, b));
  }
  /**
   * normalize
   *
   * Takes a vector 3 and normalizes it to a unit vector
   */
  static normalize(v) {
    const mag = _Vector3Utils.magnitude(v);
    return { x: v.x / mag, y: v.y / mag, z: v.z / mag };
  }
  /**
   * floor
   *
   * Floor the components of a vector to produce a new vector
   */
  static floor(v) {
    return { x: Math.floor(v.x), y: Math.floor(v.y), z: Math.floor(v.z) };
  }
  /**
   * toString
   *
   * Create a string representation of a vector3
   */
  static toString(v, options) {
    const decimals = options?.decimals ?? 2;
    const str = [v.x.toFixed(decimals), v.y.toFixed(decimals), v.z.toFixed(decimals)];
    return str.join(options?.delimiter ?? ", ");
  }
  /**
   * clamp
   *
   * Clamps the components of a vector to limits to produce a new vector
   */
  static clamp(v, limits) {
    return {
      x: clampNumber(v.x, limits?.min?.x ?? Number.MIN_SAFE_INTEGER, limits?.max?.x ?? Number.MAX_SAFE_INTEGER),
      y: clampNumber(v.y, limits?.min?.y ?? Number.MIN_SAFE_INTEGER, limits?.max?.y ?? Number.MAX_SAFE_INTEGER),
      z: clampNumber(v.z, limits?.min?.z ?? Number.MIN_SAFE_INTEGER, limits?.max?.z ?? Number.MAX_SAFE_INTEGER)
    };
  }
  /**
   * lerp
   *
   * Constructs a new vector using linear interpolation on each component from two vectors.
   */
  static lerp(a, b, t) {
    return {
      x: a.x + (b.x - a.x) * t,
      y: a.y + (b.y - a.y) * t,
      z: a.z + (b.z - a.z) * t
    };
  }
  /**
   * slerp
   *
   * Constructs a new vector using spherical linear interpolation on each component from two vectors.
   */
  static slerp(a, b, t) {
    const theta = Math.acos(_Vector3Utils.dot(a, b));
    const sinTheta = Math.sin(theta);
    const ta = Math.sin((1 - t) * theta) / sinTheta;
    const tb = Math.sin(t * theta) / sinTheta;
    return _Vector3Utils.add(_Vector3Utils.scale(a, ta), _Vector3Utils.scale(b, tb));
  }
};
var VECTOR3_UP = { x: 0, y: 1, z: 0 };

// scripts/bow.ts
import {
  world as world3,
  EntityProjectileComponent as EntityProjectileComponent2
} from "@minecraft/server";
var Bow = class {
  static BowName = "hoh_mw2:cupids_bow";
  static Initialize() {
    world3.afterEvents.projectileHitEntity.subscribe((arg) => {
      this.EntityHitbyCupid(arg);
    });
    world3.afterEvents.entitySpawn.subscribe((arg) => {
      this.BlockHitbyCupid(arg);
    });
    world3.afterEvents.itemReleaseUse.subscribe((arg) => {
      const stack = arg.itemStack;
      if (stack && stack.typeId === this.BowName) {
        this.BowUsed(arg.source);
      }
    });
  }
  static BlockHitbyCupid = (arg) => {
    if (arg.entity.typeId == "hoh_mw2:cupid_arrow_shockwave") {
      const nearbyEntities = arg.entity.dimension.getEntities({
        location: arg.entity.location,
        maxDistance: 3,
        families: ["mob"],
        excludeFamilies: ["player"],
        closest: 1
      });
      nearbyEntities.forEach((entity) => {
        entity.applyDamage(6);
        entity.addTag("hoh_hit_by_arrow");
        entity.dimension.spawnParticle("hoh_mw2:heart_hearts", entity.location);
        arg.entity.triggerEvent("hoh_mw2:time_to_despawn");
        this.PullEntitiesTogether(entity);
      });
    }
  };
  static EntityHitbyCupid = (arg) => {
    if (arg.projectile.typeId == "hoh_mw2:arrow") {
      const hitbyArrowEntity = arg.getEntityHit()?.entity;
      if (hitbyArrowEntity && hitbyArrowEntity.typeId !== "minecraft:player") {
        hitbyArrowEntity.addTag("hoh_hit_by_arrow");
        hitbyArrowEntity.dimension.spawnParticle("hoh_mw2:heart_hearts", hitbyArrowEntity.location);
        this.PullEntitiesTogether(hitbyArrowEntity);
      }
    }
  };
  static PullEntitiesTogether = (arg) => {
    const nearbyEntities = arg.dimension.getEntities({
      location: arg.location,
      families: ["mob"],
      maxDistance: 20,
      tags: ["hoh_hit_by_arrow"],
      closest: 2
    });
    if (nearbyEntities && nearbyEntities.length == 2) {
      const firstEntityHit = nearbyEntities[0];
      const secondEntityHit = nearbyEntities[1];
      if (firstEntityHit.location && secondEntityHit.location) {
        const firstToSecondDir = Vector3Utils.normalize(Vector3Utils.subtract(secondEntityHit.location, firstEntityHit.location));
        const secondToFirstDir = Vector3Utils.normalize(Vector3Utils.subtract(firstEntityHit.location, secondEntityHit.location));
        firstEntityHit.applyImpulse(Vector3Utils.scale(firstToSecondDir, 2));
        secondEntityHit.applyImpulse(Vector3Utils.scale(secondToFirstDir, 2));
        const midpoint = {
          x: (firstEntityHit.location.x + secondEntityHit.location.x) / 2,
          y: (firstEntityHit.location.y + secondEntityHit.location.y) / 2,
          z: (firstEntityHit.location.z + secondEntityHit.location.z) / 2
        };
        firstEntityHit.dimension.spawnParticle("hoh_mw2:heart_poof", midpoint);
        firstEntityHit.teleport(midpoint);
        secondEntityHit.teleport(midpoint);
        firstEntityHit.applyDamage(6);
        firstEntityHit.applyDamage(6);
        firstEntityHit.removeTag("hoh_hit_by_arrow");
        secondEntityHit.removeTag("hoh_hit_by_arrow");
      }
    }
  };
  static BowUsed(player) {
    const direction = player.getViewDirection();
    const velocitymultiplier = 3;
    const calculatedvelocity = { x: direction.x * velocitymultiplier, y: direction.y * velocitymultiplier, z: direction.z * velocitymultiplier };
    const rotation = player.getRotation();
    const arrow = player.dimension.spawnEntity("hoh_mw2:arrow", player.getHeadLocation());
    if (rotation.y >= -180 && rotation.y <= -170) {
      arrow.setRotation({ x: 0, y: -180 });
      arrow.setProperty("hoh_mw2:y", 1);
    }
    if (rotation.y >= 170 && rotation.y <= 180) {
      arrow.setRotation({ x: 0, y: 180 });
    }
    if (rotation.y >= -10 && rotation.y <= 10) {
      arrow.setRotation({ x: 0, y: 0 });
    }
    const projectileComp = arrow.getComponent(EntityProjectileComponent2.componentId);
    projectileComp?.shoot(calculatedvelocity);
    if (rotation.y >= 80 && rotation.y <= 100) {
      arrow.setRotation({ x: 0, y: 90 });
      arrow.setProperty("hoh_mw2:y", 70);
    }
    if (rotation.y >= -100 && rotation.y <= -80) {
      arrow.setRotation({ x: 0, y: -90 });
      arrow.setProperty("hoh_mw2:y", -45);
    }
  }
};

// scripts/fishhook.ts
import {
  world as world4,
  EntityDamageCause as EntityDamageCause3,
  EntityProjectileComponent as EntityProjectileComponent3
} from "@minecraft/server";
var Fishhook = class {
  static FishhookName = "hoh_mw2:fishhook";
  static Initialize() {
    world4.afterEvents.projectileHitEntity.subscribe((arg) => {
      this.EntityHitbyHook(arg);
    });
    world4.afterEvents.entitySpawn.subscribe((arg) => {
      this.BlockHitbyHook(arg);
    });
    world4.afterEvents.itemReleaseUse.subscribe((arg) => {
      const stack = arg.itemStack;
      if (stack && stack.typeId === this.FishhookName) {
        this.FishhookUsed(arg.source);
      }
    });
  }
  static EntityHitbyHook = (arg) => {
    const Hook = arg.projectile;
    if (Hook.typeId == "hoh_mw2:fishhook_entity" && !Hook.hasTag("hoh_hook_landed")) {
      Hook.addTag("hoh_hook_landed");
      const hitbyHookEntity = arg.getEntityHit()?.entity;
      const playerHookEntity = arg.source;
      if (hitbyHookEntity && playerHookEntity) {
        this.PullEntityIntoPlayer(hitbyHookEntity, playerHookEntity);
      }
    }
  };
  static BlockHitbyHook = (arg) => {
    arg.entity.getComponent;
    if (arg.entity.typeId == "hoh_mw2:fishhook_shockwave") {
      const nearbyHook = arg.entity.dimension.getEntities({
        location: arg.entity.location,
        families: ["hook"],
        maxDistance: 5,
        closest: 1,
        excludeTags: ["hoh_hook_landed"]
      });
      nearbyHook.forEach((hooks) => {
        hooks.addTag("hoh_hook_landed");
        const HookProjectile = hooks.getComponent(EntityProjectileComponent3.componentId);
        const HookOwner = HookProjectile.owner;
        const nearbyEntities = arg.entity.dimension.getEntities({
          location: arg.entity.location,
          maxDistance: 3,
          families: ["mob"],
          closest: 1
        });
        nearbyEntities.forEach((entities) => {
          if (HookOwner) {
            this.PullEntityIntoPlayer(entities, HookOwner);
            entities.applyDamage(7, { cause: EntityDamageCause3.contact, damagingEntity: HookOwner });
          }
        });
      });
      arg.entity.triggerEvent("hoh_mw2:time_to_despawn");
    }
  };
  static PullEntityIntoPlayer(arg, owner) {
    const hitbyHookEntity = arg;
    const playerHookEntity = owner;
    if (hitbyHookEntity && playerHookEntity) {
      const directionToPlayer = Vector3Utils.normalize(Vector3Utils.subtract(playerHookEntity.location, hitbyHookEntity.location));
      const distance = Vector3Utils.distance(hitbyHookEntity.location, playerHookEntity.location);
      hitbyHookEntity.applyImpulse(Vector3Utils.scale(directionToPlayer, distance - 1));
    }
  }
  static FishhookUsed(player) {
    const direction = player.getViewDirection();
    const velocitymultiplier = 2.5;
    const calculatedvelocity = { x: direction.x * velocitymultiplier, y: direction.y * velocitymultiplier, z: direction.z * velocitymultiplier };
    const Hook = player.dimension.spawnEntity("hoh_mw2:fishhook_entity", player.getHeadLocation());
    const projectileComp = Hook.getComponent(EntityProjectileComponent3.componentId);
    projectileComp.gravity = 0.1;
    projectileComp?.shoot(calculatedvelocity);
    projectileComp.owner = player;
  }
};

// scripts/scale.ts
import {
  ItemStack as ItemStack5,
  world as world5,
  system,
  EntityEquippableComponent as EntityEquippableComponent2,
  EntityComponentTypes as EntityComponentTypes2,
  EntityTypeFamilyComponent,
  EquipmentSlot as EquipmentSlot2,
  EntityDamageCause as EntityDamageCause4
} from "@minecraft/server";
var Scale = class {
  static ScaleName = "hoh_mw2:anubis_scale";
  static ScaleName2 = "hoh_mw2:anubis_scale_heavy";
  static ScaleName3 = "hoh_mw2:anubis_scale_light";
  static AimingPropKey = "hoh_is_scale_aiming";
  static CONE_ANGLE_DEGREES = 10;
  static Initialize() {
    world5.afterEvents.entityDie.subscribe((arg) => {
      if (arg.damageSource.damagingEntity != void 0 && arg.damageSource.damagingEntity.typeId == "minecraft:player") {
        let equipmentCompPlayer = arg.damageSource.damagingEntity?.getComponent(EntityComponentTypes2.Equippable);
        let itemStack = equipmentCompPlayer.getEquipment(EquipmentSlot2.Mainhand);
        if (itemStack?.typeId == this.ScaleName || itemStack?.typeId == this.ScaleName2 || itemStack?.typeId == this.ScaleName3) {
          const familyComponent = arg.deadEntity?.getComponent(EntityTypeFamilyComponent.componentId);
          if (familyComponent?.hasTypeFamily("monster")) {
            arg.deadEntity.dimension.spawnEntity("hoh_mw2:anubis_soul_evil", arg.deadEntity.location);
          } else {
            arg.deadEntity.dimension.spawnEntity("hoh_mw2:anubis_soul", arg.deadEntity.location);
          }
        } else
          return;
      }
    });
    world5.afterEvents.entityHurt.subscribe((arg) => {
      if (arg.hurtEntity.typeId === "minecraft:player" && arg.damageSource.damagingEntity?.typeId === "hoh_mw2:anubis_soul") {
        const CurrentSoulCount = arg.hurtEntity.getDynamicProperty("hoh_current_soul_count_good") || 0;
        const NewSoulCount = CurrentSoulCount + 1;
        arg.hurtEntity.setDynamicProperty("hoh_current_soul_count_good", NewSoulCount);
        let playerHurt = arg.hurtEntity;
        const combinedSoulCount = (playerHurt.getDynamicProperty("hoh_current_soul_count_evil") || 0) + (playerHurt.getDynamicProperty("hoh_current_soul_count_good") || 0);
        this.SoulCollected(playerHurt, combinedSoulCount);
      }
      if (arg.hurtEntity.typeId === "minecraft:player" && arg.damageSource.damagingEntity?.typeId === "hoh_mw2:anubis_soul_evil") {
        const CurrentSoulCount = arg.hurtEntity.getDynamicProperty("hoh_current_soul_count_evil") || 0;
        const NewSoulCount = CurrentSoulCount + 1;
        arg.hurtEntity.setDynamicProperty("hoh_current_soul_count_evil", NewSoulCount);
        let playerHurt = arg.hurtEntity;
        const combinedSoulCount = (playerHurt.getDynamicProperty("hoh_current_soul_count_evil") || 0) + (playerHurt.getDynamicProperty("hoh_current_soul_count_good") || 0);
        this.SoulCollected(playerHurt, combinedSoulCount);
      }
    });
    world5.afterEvents.itemReleaseUse.subscribe((arg) => {
      const stack = arg.itemStack;
      if (stack && stack.typeId === this.ScaleName) {
        arg.source.setDynamicProperty(this.AimingPropKey, false);
      }
    });
    world5.afterEvents.itemStopUse.subscribe((arg) => {
      const stack = arg.itemStack;
      if (stack && stack.typeId === this.ScaleName) {
        arg.source.setDynamicProperty(this.AimingPropKey, false);
      }
    });
    world5.afterEvents.itemStartUse.subscribe((arg) => {
      const stack = arg.itemStack;
      const timeCharge = arg.useDuration;
      if (stack && stack.typeId === this.ScaleName) {
        this.ScaleToggle(arg.source);
        arg.source.setDynamicProperty(this.AimingPropKey, true);
      }
      if (stack && stack.typeId === this.ScaleName2) {
        this.ScaleUsedHeavy(arg.source);
      } else if (stack && stack.typeId === this.ScaleName3) {
        this.ScaleUsedLight(arg.source);
      }
    });
    system.runInterval(() => {
      world5.getAllPlayers().forEach((player) => {
        const anubisAimProp = player.getDynamicProperty(this.AimingPropKey);
        if (anubisAimProp) {
          let currentChargeAmount = player.getDynamicProperty("hoh_laser_charge_amount") ?? 0;
          const newChargeAmount = currentChargeAmount + 10;
          player.setDynamicProperty("hoh_laser_charge_amount", newChargeAmount);
          const direction = Vector3Utils.normalize(player.getViewDirection());
          const coneAngleRadians = this.degreesToRadians(this.CONE_ANGLE_DEGREES);
          const nearbyEntities = player.dimension.getEntities({
            location: player.location,
            maxDistance: 18,
            families: ["mob"],
            excludeFamilies: ["player"]
          });
          nearbyEntities.forEach((entity) => {
            const entityDirection = this.getDirectionToEntity(player.getHeadLocation(), entity.location);
            const angle = Math.acos(this.dotProduct(direction, entityDirection));
            if (angle <= coneAngleRadians) {
              if (newChargeAmount <= 80 && newChargeAmount > 0) {
                entity.applyDamage(4, { cause: EntityDamageCause4.contact, damagingEntity: player });
              }
              if (newChargeAmount <= 200 && newChargeAmount > 80) {
                entity.applyDamage(5, { cause: EntityDamageCause4.contact, damagingEntity: player });
              }
              if (newChargeAmount >= 200) {
                entity.applyDamage(7, { cause: EntityDamageCause4.contact, damagingEntity: player });
              }
            }
            const res = player.dimension.getBlockFromRay(
              player.getHeadLocation(),
              player.getViewDirection(),
              {
                includeLiquidBlocks: true,
                includePassableBlocks: true,
                maxDistance: 30
              }
            );
            if (res === void 0) {
              return;
            }
            const ReticleOffset = Vector3Utils.add(res.block.location, { x: 0.5, y: 0, z: 0.5 });
            player.dimension.spawnParticle("hoh_mw2:AnubisTargetingParticle", Vector3Utils.add(ReticleOffset, VECTOR3_UP));
          });
        } else {
          player.setDynamicProperty("hoh_laser_charge_amount", 0);
        }
      });
    }, 5);
  }
  static ScaleToggle(player) {
    const CurrentSoulCountGood = player.getDynamicProperty("hoh_current_soul_count_good");
    const CurrentSoulCountEvil = player.getDynamicProperty("hoh_current_soul_count_evil");
    const combinedSoulCount = (player.getDynamicProperty("hoh_current_soul_count_evil") || 0) + (player.getDynamicProperty("hoh_current_soul_count_good") || 0);
    if (player.isSneaking && combinedSoulCount >= 3 && (CurrentSoulCountGood > CurrentSoulCountEvil || CurrentSoulCountEvil == void 0)) {
      const NewItem = new ItemStack5("hoh_mw2:anubis_scale_heavy");
      const Equippable = player.getComponent(EntityEquippableComponent2.componentId);
      Equippable.setEquipment(EquipmentSlot2.Mainhand, NewItem);
      player.setDynamicProperty("hoh_current_soul_count_good", 0);
      player.setDynamicProperty("hoh_current_soul_count_evil", 0);
    }
    if (player.isSneaking && combinedSoulCount >= 3 && (CurrentSoulCountEvil > CurrentSoulCountGood || CurrentSoulCountEvil == void 0)) {
      const NewItem = new ItemStack5("hoh_mw2:anubis_scale_light");
      const Equippable = player.getComponent(EntityEquippableComponent2.componentId);
      Equippable.setEquipment(EquipmentSlot2.Mainhand, NewItem);
      player.setDynamicProperty("hoh_current_soul_count_good", 0);
      player.setDynamicProperty("hoh_current_soul_count_evil", 0);
    } else {
      return;
    }
  }
  static ScaleUsedHeavy(player) {
    player.dimension.spawnEntity("minecraft:allay", player.location);
    player.dimension.spawnEntity("minecraft:allay", player.location);
    player.dimension.spawnEntity("minecraft:allay", player.location);
    const OldScale = new ItemStack5("hoh_mw2:anubis_scale");
    const Equippable = player.getComponent(EntityEquippableComponent2.componentId);
    Equippable.setEquipment(EquipmentSlot2.Mainhand, OldScale);
  }
  static ScaleUsedLight(player) {
    const nearbyEntities = player.dimension.getEntities({
      location: player.location,
      maxDistance: 30,
      families: ["monster"],
      excludeTypes: ["minecraft:ender_dragon", "minecraft:wither", "minecraft:warden", "minecraft:elder_guardian"],
      excludeFamilies: ["player"]
    });
    nearbyEntities.forEach((entity) => {
      entity.dimension.spawnParticle("hoh_mw2:fire", entity.location);
      entity.applyDamage(4, { cause: EntityDamageCause4.fire, damagingEntity: player });
      entity.applyKnockback(0, 0, 0, 2);
    });
    const OldScale = new ItemStack5("hoh_mw2:anubis_scale");
    const Equippable = player.getComponent(EntityEquippableComponent2.componentId);
    Equippable.setEquipment(EquipmentSlot2.Mainhand, OldScale);
  }
  static getDirectionToEntity(playerPos, entityPos) {
    const direction = { x: entityPos.x - playerPos.x, y: entityPos.y - playerPos.y, z: entityPos.z - playerPos.z };
    return Vector3Utils.normalize(direction);
  }
  static dotProduct(v1, v2) {
    return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
  }
  static degreesToRadians(degrees) {
    return degrees * (Math.PI / 180);
  }
  static SoulCollected(player, soulCount) {
    const CurrentSouls = {
      translate: "hoh_mw2:scale.soul",
      with: [soulCount.toString()]
    };
    const MaxSouls = {
      translate: "hoh_mw2:scale.soul_ready",
      with: [soulCount.toString()]
    };
    if (soulCount < 3) {
      player.onScreenDisplay.setActionBar(CurrentSouls);
    } else
      player.onScreenDisplay.setActionBar(MaxSouls);
  }
};

// scripts/aegis.ts
import {
  ItemStack as ItemStack6,
  world as world6,
  system as system2
} from "@minecraft/server";
var Aegis = class {
  static AegisName = "hoh_mw2:aegis_shield";
  static CONE_ANGLE_DEGREES = 40;
  static AimingPropKey = "hoh_is_aegis_aiming";
  static Initialize() {
    world6.afterEvents.itemReleaseUse.subscribe((arg) => {
      const stack = arg.itemStack;
      if (stack && stack.typeId === this.AegisName) {
        arg.source.setDynamicProperty(this.AimingPropKey, false);
      }
    });
    world6.afterEvents.itemStopUse.subscribe((arg) => {
      const stack = arg.itemStack;
      if (stack && stack.typeId === this.AegisName) {
        arg.source.setDynamicProperty(this.AimingPropKey, false);
      }
    });
    world6.afterEvents.itemStartUse.subscribe((arg) => {
      const stack = arg.itemStack;
      const timeCharge = arg.useDuration;
      if (stack && stack.typeId === this.AegisName) {
        arg.source.setDynamicProperty(this.AimingPropKey, true);
      }
    });
    system2.runInterval(() => {
      world6.getAllPlayers().forEach((player) => {
        const aegisAimProp = player.getDynamicProperty(this.AimingPropKey);
        if (aegisAimProp) {
          const direction = Vector3Utils.normalize(player.getViewDirection());
          const coneAngleRadians = this.degreesToRadians(this.CONE_ANGLE_DEGREES);
          const nearbyEntities = player.dimension.getEntities({
            location: player.location,
            maxDistance: 15,
            families: ["mob"],
            excludeTypes: ["minecraft:ender_dragon", "minecraft:wither", "minecraft:warden", "minecraft:elder_guardian"],
            excludeFamilies: ["player"]
          });
          nearbyEntities.forEach((entity) => {
            const entityDirection = this.getDirectionToEntity(player.getHeadLocation(), entity.location);
            const angle = Math.acos(this.dotProduct(direction, entityDirection));
            if (angle <= coneAngleRadians) {
              let StoneCount = entity.getDynamicProperty("hoh_mw2:stone");
              if (StoneCount == void 0) {
                entity.setDynamicProperty("hoh_mw2:stone", 0);
                StoneCount = 0;
              }
              StoneCount += 1;
              entity.setDynamicProperty("hoh_mw2:stone", StoneCount);
              if (StoneCount > 0) {
                entity.dimension.spawnParticle("hoh_mw2:petrification_smoke", entity.location);
              }
              if (StoneCount >= 10) {
                entity.dimension.spawnParticle("hoh_mw2:petrification_rocks", entity.location);
              }
              if (StoneCount == 5) {
                entity.addEffect("slowness", 1, { amplifier: 2, showParticles: false });
              }
              if (StoneCount == 10) {
                entity.addEffect("slowness", 1, { amplifier: 5, showParticles: false });
              }
              if (StoneCount == 15) {
                const stoneItem = new ItemStack6("cobblestone", 1);
                entity.dimension.spawnItem(stoneItem, Vector3Utils.add(entity.location, VECTOR3_UP));
                entity.dimension.spawnItem(stoneItem, Vector3Utils.add(entity.location, VECTOR3_UP));
                entity.dimension.spawnItem(stoneItem, Vector3Utils.add(entity.location, VECTOR3_UP));
                entity.remove();
              }
            }
          });
        }
      });
    }, 5);
  }
  static getDirectionToEntity(playerPos, entityPos) {
    const direction = { x: entityPos.x - playerPos.x, y: entityPos.y - playerPos.y, z: entityPos.z - playerPos.z };
    return Vector3Utils.normalize(direction);
  }
  static dotProduct(v1, v2) {
    return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
  }
  static degreesToRadians(degrees) {
    return degrees * (Math.PI / 180);
  }
};

// scripts/staff.ts
import {
  world as world7,
  system as system3,
  EntityDamageCause as EntityDamageCause5,
  EntityComponentTypes as EntityComponentTypes3,
  EquipmentSlot as EquipmentSlot3
} from "@minecraft/server";
var Staff = class _Staff {
  static StaffName = "hoh_mw2:wukong_staff";
  static CONE_ANGLE_DEGREES = 40;
  static AimingPropKey = "hoh_is_wukong_aiming";
  static HoldingPropKey = "hoh_is_wukong_holding";
  static Initialize() {
    world7.afterEvents.itemStartUse.subscribe((arg) => {
      const stack = arg.itemStack;
      if (stack && stack.typeId === this.StaffName) {
        if (arg.source.isSneaking) {
          arg.source.setDynamicProperty("hoh_sneak_mode", 1);
        } else {
          const CurrentStaffMode = arg.source.getDynamicProperty("hoh_current_staff_mode");
          if (CurrentStaffMode == 1 || CurrentStaffMode == void 0) {
            this.StaffAttack(arg);
          } else if (CurrentStaffMode == 2) {
            arg.source.setDynamicProperty("hoh_charged_staff", true);
          }
          arg.source.setDynamicProperty(this.HoldingPropKey, true);
        }
      }
    });
    world7.afterEvents.itemStopUse.subscribe((arg) => {
      const stack = arg.itemStack;
      if (stack && stack.typeId === this.StaffName) {
        arg.source.setDynamicProperty(this.HoldingPropKey, false);
        arg.source.setDynamicProperty("hoh_charged_staff", false);
      }
    });
    world7.afterEvents.itemReleaseUse.subscribe((arg) => {
      const stack = arg.itemStack;
      if (stack && stack.typeId === this.StaffName) {
        if (arg.source.getDynamicProperty("hoh_sneak_mode")) {
          arg.source.setDynamicProperty("hoh_sneak_mode", 0);
          this.StaffUsed(arg.source);
          return;
        }
        if (arg.source.getDynamicProperty("hoh_charged_staff")) {
          arg.source.setDynamicProperty("hoh_charged_staff", false);
          const direction = Vector3Utils.normalize(arg.source.getViewDirection());
          const coneAngleRadians = this.degreesToRadians(this.CONE_ANGLE_DEGREES);
          if (direction.y < -0.98 && arg.source.isOnGround) {
            const chargetime = arg.useDuration;
            if (chargetime <= 400 && chargetime > 390) {
              arg.source.applyKnockback(0, 0, 0, 1);
            }
            if (chargetime <= 389 && chargetime > 350) {
              arg.source.applyKnockback(0, 0, 0, 2);
            }
            if (chargetime <= 349) {
              arg.source.applyKnockback(0, 0, 0, 4);
            }
          }
          const nearbyEntities = arg.source.dimension.getEntities({
            location: arg.source.location,
            maxDistance: 7,
            families: ["mob"]
          });
          nearbyEntities.forEach((entity) => {
            if (entity === arg.source)
              return;
            const entityDirection = this.getDirectionToEntity(arg.source.location, entity.location);
            const angle = Math.acos(this.dotProduct(direction, entityDirection));
            const arcFactor = 1.5;
            const PushPower = { x: entityDirection.x * 5, y: arcFactor + entityDirection.y * 3, z: entityDirection.z * 5 };
            if (angle <= coneAngleRadians) {
              entity.applyDamage(1, { cause: EntityDamageCause5.contact, damagingEntity: arg.source });
              entity.applyImpulse(PushPower);
            }
          });
        }
      }
    });
  }
  static StaffAttack(arg) {
    const wukongAimProp = arg.source.getDynamicProperty(this.AimingPropKey);
    if (wukongAimProp == false || wukongAimProp == void 0) {
      arg.source.setDynamicProperty(this.AimingPropKey, true);
      system3.runTimeout(() => {
        arg.source.setDynamicProperty(this.AimingPropKey, false);
        const equippable = arg.source.getComponent(EntityComponentTypes3.Equippable);
        const inHand = equippable.getEquipmentSlot(EquipmentSlot3.Mainhand);
        const item = inHand.getItem();
        if (item == void 0 || item.typeId != this.StaffName) {
          return;
        }
        const direction = Vector3Utils.normalize(arg.source.getViewDirection());
        const coneAngleRadians = this.degreesToRadians(this.CONE_ANGLE_DEGREES);
        const nearbyEntities = arg.source.dimension.getEntities({
          location: arg.source.location,
          maxDistance: 7,
          families: ["mob"]
        });
        nearbyEntities.forEach((entity) => {
          if (entity === arg.source)
            return;
          const entityDirection = this.getDirectionToEntity(arg.source.location, entity.location);
          const angle = Math.acos(this.dotProduct(direction, entityDirection));
          if (angle <= coneAngleRadians) {
            entity.applyDamage(8, { cause: EntityDamageCause5.contact, damagingEntity: arg.source });
          }
        });
        const wukongHoldProp = arg.source.getDynamicProperty(this.HoldingPropKey);
        if (wukongHoldProp) {
          _Staff.StaffAttack(arg);
        }
      }, 6);
    }
  }
  static StaffUsed(player) {
    const CurrentStaffMode = player.getDynamicProperty("hoh_current_staff_mode");
    if (CurrentStaffMode == 1 || CurrentStaffMode == void 0) {
      player.setDynamicProperty("hoh_current_staff_mode", 2);
    } else if (CurrentStaffMode == 2) {
      player.setDynamicProperty("hoh_current_staff_mode", 1);
    }
  }
  static getDirectionToEntity(playerPos, entityPos) {
    const direction = { x: entityPos.x - playerPos.x, y: entityPos.y - playerPos.y, z: entityPos.z - playerPos.z };
    return Vector3Utils.normalize(direction);
  }
  static dotProduct(v1, v2) {
    return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
  }
  static degreesToRadians(degrees) {
    return degrees * (Math.PI / 180);
  }
};

// scripts/main.ts
import { ActionFormData } from "@minecraft/server-ui";
function PlayerSpawned(arg) {
  if (arg.player.hasTag("hoh_mw2:welcomed")) {
    const container = arg.player.getComponent(EntityComponentTypes4.Inventory).container;
    let hasBook = false;
    for (let i = 0; i < container.size; i++) {
      const itemStack = container.getItem(i);
      if (itemStack?.typeId === "hoh_mw2:crafting_recipe_book") {
        hasBook = true;
        break;
      }
    }
    if (!hasBook) {
      const newBook = new ItemStack8("hoh_mw2:crafting_recipe_book", 1);
      newBook.setLore(["\xA76From the Magic Weapons 2 Addon"]);
      arg.player.dimension.spawnItem(newBook, arg.player.location);
    }
  }
  if (!arg.player.hasTag("hoh_mw2:welcomed")) {
    const itemstack = new ItemStack8("hoh_mw2:crafting_recipe_book", 1);
    itemstack.setLore(["\xA76From the Magic Weapons 2 Addon"]);
    arg.player.dimension.spawnItem(itemstack, arg.player.location);
    arg.player.addTag("hoh_mw2:welcomed");
  }
}
function PlayerLeaves(arg) {
  arg.player.setDynamicProperty("hoh_current_book_mode", 1);
  arg.player.setDynamicProperty("hoh_current_staff_mode", 1);
}
var WeaponList = ["minecraft:bow", "minecraft:crossbow", "minecraft:trident", "hoh_mw2:wukong_staff", "hoh_mw2:vamanas_umbrella", "hoh_mw2:book_of_thoth", "hoh_mw2:aegis_shield", "hoh_mw2:anubis_scale", "hoh_mw2:anubis_scale_light", "hoh_mw2:anubis_scale_heavy", "hoh_mw2:cupids_bow", "hoh_mw2:fishhook"];
function containsString(array, searchString) {
  return array.includes(searchString);
}
var WeaponEquipMap = /* @__PURE__ */ new Map();
function WeaponChecker() {
  world8.getAllPlayers().forEach((Player9) => {
    let MainHandWeapon = WeaponEquipMap.get(Player9);
    if (!MainHandWeapon) {
      WeaponEquipMap.set(Player9, "");
    }
    const equippable = Player9.getComponent(EntityComponentTypes4.Equippable);
    if (equippable) {
      const CurrentMainHandSlot = equippable.getEquipmentSlot(EquipmentSlot4.Mainhand);
      const CurrentWeapon = CurrentMainHandSlot.getItem();
      const FoundWeapon = CurrentWeapon?.typeId;
      if (FoundWeapon && FoundWeapon != MainHandWeapon && containsString(WeaponList, FoundWeapon)) {
        WeaponEquipMap.set(Player9, FoundWeapon);
        Player9.setDynamicProperty("hoh_current_staff_mode", 1);
        Player9.setDynamicProperty("hoh_current_book_mode", 1);
      }
    }
  });
}
world8.afterEvents.playerSpawn.subscribe(PlayerSpawned);
world8.afterEvents.playerSpawn.subscribe(PlayerLeaves);
Umbrella.Initialize();
Book.Initialize();
Bow.Initialize();
Fishhook.Initialize();
Scale.Initialize();
Aegis.Initialize();
Staff.Initialize();
system4.runInterval(WeaponChecker, 5);
world8.afterEvents.itemUse.subscribe(ArmorFormDisplay);
function ArmorFormDisplay(arg) {
  if (arg.itemStack.typeId != "hoh_mw2:crafting_recipe_book") {
    return;
  }
  const BookOpenForm = createActionForm("hoh_mw2:book_open_title", "hoh_mw2:book_open_body", [
    { text: "item.hoh_mw2:aegis_shield", icon: "textures/HoH/mw2/items/aegis_shield" },
    { text: "item.hoh_mw2:anubis_scale", icon: "textures/HoH/mw2/items/anubis_scale" },
    { text: "item.hoh_mw2:book_of_thoth", icon: "textures/HoH/mw2/items/book_of_thoth" },
    { text: "item.hoh_mw2:cupids_bow", icon: "textures/HoH/mw2/items/cupids_bow" },
    { text: "item.hoh_mw2:fishhook", icon: "textures/HoH/mw2/items/fish_hook" },
    { text: "item.hoh_mw2:vamanas_umbrella", icon: "textures/HoH/mw2/items/vamanas_umbrella" },
    { text: "item.hoh_mw2:wukong_staff", icon: "textures/HoH/mw2/items/wukong_staff" }
  ]);
  const AegisForm = createActionForm("item.hoh_mw2:aegis_shield", "hoh_mw2:aegis_body", [
    { text: "item.hoh_mw2:recipe", icon: "textures/HoH/mw2/items/aegis_shield" },
    { text: "item.hoh_mw2:tips", icon: "textures/HoH/mw2/items/aegis_shield" }
  ]);
  const ScaleForm = createActionForm("item.hoh_mw2:anubis_scale", "hoh_mw2:scale_body", [
    { text: "item.hoh_mw2:recipe", icon: "textures/HoH/mw2/items/anubis_scale" },
    { text: "item.hoh_mw2:tips", icon: "textures/HoH/mw2/items/anubis_scale" }
  ]);
  const BookForm = createActionForm("item.hoh_mw2:book_of_thoth", "hoh_mw2:thoth_body", [
    { text: "item.hoh_mw2:recipe", icon: "textures/HoH/mw2/items/book_of_thoth" },
    { text: "item.hoh_mw2:tips", icon: "textures/HoH/mw2/items/book_of_thoth" }
  ]);
  const BowForm = createActionForm("item.hoh_mw2:cupids_bow", "hoh_mw2:cupid_body", [
    { text: "item.hoh_mw2:recipe", icon: "textures/HoH/mw2/items/cupids_bow" },
    { text: "item.hoh_mw2:tips", icon: "textures/HoH/mw2/items/cupids_bow" }
  ]);
  const FishhookForm = createActionForm("item.hoh_mw2:fishhook", "hoh_mw2:fishhook_body", [
    { text: "item.hoh_mw2:recipe", icon: "textures/HoH/mw2/items/fish_hook" },
    { text: "item.hoh_mw2:tips", icon: "textures/HoH/mw2/items/fish_hook" }
  ]);
  const UmbrellaForm = createActionForm("item.hoh_mw2:vamanas_umbrella", "hoh_mw2:umbrella_body", [
    { text: "item.hoh_mw2:recipe", icon: "textures/HoH/mw2/items/vamanas_umbrella" },
    { text: "item.hoh_mw2:tips", icon: "textures/HoH/mw2/items/vamanas_umbrella" }
  ]);
  const StaffForm = createActionForm("item.hoh_mw2:wukong_staff", "hoh_mw2:staff_body", [
    { text: "item.hoh_mw2:recipe", icon: "textures/HoH/mw2/items/wukong_staff" },
    { text: "item.hoh_mw2:tips", icon: "textures/HoH/mw2/items/wukong_staff" }
  ]);
  const recipeAegisForms = {
    Recipe: createActionForm("item.hoh_mw2:aegis_shield", "hoh_mw2:aegis_recipe", [
      { text: "hoh_mw2:exit" }
    ]),
    Tips: createActionForm("item.hoh_mw2:aegis_shield", "hoh_mw2:aegis_tip", [
      { text: "hoh_mw2:exit" }
    ])
  };
  const recipeScaleForms = {
    Recipe: createActionForm("item.hoh_mw2:anubis_scale", "hoh_mw2:scale_recipe", [
      { text: "hoh_mw2:exit" }
    ]),
    Tips: createActionForm("item.hoh_mw2:anubis_scale", "hoh_mw2:scale_tip", [
      { text: "hoh_mw2:exit" }
    ])
  };
  const recipeBookForms = {
    Recipe: createActionForm("item.hoh_mw2:book_of_thoth", "hoh_mw2:thoth_recipe", [{ text: "hoh_mw2:exit" }]),
    Tips: createActionForm("item.hoh_mw2:book_of_thoth", "hoh_mw2:thoth_tip", [
      { text: "hoh_mw2:exit" }
    ])
  };
  const recipeBowForms = {
    Recipe: createActionForm("item.hoh_mw2:cupids_bow", "hoh_mw2:cupid_recipe", [{ text: "hoh_mw2:exit" }]),
    Tips: createActionForm("item.hoh_mw2:cupids_bow", "hoh_mw2:cupid_tip", [
      { text: "hoh_mw2:exit" }
    ])
  };
  const recipeFishhookForms = {
    Recipe: createActionForm("item.hoh_mw2:fishhook", "hoh_mw2:fishhook_recipe", [
      { text: "hoh_mw2:exit" }
    ]),
    Tips: createActionForm("item.hoh_mw2:fishhook", "hoh_mw2:fishhook_tip", [
      { text: "hoh_mw2:exit" }
    ])
  };
  const recipeUmbrellaForms = {
    Recipe: createActionForm("item.hoh_mw2:vamanas_umbrella", "hoh_mw2:umbrella_recipe", [{ text: "hoh_mw2:exit" }]),
    Tips: createActionForm("item.hoh_mw2:vamanas_umbrella", "hoh_mw2:umbrella_tip", [
      { text: "hoh_mw2:exit" }
    ])
  };
  const recipeStaffForms = {
    Recipe: createActionForm("item.hoh_mw2:wukong_staff", "hoh_mw2:staff_recipe", [{ text: "hoh_mw2:exit" }]),
    Tips: createActionForm("item.hoh_mw2:wukong_staff", "hoh_mw2:staff_tip", [
      { text: "hoh_mw2:exit" }
    ])
  };
  BookOpenForm.show(arg.source).then((response) => {
    if (response?.selection !== void 0) {
      switch (response.selection) {
        case 0:
          AegisForm.show(arg.source).then((response2) => {
            if (response2?.selection !== void 0) {
              const items = ["Recipe", "Tips"];
              const selectedItem = items[response2.selection];
              if (selectedItem) {
                recipeAegisForms[selectedItem]?.show(arg.source);
              }
            }
          });
          break;
        case 1:
          ScaleForm.show(arg.source).then((response2) => {
            if (response2?.selection !== void 0) {
              const items = ["Recipe", "Tips"];
              const selectedItem = items[response2.selection];
              if (selectedItem) {
                recipeScaleForms[selectedItem]?.show(arg.source);
              }
            }
          });
          break;
        case 2:
          BookForm.show(arg.source).then((response2) => {
            if (response2?.selection !== void 0) {
              const items = ["Recipe", "Tips"];
              const selectedItem = items[response2.selection];
              if (selectedItem) {
                recipeBookForms[selectedItem]?.show(arg.source);
              }
            }
          });
          break;
        case 3:
          BowForm.show(arg.source).then((response2) => {
            if (response2?.selection !== void 0) {
              const items = ["Recipe", "Tips"];
              const selectedItem = items[response2.selection];
              if (selectedItem) {
                recipeBowForms[selectedItem]?.show(arg.source);
              }
            }
          });
          break;
        case 4:
          FishhookForm.show(arg.source).then((response2) => {
            if (response2?.selection !== void 0) {
              const items = ["Recipe", "Tips"];
              const selectedItem = items[response2.selection];
              if (selectedItem) {
                recipeFishhookForms[selectedItem]?.show(arg.source);
              }
            }
          });
          break;
        case 5:
          UmbrellaForm.show(arg.source).then((response2) => {
            if (response2?.selection !== void 0) {
              const items = ["Recipe", "Tips"];
              const selectedItem = items[response2.selection];
              if (selectedItem) {
                recipeUmbrellaForms[selectedItem]?.show(arg.source);
              }
            }
          });
          break;
        case 6:
          StaffForm.show(arg.source).then((response2) => {
            if (response2?.selection !== void 0) {
              const items = ["Recipe", "Tips"];
              const selectedItem = items[response2.selection];
              if (selectedItem) {
                recipeStaffForms[selectedItem]?.show(arg.source);
              }
            }
          });
          break;
        default:
          break;
      }
    }
  });
}
function createActionForm(titleKey, bodyKey, buttons) {
  const form = new ActionFormData().title({ translate: titleKey }).body({ translate: bodyKey });
  buttons.forEach((button) => form.button({ translate: button.text }, button.icon || ""));
  return form;
}

//# sourceMappingURL=../debug/main.js.map
