Class NPCUtils

java.lang.Object
io.hymods.lib.utils.NPCUtils

public class NPCUtils extends Object
Utility class for NPC-related operations
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    changeNPCRole(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store, String newRoleName)
    Changes the role of an NPC
    static com.hypixel.hytale.server.npc.entities.NPCEntity
    getNPC(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store)
    Gets the NPC component from a reference
    static double
    getNPCHealth(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store)
    Gets the health of an NPC
    static com.hypixel.hytale.math.vector.Vector3d
    getNPCLeashPoint(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store)
    Gets the leash point of an NPC
    static com.hypixel.hytale.server.npc.role.Role
    getNPCRole(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store)
    Gets the role of an NPC
    static String
    getNPCRoleName(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store)
    Gets the role name of an NPC
    static String
    getNPCState(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store)
    Gets the current state of an NPC Note: State retrieval depends on internal StateSupport implementation
    static boolean
    isNPC(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store)
    Checks if an entity is an NPC
    static boolean
    removeNPC(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store)
    Removes an NPC from the world
    static boolean
    setNPCDisplayName(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store, String displayName)
    Sets the display name of an NPC
    static boolean
    setNPCLeashPoint(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store, com.hypixel.hytale.math.vector.Vector3d leashPoint)
    Sets the leash point for an NPC
    static boolean
    setNPCState(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store, String state, String subState)
    Sets the state of an NPC
    static boolean
    setNPCTarget(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store, String targetSlot, com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> targetRef)
    Sets a marked target for an NPC
    static com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore>
    spawnCustomNPC(com.hypixel.hytale.server.core.universe.world.World world, String roleName, com.hypixel.hytale.math.vector.Vector3d position, com.hypixel.hytale.math.vector.Vector3f rotation, BiConsumer<com.hypixel.hytale.server.npc.entities.NPCEntity, com.hypixel.hytale.component.Holder<com.hypixel.hytale.server.core.universe.world.storage.EntityStore>> customizer)
    Creates a custom NPC with a callback for customization
    static com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore>
    spawnNPC(com.hypixel.hytale.server.core.universe.world.World world, String roleName, com.hypixel.hytale.math.vector.Vector3d position, com.hypixel.hytale.math.vector.Vector3f rotation)
    Spawns an NPC at a location
    static com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore>
    spawnNPCWithFlock(com.hypixel.hytale.server.core.universe.world.World world, String roleName, String flockType, com.hypixel.hytale.math.vector.Vector3d position, com.hypixel.hytale.math.vector.Vector3f rotation)
    Spawns an NPC with a flock type

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • spawnNPC

      public static com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> spawnNPC(com.hypixel.hytale.server.core.universe.world.World world, String roleName, com.hypixel.hytale.math.vector.Vector3d position, com.hypixel.hytale.math.vector.Vector3f rotation)
      Spawns an NPC at a location
      Parameters:
      world - The world to spawn in
      roleName - The NPC role name
      position - The spawn position
      rotation - The spawn rotation
      Returns:
      The spawned NPC reference, or null if failed
    • spawnNPCWithFlock

      public static com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> spawnNPCWithFlock(com.hypixel.hytale.server.core.universe.world.World world, String roleName, String flockType, com.hypixel.hytale.math.vector.Vector3d position, com.hypixel.hytale.math.vector.Vector3f rotation)
      Spawns an NPC with a flock type
      Parameters:
      world - The world to spawn in
      roleName - The NPC role name
      flockType - The flock type (for group behavior)
      position - The spawn position
      rotation - The spawn rotation
      Returns:
      The spawned NPC reference, or null if failed
    • spawnCustomNPC

      public static com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> spawnCustomNPC(com.hypixel.hytale.server.core.universe.world.World world, String roleName, com.hypixel.hytale.math.vector.Vector3d position, com.hypixel.hytale.math.vector.Vector3f rotation, BiConsumer<com.hypixel.hytale.server.npc.entities.NPCEntity, com.hypixel.hytale.component.Holder<com.hypixel.hytale.server.core.universe.world.storage.EntityStore>> customizer)
      Creates a custom NPC with a callback for customization
      Parameters:
      world - The world to spawn in
      roleName - The NPC role name
      position - The spawn position
      rotation - The spawn rotation
      customizer - Callback to customize the NPC before spawning
      Returns:
      The spawned NPC reference, or null if failed
    • getNPC

      public static com.hypixel.hytale.server.npc.entities.NPCEntity getNPC(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store)
      Gets the NPC component from a reference
      Parameters:
      ref - The entity reference
      store - The entity store
      Returns:
      The NPC component, or null if not an NPC
    • getNPCRole

      public static com.hypixel.hytale.server.npc.role.Role getNPCRole(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store)
      Gets the role of an NPC
      Parameters:
      ref - The NPC reference
      store - The entity store
      Returns:
      The NPC's role, or null if not found
    • setNPCState

      public static boolean setNPCState(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store, String state, String subState)
      Sets the state of an NPC
      Parameters:
      ref - The NPC reference
      store - The entity store
      state - The new state
      subState - Optional sub-state
      Returns:
      true if the state was set successfully
    • getNPCState

      public static String getNPCState(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store)
      Gets the current state of an NPC Note: State retrieval depends on internal StateSupport implementation
      Parameters:
      ref - The NPC reference
      store - The entity store
      Returns:
      The current state, or null if not found
    • setNPCTarget

      public static boolean setNPCTarget(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store, String targetSlot, com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> targetRef)
      Sets a marked target for an NPC
      Parameters:
      ref - The NPC reference
      store - The entity store
      targetSlot - The target slot name (e.g., "LockedTarget")
      targetRef - The target entity reference
      Returns:
      true if the target was set successfully
    • getNPCLeashPoint

      public static com.hypixel.hytale.math.vector.Vector3d getNPCLeashPoint(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store)
      Gets the leash point of an NPC
      Parameters:
      ref - The NPC reference
      store - The entity store
      Returns:
      The leash point, or null if not found
    • setNPCLeashPoint

      public static boolean setNPCLeashPoint(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store, com.hypixel.hytale.math.vector.Vector3d leashPoint)
      Sets the leash point for an NPC
      Parameters:
      ref - The NPC reference
      store - The entity store
      leashPoint - The new leash point
      Returns:
      true if the leash point was set successfully
    • setNPCDisplayName

      public static boolean setNPCDisplayName(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store, String displayName)
      Sets the display name of an NPC
      Parameters:
      ref - The NPC reference
      store - The entity store
      displayName - The new display name
      Returns:
      true if the display name was set successfully
    • getNPCRoleName

      public static String getNPCRoleName(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store)
      Gets the role name of an NPC
      Parameters:
      ref - The NPC reference
      store - The entity store
      Returns:
      The role name, or null if not found
    • changeNPCRole

      public static boolean changeNPCRole(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store, String newRoleName)
      Changes the role of an NPC
      Parameters:
      ref - The NPC reference
      store - The entity store
      newRoleName - The new role name
      Returns:
      true if the role was changed successfully
    • removeNPC

      public static boolean removeNPC(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store)
      Removes an NPC from the world
      Parameters:
      ref - The NPC reference
      store - The entity store
      Returns:
      true if the NPC was removed successfully
    • isNPC

      public static boolean isNPC(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store)
      Checks if an entity is an NPC
      Parameters:
      ref - The entity reference
      store - The entity store
      Returns:
      true if the entity is an NPC
    • getNPCHealth

      public static double getNPCHealth(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store)
      Gets the health of an NPC
      Parameters:
      ref - The NPC reference
      store - The entity store
      Returns:
      The current health, or -1 if not found