Contents
- Description
- Constructor Summary
- Method Summary
- Constructor Details
- Method Details
- getTargetBlock(ChunkStore, BiIntPredicate, double, double, double, double, double, double, double)
- getTargetBlock(World, BiIntPredicate, double, double, double, double, double, double, double)
- getTargetBlockOrigin(ChunkStore, BiIntPredicate, double, double, double, double, double, double, double)
- getTargetBlockOrigin(World, BiIntPredicate, double, double, double, double, double, double, double)
- getTargetLocation(ChunkStore, IntPredicate, double, double, double, double, double, double, double)
- getTargetLocation(World, IntPredicate, double, double, double, double, double, double, double)
- getTargetBlockAvoidLocations(ChunkStore, IntPredicate, double, double, double, double, double, double, double, Collection)
- getTargetBlockAvoidLocations(World, IntPredicate, double, double, double, double, double, double, double, Collection)
- getTargetBlockAvoidLocations(ChunkStore, IntPredicate, double, double, double, double, double, double, double, Collection, Vector3d)
- getTargetBlockAvoidLocations(World, IntPredicate, double, double, double, double, double, double, double, Collection, Vector3d)
- getTargetBlock(Ref, double, ComponentAccessor)
- getTargetBlock(Ref, IntPredicate, double, ComponentAccessor)
- getTargetBlockOrigin(Ref, double, ComponentAccessor)
- getTargetBlockOrigin(Ref, IntPredicate, double, ComponentAccessor)
- getTargetLocation(Ref, double, ComponentAccessor)
- getTargetLocation(Ref, IntPredicate, double, ComponentAccessor)
- getTargetLocation(Transform, IntPredicate, double, ComponentAccessor)
- getAllEntitiesInSphere(Vector3d, double, ComponentAccessor)
- getAllEntitiesInCylinder(Vector3d, double, double, ComponentAccessor)
- getAllEntitiesInBox(Vector3d, Vector3d, ComponentAccessor)
- getTargetEntity(Ref, ComponentAccessor)
- getTargetEntity(Ref, float, ComponentAccessor)
- getTargetEntity(Ref, float, boolean, ComponentAccessor)
- getLook(Ref, ComponentAccessor)
Class TargetUtil
java.lang.Object
com.hypixel.hytale.server.core.util.TargetUtil
A utility class that contains a variety of useful target related methods.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic List<Ref<EntityStore>> getAllEntitiesInBox(org.joml.Vector3d min, org.joml.Vector3d max, ComponentAccessor<EntityStore> componentAccessor) Called to fetch a list of all entities within an axis-aligned box, utilising the spatial resources available.static List<Ref<EntityStore>> getAllEntitiesInCylinder(org.joml.Vector3d position, double radius, double height, ComponentAccessor<EntityStore> componentAccessor) Called to fetch a list of all entities within a cylindrical area, utilising the spatial resources available.static List<Ref<EntityStore>> getAllEntitiesInSphere(org.joml.Vector3d position, double radius, ComponentAccessor<EntityStore> componentAccessor) Called to fetch a list of all entities within a spherical area, utilising the spatial resources available.static TransformgetLook(Ref<EntityStore> ref, ComponentAccessor<EntityStore> componentAccessor) Creates a newTransforminstance based on the transform and head rotation/height of the provided entity.static org.joml.Vector3igetTargetBlock(Ref<EntityStore> ref, double maxDistance, ComponentAccessor<EntityStore> componentAccessor) Called to fetch the target block position based on a raycast from an entity.static org.joml.Vector3igetTargetBlock(Ref<EntityStore> ref, IntPredicate blockIdPredicate, double maxDistance, ComponentAccessor<EntityStore> componentAccessor) Called to fetch the target block position based on a raycast from an entity.static org.joml.Vector3igetTargetBlock(ChunkStore chunkStore, BiIntPredicate blockIdPredicate, double originX, double originY, double originZ, double directionX, double directionY, double directionZ, double maxDistance) Called to fetch the target block position based on a raycast from an origin in a specific direction.static org.joml.Vector3igetTargetBlock(World world, BiIntPredicate blockIdPredicate, double originX, double originY, double originZ, double directionX, double directionY, double directionZ, double maxDistance) Deprecated.static org.joml.Vector3igetTargetBlockAvoidLocations(ChunkStore chunkStore, IntPredicate blockIdPredicate, double originX, double originY, double originZ, double directionX, double directionY, double directionZ, double maxDistance, Collection<Int3OpenHashSet> blocksToIgnore) Called to fetch the target block position based on a raycast from an origin in a specific direction,static org.joml.Vector3igetTargetBlockAvoidLocations(ChunkStore chunkStore, IntPredicate blockIdPredicate, double originX, double originY, double originZ, double directionX, double directionY, double directionZ, double maxDistance, Collection<Int3OpenHashSet> blocksToIgnore, org.joml.Vector3d hitPositionOut) Same asgetTargetBlockAvoidLocations(ChunkStore, IntPredicate, double, double, double, double, double, double, double, Collection)but also writes the precise hit position intohitPositionOut.static org.joml.Vector3igetTargetBlockAvoidLocations(World world, IntPredicate blockIdPredicate, double originX, double originY, double originZ, double directionX, double directionY, double directionZ, double maxDistance, Collection<Int3OpenHashSet> blocksToIgnore) Deprecated.static org.joml.Vector3igetTargetBlockAvoidLocations(World world, IntPredicate blockIdPredicate, double originX, double originY, double originZ, double directionX, double directionY, double directionZ, double maxDistance, Collection<Int3OpenHashSet> blocksToIgnore, org.joml.Vector3d hitPositionOut) Deprecated.static org.joml.Vector3igetTargetBlockOrigin(Ref<EntityStore> ref, double maxDistance, ComponentAccessor<EntityStore> componentAccessor) Called to fetch the origin (base) block position of a multi-block structure hit by a raycast from an entity.static org.joml.Vector3igetTargetBlockOrigin(Ref<EntityStore> ref, IntPredicate blockIdPredicate, double maxDistance, ComponentAccessor<EntityStore> componentAccessor) Called to fetch the origin (base) block position of a multi-block structure hit by a raycast from an entity.static org.joml.Vector3igetTargetBlockOrigin(ChunkStore chunkStore, BiIntPredicate blockIdPredicate, double originX, double originY, double originZ, double directionX, double directionY, double directionZ, double maxDistance) Called to fetch the origin (base) block position of a multi-block structure hit by a raycast.static org.joml.Vector3igetTargetBlockOrigin(World world, BiIntPredicate blockIdPredicate, double originX, double originY, double originZ, double directionX, double directionY, double directionZ, double maxDistance) Deprecated.static Ref<EntityStore> getTargetEntity(Ref<EntityStore> ref, float radius, boolean includeItemDrops, ComponentAccessor<EntityStore> componentAccessor) Called to fetch the nearest entity in view of the given entity reference.static Ref<EntityStore> getTargetEntity(Ref<EntityStore> ref, float radius, ComponentAccessor<EntityStore> componentAccessor) Called to fetch the nearest entity in view of the given entity reference.static Ref<EntityStore> getTargetEntity(Ref<EntityStore> ref, ComponentAccessor<EntityStore> componentAccessor) Called to fetch the nearest entity in view of the given entity reference.static org.joml.Vector3dgetTargetLocation(Ref<EntityStore> ref, double maxDistance, ComponentAccessor<EntityStore> componentAccessor) Called to fetch the target location based on a raycast from an entity.static org.joml.Vector3dgetTargetLocation(Ref<EntityStore> ref, IntPredicate blockIdPredicate, double maxDistance, ComponentAccessor<EntityStore> componentAccessor) Called to fetch the target location based on a raycast from an entity.static org.joml.Vector3dgetTargetLocation(Transform transform, IntPredicate blockIdPredicate, double maxDistance, ComponentAccessor<EntityStore> componentAccessor) Called to fetch the target location based on a raycast from an entity.static org.joml.Vector3dgetTargetLocation(ChunkStore chunkStore, IntPredicate blockIdPredicate, double originX, double originY, double originZ, double directionX, double directionY, double directionZ, double maxDistance) Called to fetch the target location based on a raycast from an origin in a specific direction.static org.joml.Vector3dgetTargetLocation(World world, IntPredicate blockIdPredicate, double originX, double originY, double originZ, double directionX, double directionY, double directionZ, double maxDistance) Overload forgetTargetLocation(ChunkStore, IntPredicate, double, double, double, double, double, double, double)that uses the world chunk store.
-
Constructor Details
-
TargetUtil
public TargetUtil()
-
-
Method Details
-
getTargetBlock
@Nullable public static org.joml.Vector3i getTargetBlock(@Nonnull ChunkStore chunkStore, @Nonnull BiIntPredicate blockIdPredicate, double originX, double originY, double originZ, double directionX, double directionY, double directionZ, double maxDistance) Called to fetch the target block position based on a raycast from an origin in a specific direction.- Parameters:
chunkStore- The chunk store to perform the raycast in.blockIdPredicate- A predicate that tests the block ID and fluid ID at each position. Return true to continue the raycast, false to stop.originX- The X coordinate of the origin.originY- The Y coordinate of the origin.originZ- The Z coordinate of the origin.directionX- The X component of the direction.directionY- The Y component of the direction.directionZ- The Z component of the direction.maxDistance- The maximum distance to cast.- Returns:
- the target
Vector3iblock position, ornullif no block was found within the max distance.
-
getTargetBlock
@Nullable @Deprecated public static org.joml.Vector3i getTargetBlock(@Nonnull World world, @Nonnull BiIntPredicate blockIdPredicate, double originX, double originY, double originZ, double directionX, double directionY, double directionZ, double maxDistance) Deprecated.Overload forgetTargetBlock(ChunkStore, BiIntPredicate, double, double, double, double, double, double, double)that uses the world chunk store. -
getTargetBlockOrigin
@Nullable public static org.joml.Vector3i getTargetBlockOrigin(@Nonnull ChunkStore chunkStore, @Nonnull BiIntPredicate blockIdPredicate, double originX, double originY, double originZ, double directionX, double directionY, double directionZ, double maxDistance) Called to fetch the origin (base) block position of a multi-block structure hit by a raycast.Functions identically to
getTargetBlock(ChunkStore, BiIntPredicate, double, double, double, double, double, double, double), except the returned position is offset by the packed filler value at the hit position so that filler blocks resolve to their origin block.- Parameters:
chunkStore- The chunks store to perform the raycast in.blockIdPredicate- A predicate that tests the block ID and fluid ID at each position. Return true to continue the raycast, false to stop.originX- The X coordinate of the origin.originY- The Y coordinate of the origin.originZ- The Z coordinate of the origin.directionX- The X component of the direction.directionY- The Y component of the direction.directionZ- The Z component of the direction.maxDistance- The maximum distance to cast.- Returns:
- the origin
Vector3iblock position, ornullif no block was found within the max distance.
-
getTargetBlockOrigin
@Nullable @Deprecated public static org.joml.Vector3i getTargetBlockOrigin(@Nonnull World world, @Nonnull BiIntPredicate blockIdPredicate, double originX, double originY, double originZ, double directionX, double directionY, double directionZ, double maxDistance) Deprecated.Overload forgetTargetBlockOrigin(ChunkStore, BiIntPredicate, double, double, double, double, double, double, double)that uses the world chunk store. -
getTargetLocation
@Nullable public static org.joml.Vector3d getTargetLocation(@Nonnull ChunkStore chunkStore, @Nonnull IntPredicate blockIdPredicate, double originX, double originY, double originZ, double directionX, double directionY, double directionZ, double maxDistance) Called to fetch the target location based on a raycast from an origin in a specific direction.- Parameters:
chunkStore- The chunk store to perform the raycast in.blockIdPredicate- A predicate that tests the block ID at each position. Return true to continue the raycast, false to stop.originX- The X coordinate of the origin.originY- The Y coordinate of the origin.originZ- The Z coordinate of the origin.directionX- The X component of the direction.directionY- The Y component of the direction.directionZ- The Z component of the direction.maxDistance- The maximum distance to cast.- Returns:
- the target
Vector3dlocation, ornullif no block was found within the max distance.
-
getTargetLocation
@Nullable public static org.joml.Vector3d getTargetLocation(@Nonnull World world, @Nonnull IntPredicate blockIdPredicate, double originX, double originY, double originZ, double directionX, double directionY, double directionZ, double maxDistance) Overload forgetTargetLocation(ChunkStore, IntPredicate, double, double, double, double, double, double, double)that uses the world chunk store. -
getTargetBlockAvoidLocations
@Nullable public static org.joml.Vector3i getTargetBlockAvoidLocations(@Nonnull ChunkStore chunkStore, @Nonnull IntPredicate blockIdPredicate, double originX, double originY, double originZ, double directionX, double directionY, double directionZ, double maxDistance, @Nonnull Collection<Int3OpenHashSet> blocksToIgnore) Called to fetch the target block position based on a raycast from an origin in a specific direction,- Parameters:
chunkStore- The chunk store to perform the raycast in.blockIdPredicate- A predicate that tests the block ID at each position. Return true to continue the raycast, false to stop.originX- The X coordinate of the origin.originY- The Y coordinate of the origin.originZ- The Z coordinate of the origin.directionX- The X component of the direction.directionY- The Y component of the direction.directionZ- The Z component of the direction.maxDistance- The maximum distance to cast.blocksToIgnore- A list of sets of block positions to ignore during the raycast.- Returns:
- the target
Vector3iblock position, ornullif no block was found within the max distance.
-
getTargetBlockAvoidLocations
@Nullable @Deprecated public static org.joml.Vector3i getTargetBlockAvoidLocations(@Nonnull World world, @Nonnull IntPredicate blockIdPredicate, double originX, double originY, double originZ, double directionX, double directionY, double directionZ, double maxDistance, @Nonnull Collection<Int3OpenHashSet> blocksToIgnore) Deprecated.Overload forgetTargetBlockAvoidLocations(ChunkStore, IntPredicate, double, double, double, double, double, double, double, Collection)that uses the world chunk store. -
getTargetBlockAvoidLocations
@Nullable public static org.joml.Vector3i getTargetBlockAvoidLocations(@Nonnull ChunkStore chunkStore, @Nonnull IntPredicate blockIdPredicate, double originX, double originY, double originZ, double directionX, double directionY, double directionZ, double maxDistance, @Nonnull Collection<Int3OpenHashSet> blocksToIgnore, @Nonnull org.joml.Vector3d hitPositionOut) Same asgetTargetBlockAvoidLocations(ChunkStore, IntPredicate, double, double, double, double, double, double, double, Collection)but also writes the precise hit position intohitPositionOut. -
getTargetBlockAvoidLocations
@Nullable @Deprecated public static org.joml.Vector3i getTargetBlockAvoidLocations(@Nonnull World world, @Nonnull IntPredicate blockIdPredicate, double originX, double originY, double originZ, double directionX, double directionY, double directionZ, double maxDistance, @Nonnull Collection<Int3OpenHashSet> blocksToIgnore, @Nonnull org.joml.Vector3d hitPositionOut) Deprecated.Overload forgetTargetBlockAvoidLocations(ChunkStore, IntPredicate, double, double, double, double, double, double, double, Collection, Vector3d)that uses the world chunk store. -
getTargetBlock
@Nullable public static org.joml.Vector3i getTargetBlock(@Nonnull Ref<EntityStore> ref, double maxDistance, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Called to fetch the target block position based on a raycast from an entity.- Parameters:
ref- The entity reference of the entity.maxDistance- The maximum distance to cast.componentAccessor- TheComponentAccessor<EntityStore>for component access.- Returns:
- the target
Vector3iblock position, ornullif no block was found within the max distance.
-
getTargetBlock
@Nullable public static org.joml.Vector3i getTargetBlock(@Nonnull Ref<EntityStore> ref, @Nonnull IntPredicate blockIdPredicate, double maxDistance, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Called to fetch the target block position based on a raycast from an entity.- Parameters:
ref- The entity reference of the entity.blockIdPredicate- The predicate to test block IDs.maxDistance- The maximum distance to cast.componentAccessor- TheComponentAccessor<EntityStore>for component access.- Returns:
- the target
Vector3iblock position, ornullif no block was found within the max distance.
-
getTargetBlockOrigin
@Nullable public static org.joml.Vector3i getTargetBlockOrigin(@Nonnull Ref<EntityStore> ref, double maxDistance, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Called to fetch the origin (base) block position of a multi-block structure hit by a raycast from an entity.- Parameters:
ref- The entity reference of the entity.maxDistance- The maximum distance to cast.componentAccessor- TheComponentAccessor<EntityStore>for component access.- Returns:
- the origin
Vector3iblock position, ornullif no block was found within the max distance.
-
getTargetBlockOrigin
@Nullable public static org.joml.Vector3i getTargetBlockOrigin(@Nonnull Ref<EntityStore> ref, @Nonnull IntPredicate blockIdPredicate, double maxDistance, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Called to fetch the origin (base) block position of a multi-block structure hit by a raycast from an entity.- Parameters:
ref- The entity reference of the entity.blockIdPredicate- The predicate to test block IDs.maxDistance- The maximum distance to cast.componentAccessor- TheComponentAccessor<EntityStore>for component access.- Returns:
- the origin
Vector3iblock position, ornullif no block was found within the max distance.
-
getTargetLocation
@Nullable public static org.joml.Vector3d getTargetLocation(@Nonnull Ref<EntityStore> ref, double maxDistance, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Called to fetch the target location based on a raycast from an entity.- Parameters:
ref- The entity reference of the entity.maxDistance- The maximum distance to cast.componentAccessor- TheComponentAccessor<EntityStore>for component access.- Returns:
- the target
Vector3dlocation, ornullif no block was found within the max distance.
-
getTargetLocation
@Nullable public static org.joml.Vector3d getTargetLocation(@Nonnull Ref<EntityStore> ref, @Nonnull IntPredicate blockIdPredicate, double maxDistance, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Called to fetch the target location based on a raycast from an entity.- Parameters:
ref- The entity reference of the entity.blockIdPredicate- The predicate to test block IDs.maxDistance- The maximum distance to cast.componentAccessor- TheComponentAccessor<EntityStore>for component access.- Returns:
- the target
Vector3dlocation, ornullif no block was found within the max distance.
-
getTargetLocation
@Nullable public static org.joml.Vector3d getTargetLocation(@Nonnull Transform transform, @Nonnull IntPredicate blockIdPredicate, double maxDistance, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Called to fetch the target location based on a raycast from an entity.- Parameters:
transform- The transform to raycast from.blockIdPredicate- The predicate to test block IDs.maxDistance- The maximum distance to cast.componentAccessor- TheComponentAccessor<EntityStore>for component access.- Returns:
- the target
Vector3dlocation, ornullif no block was found within the max distance.
-
getAllEntitiesInSphere
@Nonnull public static List<Ref<EntityStore>> getAllEntitiesInSphere(@Nonnull org.joml.Vector3d position, double radius, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Called to fetch a list of all entities within a spherical area, utilising the spatial resources available.- Parameters:
position- The center position of the sphere.radius- The radius of the sphere.componentAccessor- TheComponentAccessor<EntityStore>for component access.- Returns:
- a list of entity references within the sphere.
-
getAllEntitiesInCylinder
@Nonnull public static List<Ref<EntityStore>> getAllEntitiesInCylinder(@Nonnull org.joml.Vector3d position, double radius, double height, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Called to fetch a list of all entities within a cylindrical area, utilising the spatial resources available.- Parameters:
position- The center position of the cylinder.radius- The radius of the cylinder in the XZ plane.height- The total height of the cylinder (extends halfHeight above and below center).componentAccessor- TheComponentAccessor<EntityStore>for component access.- Returns:
- a list of entity references within the cylinder.
-
getAllEntitiesInBox
@Nonnull public static List<Ref<EntityStore>> getAllEntitiesInBox(@Nonnull org.joml.Vector3d min, @Nonnull org.joml.Vector3d max, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Called to fetch a list of all entities within an axis-aligned box, utilising the spatial resources available.- Parameters:
min- The minimum corner of the box (inclusive).max- The maximum corner of the box (inclusive).componentAccessor- TheComponentAccessor<EntityStore>for component access.- Returns:
- a list of entity references within the box.
-
getTargetEntity
@Nullable public static Ref<EntityStore> getTargetEntity(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Called to fetch the nearest entity in view of the given entity reference. Uses the defaultENTITY_TARGET_RADIUSof 8 blocks.- Parameters:
ref- The entity reference of the viewer entity.componentAccessor- TheComponentAccessor<EntityStore>for component access.- Returns:
- The nearest entity reference in view, or null if none found.
-
getTargetEntity
@Nullable public static Ref<EntityStore> getTargetEntity(@Nonnull Ref<EntityStore> ref, float radius, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Called to fetch the nearest entity in view of the given entity reference.- Parameters:
ref- The entity reference of the viewer entity.radius- The radius, in blocks, in which to search for entities.componentAccessor- TheComponentAccessor<EntityStore>for component access.- Returns:
- The nearest entity reference in view, or null if none found.
-
getTargetEntity
@Nullable public static Ref<EntityStore> getTargetEntity(@Nonnull Ref<EntityStore> ref, float radius, boolean includeItemDrops, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Called to fetch the nearest entity in view of the given entity reference.- Parameters:
ref- The entity reference of the viewer entity.radius- The radius, in blocks, in which to search for entities.includeItemDrops- Whether dropped item entities may be targeted. Item drops are intangible and indexed separately, so the entity search never sees them unless they are requested here.componentAccessor- TheComponentAccessor<EntityStore>for component access.- Returns:
- The nearest entity reference in view, or null if none found.
-
getLook
@Nonnull public static Transform getLook(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Creates a newTransforminstance based on the transform and head rotation/height of the provided entity.- Parameters:
ref- The entity reference of the entity that we are creating a transform for.componentAccessor- TheComponentAccessorfor component access.- Returns:
- the newly created
Transforminstance.
-