Class EntityUtils
java.lang.Object
io.hymods.lib.utils.EntityUtils
Utility class for entity-related operations
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> getClosestEntity(com.hypixel.hytale.server.core.universe.world.World world, com.hypixel.hytale.math.vector.Vector3d position, double maxRadius, Predicate<com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore>> filter) Gets the closest entity to a positionstatic doublegetDistanceBetween(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref1, com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref2, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store) Gets the distance between two entitiesstatic <T extends com.hypixel.hytale.component.Component<com.hypixel.hytale.server.core.universe.world.storage.EntityStore>>
List<com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore>> getEntitiesWithComponent(com.hypixel.hytale.server.core.universe.world.World world, com.hypixel.hytale.component.ComponentType<com.hypixel.hytale.server.core.universe.world.storage.EntityStore, T> componentType) Gets all entities of a specific component typestatic com.hypixel.hytale.server.core.modules.entity.component.BoundingBoxgetEntityBoundingBox(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 bounding box of an entitystatic com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> getEntityByUUID(com.hypixel.hytale.server.core.universe.world.World world, UUID uuid) Gets an entity by its UUIDstatic StringgetEntityDisplayName(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 display name of an entitystatic com.hypixel.hytale.math.vector.Vector3dgetEntityPosition(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 position of an entitystatic com.hypixel.hytale.math.vector.Vector3fgetEntityRotation(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 rotation of an entitystatic com.hypixel.hytale.math.vector.Vector3dgetEntityVelocity(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 velocity of an entity Note: Velocity data may not be available for all entitiesstatic booleanisInWater(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 in water Note: This is a simplified implementation - actual water check may require accessing the world and checking the block at entity positionstatic booleanisLivingEntity(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 a living entity (has health/can take damage)static 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 booleanisOnGround(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 on the ground Note: This is a simplified implementation - actual ground check may require accessing the entity's transform and checking blocks belowstatic booleanisPlayer(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 a playerstatic booleanremoveEntity(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 entity from the worldstatic EntitySearchResultsearchEntities(com.hypixel.hytale.server.core.universe.world.World world, com.hypixel.hytale.math.vector.Vector3d center, double radius) Searches for entities within a radiusstatic EntitySearchResultsearchEntities(com.hypixel.hytale.server.core.universe.world.World world, SearchParameters params) Searches for entities with specific parameters
-
Method Details
-
getEntityByUUID
public static com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> getEntityByUUID(com.hypixel.hytale.server.core.universe.world.World world, UUID uuid) Gets an entity by its UUID- Parameters:
world- The world to search inuuid- The entity's UUID- Returns:
- The entity reference, or null if not found
-
searchEntities
public static EntitySearchResult searchEntities(com.hypixel.hytale.server.core.universe.world.World world, com.hypixel.hytale.math.vector.Vector3d center, double radius) Searches for entities within a radius- Parameters:
world- The world to search incenter- The center positionradius- The search radius- Returns:
- The search results
-
searchEntities
public static EntitySearchResult searchEntities(com.hypixel.hytale.server.core.universe.world.World world, SearchParameters params) Searches for entities with specific parameters- Parameters:
world- The world to search inparams- The search parameters- Returns:
- The search results
-
getEntitiesWithComponent
public static <T extends com.hypixel.hytale.component.Component<com.hypixel.hytale.server.core.universe.world.storage.EntityStore>> List<com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore>> getEntitiesWithComponent(com.hypixel.hytale.server.core.universe.world.World world, com.hypixel.hytale.component.ComponentType<com.hypixel.hytale.server.core.universe.world.storage.EntityStore, T> componentType) Gets all entities of a specific component type- Parameters:
world- The world to search incomponentType- The component type to filter by- Returns:
- List of entity references
-
getEntityPosition
public static com.hypixel.hytale.math.vector.Vector3d getEntityPosition(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 position of an entity- Parameters:
ref- The entity referencestore- The entity store- Returns:
- The entity's position, or null if not found
-
getEntityRotation
public static com.hypixel.hytale.math.vector.Vector3f getEntityRotation(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 rotation of an entity- Parameters:
ref- The entity referencestore- The entity store- Returns:
- The entity's rotation, or null if not found
-
getEntityVelocity
public static com.hypixel.hytale.math.vector.Vector3d getEntityVelocity(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 velocity of an entity Note: Velocity data may not be available for all entities- Parameters:
ref- The entity referencestore- The entity store- Returns:
- The entity's velocity, or null if not found
-
getEntityDisplayName
public static String getEntityDisplayName(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 display name of an entity- Parameters:
ref- The entity referencestore- The entity store- Returns:
- The entity's display name, or "Unknown" if not found
-
getEntityBoundingBox
public static com.hypixel.hytale.server.core.modules.entity.component.BoundingBox getEntityBoundingBox(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 bounding box of an entity- Parameters:
ref- The entity referencestore- The entity store- Returns:
- The entity's bounding box, or null if not found
-
isOnGround
public static boolean isOnGround(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 on the ground Note: This is a simplified implementation - actual ground check may require accessing the entity's transform and checking blocks below- Parameters:
ref- The entity referencestore- The entity store- Returns:
- true if the entity appears to be on ground based on position
-
isInWater
public static boolean isInWater(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 in water Note: This is a simplified implementation - actual water check may require accessing the world and checking the block at entity position- Parameters:
ref- The entity referencestore- The entity store- Returns:
- true if the entity appears to be in water
-
getDistanceBetween
public static double getDistanceBetween(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref1, com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref2, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store) Gets the distance between two entities- Parameters:
ref1- First entity referenceref2- Second entity referencestore- The entity store- Returns:
- The distance between entities, or -1 if either is invalid
-
isPlayer
public static boolean isPlayer(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 a player- Parameters:
ref- The entity referencestore- The entity store- Returns:
- true if the entity is a player
-
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
-
isLivingEntity
public static boolean isLivingEntity(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 a living entity (has health/can take damage)- Parameters:
ref- The entity referencestore- The entity store- Returns:
- true if the entity is living
-
getClosestEntity
public static com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> getClosestEntity(com.hypixel.hytale.server.core.universe.world.World world, com.hypixel.hytale.math.vector.Vector3d position, double maxRadius, Predicate<com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore>> filter) Gets the closest entity to a position- Parameters:
world- The world to search inposition- The position to search frommaxRadius- Maximum search radiusfilter- Optional filter predicate- Returns:
- The closest entity reference, or null if none found
-
removeEntity
public static boolean removeEntity(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 entity from the world- Parameters:
ref- The entity referencestore- The entity store- Returns:
- true if the entity was removed
-