Class NPCUtils
java.lang.Object
io.hymods.lib.utils.NPCUtils
Utility class for NPC-related operations
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanchangeNPCRole(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 NPCstatic com.hypixel.hytale.server.npc.entities.NPCEntitygetNPC(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 referencestatic doublegetNPCHealth(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 NPCstatic com.hypixel.hytale.math.vector.Vector3dgetNPCLeashPoint(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 NPCstatic com.hypixel.hytale.server.npc.role.RolegetNPCRole(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 NPCstatic StringgetNPCRoleName(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 NPCstatic StringgetNPCState(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 implementationstatic booleanisNPC(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 NPCstatic booleanremoveNPC(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 worldstatic booleansetNPCDisplayName(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 NPCstatic booleansetNPCLeashPoint(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 NPCstatic booleansetNPCState(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 NPCstatic booleansetNPCTarget(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 NPCstatic 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 customizationstatic 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 locationstatic 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
-
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 inroleName- The NPC role nameposition- The spawn positionrotation- 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 inroleName- The NPC role nameflockType- The flock type (for group behavior)position- The spawn positionrotation- 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 inroleName- The NPC role nameposition- The spawn positionrotation- The spawn rotationcustomizer- 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 referencestore- 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 referencestore- 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 referencestore- The entity storestate- The new statesubState- 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 referencestore- 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 referencestore- The entity storetargetSlot- 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 referencestore- 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 referencestore- The entity storeleashPoint- 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 referencestore- The entity storedisplayName- 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 referencestore- 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 referencestore- The entity storenewRoleName- 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 referencestore- 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 referencestore- 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 referencestore- The entity store- Returns:
- The current health, or -1 if not found
-