Contents
Class EntityRefCollisionProvider
java.lang.Object
com.hypixel.hytale.server.core.modules.collision.EntityRefCollisionProvider
A collision provider that computes collisions between an AABB and entities.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Called to clear all stored contacts.doublecomputeNearest(CommandBuffer<EntityStore> commandBuffer, Box entityBoundingBox, org.joml.Vector3d pos, org.joml.Vector3d dir, Ref<EntityStore> ignoreSelf, Ref<EntityStore> ignore) Find nearest collision of AABB swept along a vector with another entity and store it in contact list.doublecomputeNearest(CommandBuffer<EntityStore> commandBuffer, org.joml.Vector3d pos, org.joml.Vector3d dir, Box boundingBox, double radius, BiPredicate<Ref<EntityStore>, CommandBuffer<EntityStore>> entityFilter, Ref<EntityStore> ignoreSelf, Ref<EntityStore> ignoreOther) Find nearest collision of AABB swept along a vector with another entity and store it in contact list.static booleandefaultEntityFilter(Ref<EntityStore> entity, CommandBuffer<EntityStore> commandBuffer) Default entity filter to exclude projectiles, dead entities, and non-collidable entities.getContact(int i) Called to fetch the contact data of a specific contact.intgetCount()
-
Constructor Details
-
EntityRefCollisionProvider
public EntityRefCollisionProvider()Default Constructor for aEntityRefCollisionProviderinstance.
-
-
Method Details
-
getCount
public int getCount()- Returns:
- number of contacts stored in the provider.
-
getContact
Called to fetch the contact data of a specific contact.- Parameters:
i- Index of contact to fetch.- Returns:
- the contact data.
-
clear
public void clear()Called to clear all stored contacts. -
computeNearest
public double computeNearest(@Nonnull CommandBuffer<EntityStore> commandBuffer, @Nonnull Box entityBoundingBox, @Nonnull org.joml.Vector3d pos, @Nonnull org.joml.Vector3d dir, @Nullable Ref<EntityStore> ignoreSelf, @Nullable Ref<EntityStore> ignore) Find nearest collision of AABB swept along a vector with another entity and store it in contact list.- Parameters:
commandBuffer- TheCommandBuffer<EntityStore>for component access.entityBoundingBox- AABB bounding box of the moving entitypos- Initial position of AABBdir- Movement ray of AABBignoreSelf- The entity reference of the instigating entity, ornullto not ignore any entity.ignore- The entity reference of the creator of the instigating entity, ornullto not ignore any entity.- Returns:
- relative distance of collision or negative value (-
Double.MAX_VALUE) when no collision with entity found
-
computeNearest
public double computeNearest(@Nonnull CommandBuffer<EntityStore> commandBuffer, @Nonnull org.joml.Vector3d pos, @Nonnull org.joml.Vector3d dir, @Nonnull Box boundingBox, double radius, @Nonnull BiPredicate<Ref<EntityStore>, CommandBuffer<EntityStore>> entityFilter, @Nullable Ref<EntityStore> ignoreSelf, @Nullable Ref<EntityStore> ignoreOther) Find nearest collision of AABB swept along a vector with another entity and store it in contact list.- Parameters:
commandBuffer- TheCommandBuffer<EntityStore>for component access.pos- Initial position of AABBdir- Movement ray of AABBboundingBox- AABB bounding boxradius- Search distance for entitiesentityFilter- Predicate to accept or reject entitiesignoreSelf- Ref to ignore. Can be null. Intended to be used for excluding entity starting the searchignoreOther- Ref to ignore. Can be null. Intended to be used for excluding creator of entity starting the search- 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> entity, @Nonnull CommandBuffer<EntityStore> commandBuffer) Default entity filter to exclude projectiles, dead entities, and non-collidable entities.- Parameters:
entity- The entity reference of the entity to filter.commandBuffer- TheCommandBuffer<EntityStore>for component access.- Returns:
trueif the entity should be considered for collision,falseotherwise.
-