Class BlockCollisionProvider

java.lang.Object
com.hypixel.hytale.server.core.modules.collision.BlockCollisionProvider
All Implemented Interfaces:
BoxBlockIterator.BoxIterationConsumer

public class BlockCollisionProvider extends Object implements BoxBlockIterator.BoxIterationConsumer
Provider for collisions with world blocks.

A collider is cast into the world from a given start position along a vector. Potential block collisions, trigger events and damages are reported to caller using a IBlockCollisionConsumer instance. A block with filler blocks is only processed once per call. For each trigger exactly one of the trigger event callbacks is executed. Current active triggers are passed and updated using a provided IBlockTracker instance.

Collision contacts are not sorted by distance and are delivered in order as returned by BoxBlockIterator.

Collision processing can be terminated when a final collision is detected using any of the methods in IBlockCollisionConsumer returning a IBlockCollisionConsumer.Result.

Notes: - For solid and empty blocks the damage, trigger and collision boxes are the block bounding boxes. - For fluid blocks trigger boxes are defined by the block bounding boxes. Damage and collisions are computed using the unit box with height vertical fill level. - Submerged fluid is processed as fluid block but no trigger block processing is performed. - A single block can cause collisions with multiple materials (e.g. submerged blocks) - A single block can report damage twice for the block and the submerge fluid - Collision with empty collision material is not reported when the empty space is part of a solid or fluid block (complexity of computing the empty sub-boxes)

Since:
2020-06-25
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    accept(long x, long y, long z)
    Called by the algorithm to report a block that is being hit by the AABB on the given direction.
    void
    cast(World world, Box collider, org.joml.Vector3d pos, org.joml.Vector3d v, IBlockCollisionConsumer collisionConsumer, IBlockTracker activeTriggers, double collisionStop)
    Cast a box collider and report block collisions, triggers and damage.
    boolean
    Called when the current iteration step is done and the next block to hit is further away.
    void
    setReportOverlaps(boolean reportOverlaps)
    Enable or disable reporting of overlapping blocks.
    void
    setRequestedCollisionMaterials(int requestedCollisionMaterials)
     

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BlockCollisionProvider

      public BlockCollisionProvider()
  • Method Details

    • setRequestedCollisionMaterials

      public void setRequestedCollisionMaterials(int requestedCollisionMaterials)
    • setReportOverlaps

      public void setReportOverlaps(boolean reportOverlaps)
      Enable or disable reporting of overlapping blocks.

      Normally overlapping blocks are ignored. But for moving out of solid blocks or searching for jump landing positions they need to be reported.

      Parameters:
      reportOverlaps - True to report overlapping blocks else ignore them.
    • next

      public boolean next()
      Description copied from interface: BoxBlockIterator.BoxIterationConsumer
      Called when the current iteration step is done and the next block to hit is further away.
      Specified by:
      next in interface BoxBlockIterator.BoxIterationConsumer
      Returns:
      TRUE if iteration should continue
    • accept

      public boolean accept(long x, long y, long z)
      Description copied from interface: BoxBlockIterator.BoxIterationConsumer
      Called by the algorithm to report a block that is being hit by the AABB on the given direction.
      Specified by:
      accept in interface BoxBlockIterator.BoxIterationConsumer
      Parameters:
      x - X-Coordinate of block
      y - Y-Coordinate of block
      z - Z-Coordinate of block
      Returns:
      TRUE if iteration should continue
    • cast

      public void cast(@Nonnull World world, @Nonnull Box collider, @Nonnull org.joml.Vector3d pos, @Nonnull org.joml.Vector3d v, @Nonnull IBlockCollisionConsumer collisionConsumer, @Nonnull IBlockTracker activeTriggers, double collisionStop)
      Cast a box collider and report block collisions, triggers and damage.
      Parameters:
      world - World
      collider - Box used as collider
      pos - Start position for box
      v - Vector along the box is cast
      collisionConsumer - Instance to receive collision, trigger and damage events
      activeTriggers - IBlockTracker storing currently active trigger block
      collisionStop - Relative distance factor to v to stop processing (between 0 and 1)