Class BlockIterator

java.lang.Object
net.minestom.server.utils.block.BlockIterator
All Implemented Interfaces:
Iterator<Point>

public class BlockIterator extends Object implements Iterator<Point>
This class performs ray tracing and iterates along blocks on a line
  • Constructor Details

    • BlockIterator

      public BlockIterator(@NotNull @NotNull Vec start, @NotNull @NotNull Vec direction, double yOffset, double maxDistance, boolean smooth)
      Constructs the BlockIterator.

      This considers all blocks as 1x1x1 in size.

      Parameters:
      start - A Vector giving the initial position for the trace
      direction - A Vector pointing in the direction for the trace
      yOffset - The trace begins vertically offset from the start vector by this value
      maxDistance - This is the maximum distance in blocks for the trace. Setting this value above 140 may lead to problems with unloaded chunks. A value of 0 indicates no limit
      smooth - A boolean indicating whether the cast should be smooth. Smooth casts will only include one block when intersecting multiple axis lines.
    • BlockIterator

      public BlockIterator(@NotNull @NotNull Vec start, @NotNull @NotNull Vec direction, double yOffset, double maxDistance)
      Constructs the BlockIterator.

      This considers all blocks as 1x1x1 in size.

      Parameters:
      start - A Vector giving the initial position for the trace
      direction - A Vector pointing in the direction for the trace
      yOffset - The trace begins vertically offset from the start vector by this value
      maxDistance - This is the maximum distance in blocks for the trace. Setting this value above 140 may lead to problems with unloaded chunks. A value of 0 indicates no limit
    • BlockIterator

      public BlockIterator(@NotNull @NotNull Pos pos, double yOffset, int maxDistance)
      Constructs the BlockIterator.

      This considers all blocks as 1x1x1 in size.

      Parameters:
      pos - The position for the start of the ray trace
      yOffset - The trace begins vertically offset from the start vector by this value
      maxDistance - This is the maximum distance in blocks for the trace. Setting this value above 140 may lead to problems with unloaded chunks. A value of 0 indicates no limit
    • BlockIterator

      public BlockIterator(@NotNull @NotNull Pos pos, double yOffset)
      Constructs the BlockIterator.

      This considers all blocks as 1x1x1 in size.

      Parameters:
      pos - The position for the start of the ray trace
      yOffset - The trace begins vertically offset from the start vector by this value
    • BlockIterator

      public BlockIterator(@NotNull @NotNull Pos pos)
      Constructs the BlockIterator.

      This considers all blocks as 1x1x1 in size.

      Parameters:
      pos - The position for the start of the ray trace
    • BlockIterator

      public BlockIterator(@NotNull @NotNull Entity entity, int maxDistance)
      Constructs the BlockIterator.

      This considers all blocks as 1x1x1 in size.

      Parameters:
      entity - Information from the entity is used to set up the trace
      maxDistance - This is the maximum distance in blocks for the trace. Setting this value above 140 may lead to problems with unloaded chunks. A value of 0 indicates no limit
    • BlockIterator

      public BlockIterator(@NotNull @NotNull Entity entity)
      Constructs the BlockIterator.

      This considers all blocks as 1x1x1 in size.

      Parameters:
      entity - Information from the entity is used to set up the trace
  • Method Details

    • hasNext

      public boolean hasNext()
      Returns true if the iteration has more elements
      Specified by:
      hasNext in interface Iterator<Point>
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator<Point>
    • next

      public Point next()
      Returns the next BlockPosition in the trace
      Specified by:
      next in interface Iterator<Point>
      Returns:
      the next BlockPosition in the trace