Class EntityRefCollisionProvider

java.lang.Object
com.hypixel.hytale.server.core.modules.collision.EntityRefCollisionProvider

public class EntityRefCollisionProvider extends Object
A collision provider that computes collisions between an AABB and entities.
  • Constructor Details

  • Method Details

    • getCount

      public int getCount()
      Returns:
      number of contacts stored in the provider.
    • getContact

      @Nonnull public EntityContactData getContact(int i)
      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 - The CommandBuffer<EntityStore> for component access.
      entityBoundingBox - AABB bounding box of the moving entity
      pos - Initial position of AABB
      dir - Movement ray of AABB
      ignoreSelf - The entity reference of the instigating entity, or null to not ignore any entity.
      ignore - The entity reference of the creator of the instigating entity, or null to 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 - The CommandBuffer<EntityStore> for component access.
      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
      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 - The CommandBuffer<EntityStore> for component access.
      Returns:
      true if the entity should be considered for collision, false otherwise.