Class CollisionUtils

java.lang.Object
net.minestom.server.collision.CollisionUtils

@Internal @Experimental public final class CollisionUtils extends Object
  • Constructor Details

    • CollisionUtils

      public CollisionUtils()
  • Method Details

    • handlePhysics

      public static PhysicsResult handlePhysics(@NotNull @NotNull Entity entity, @NotNull @NotNull Vec entityVelocity, @Nullable @Nullable PhysicsResult lastPhysicsResult)
      Moves an entity with physics applied (ie checking against blocks)

      Works by getting all the full blocks that an entity could interact with. All bounding boxes inside the full blocks are checked for collisions with the entity.

      Parameters:
      entity - the entity to move
      Returns:
      the result of physics simulation
    • handlePhysics

      public static PhysicsResult handlePhysics(@NotNull @NotNull Instance instance, @Nullable @Nullable Chunk chunk, @NotNull @NotNull BoundingBox boundingBox, @NotNull @NotNull Pos position, @NotNull @NotNull Vec velocity, @Nullable @Nullable PhysicsResult lastPhysicsResult)
      Moves bounding box with physics applied (ie checking against blocks)

      Works by getting all the full blocks that a bounding box could interact with. All bounding boxes inside the full blocks are checked for collisions with the given bounding box.

      Parameters:
      boundingBox - the bounding box to move
      Returns:
      the result of physics simulation
    • isLineOfSightReachingShape

      public static boolean isLineOfSightReachingShape(@NotNull @NotNull Instance instance, @Nullable @Nullable Chunk chunk, @NotNull @NotNull Point start, @NotNull @NotNull Point end, @NotNull @NotNull Shape shape)
      Checks whether shape is reachable by the given line of sight (ie there are no blocks colliding with it).
      Parameters:
      instance - the instance.
      chunk - optional chunk reference for speedup purposes.
      start - start of the line of sight.
      end - end of the line of sight.
      shape - shape to check.
      Returns:
      true is shape is reachable by the given line of sight; false otherwise.
    • handlePhysics

      public static PhysicsResult handlePhysics(@NotNull @NotNull Entity entity, @NotNull @NotNull Vec entityVelocity)
    • canPlaceBlockAt

      public static Entity canPlaceBlockAt(Instance instance, Point blockPos, Block b)
    • applyWorldBorder

      @NotNull public static @NotNull Pos applyWorldBorder(@NotNull @NotNull Instance instance, @NotNull @NotNull Pos currentPosition, @NotNull @NotNull Pos newPosition)
      Applies world border collision.
      Parameters:
      instance - the instance where the world border is
      currentPosition - the current position
      newPosition - the future target position
      Returns:
      the position with the world border collision applied (can be newPosition if not changed)
    • parseBlockShape

      public static Shape parseBlockShape(String str, Registry.BlockEntry blockEntry)