Contents
Class EntityCollisionProvider
java.lang.Object
com.hypixel.hytale.server.core.modules.collision.EntityCollisionProvider
Provides functionality to compute collisions between entities in the game world.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Called to clear the contact list.doublecomputeNearest(Box entityBoundingBox, org.joml.Vector3d pos, org.joml.Vector3d dir, Ref<EntityStore> ignoreSelf, Ref<EntityStore> ignore, ComponentAccessor<EntityStore> componentAccessor) Find nearest collision of AABB swept along a vector with another entity and store it in contact list.doublecomputeNearest(org.joml.Vector3d pos, org.joml.Vector3d dir, Box boundingBox, double radius, BiPredicate<Ref<EntityStore>, ComponentAccessor<EntityStore>> entityFilter, Ref<EntityStore> ignoreSelf, Ref<EntityStore> ignoreOther, ComponentAccessor<EntityStore> componentAccessor) Find nearest collision of AABB swept along a vector with another entity and store it in contact list.static booleandefaultEntityFilter(Ref<EntityStore> ref, ComponentAccessor<EntityStore> componentAccessor) The default entity filter which filters out projectiles and dead entities.getContact(int index) Called to fetch contact data at a given index.intgetCount()
-
Constructor Details
-
EntityCollisionProvider
public EntityCollisionProvider()Default Constructor for aEntityCollisionProviderinstance.
-
-
Method Details
-
getCount
public int getCount()- Returns:
- the number of contacts detected.
-
getContact
Called to fetch contact data at a given index.- Parameters:
index- The index of the contact data to retrieve.- Returns:
- the contact data at the specified index.
-
clear
public void clear()Called to clear the contact list. -
computeNearest
public double computeNearest(@Nonnull Box entityBoundingBox, @Nonnull org.joml.Vector3d pos, @Nonnull org.joml.Vector3d dir, @Nullable Ref<EntityStore> ignoreSelf, @Nullable Ref<EntityStore> ignore, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Find nearest collision of AABB swept along a vector with another entity and store it in contact list.- Parameters:
entityBoundingBox- AABB bounding box of the entity performing the collision check.pos- Initial position of AABB.dir- Movement ray of AABB.ignoreSelf- The entity reference of the entity to ignore during collision checks, ornullto not ignore any entity.ignore- Ref to ignore. Can be null. Intended to be used for excluding creator of entity starting the search.componentAccessor- TheComponentAccessor<EntityStore>for component access.- Returns:
- relative distance of collision or negative value (-
Double.MAX_VALUE) when no collision with entity found.
-
computeNearest
public double computeNearest(@Nonnull org.joml.Vector3d pos, @Nonnull org.joml.Vector3d dir, @Nonnull Box boundingBox, double radius, @Nonnull BiPredicate<Ref<EntityStore>, ComponentAccessor<EntityStore>> entityFilter, @Nullable Ref<EntityStore> ignoreSelf, @Nullable Ref<EntityStore> ignoreOther, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Find nearest collision of AABB swept along a vector with another entity and store it in contact list.- Parameters:
pos- Initial position of AABB.dir- Movement ray of AABB.boundingBox- AABB bounding box.radius- Search distance for entities.entityFilter- Predicate to accept or reject entities.ignoreSelf- Ref to ignore. Can be null. Intended to be used for excluding entity starting the search.ignoreOther- Ref to ignore. Can be null. Intended to be used for excluding creator of entity starting the search.componentAccessor- TheComponentAccessor<EntityStore>for component access.- Returns:
- relative distance of collision or negative value (-
Double.MAX_VALUE) when no collision with entity found
-
defaultEntityFilter
public static boolean defaultEntityFilter(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor) The default entity filter which filters out projectiles and dead entities.- Parameters:
ref- The entity reference to test.componentAccessor- TheComponentAccessor<EntityStore>for component access.- Returns:
trueif the entity should be considered for collision,falseotherwise.
-