Class BlockIterator

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

public class BlockIterator extends Object implements Iterator<net.minestom.server.coordinate.Point>
This class performs ray tracing and iterates along blocks on a line
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    BlockIterator(@NotNull net.minestom.server.coordinate.Pos pos)
    Constructs the BlockIterator.
    BlockIterator(@NotNull net.minestom.server.coordinate.Pos pos, double yOffset)
    Constructs the BlockIterator.
    BlockIterator(@NotNull net.minestom.server.coordinate.Pos pos, double yOffset, int maxDistance)
    Constructs the BlockIterator.
    BlockIterator(@NotNull net.minestom.server.coordinate.Vec start, @NotNull net.minestom.server.coordinate.Vec direction, double yOffset, double maxDistance)
    Constructs the BlockIterator.
    BlockIterator(@NotNull net.minestom.server.coordinate.Vec start, @NotNull net.minestom.server.coordinate.Vec direction, double yOffset, double maxDistance, boolean smooth)
    Constructs the BlockIterator.
    BlockIterator(@NotNull Entity entity)
    Constructs the BlockIterator.
    BlockIterator(@NotNull Entity entity, int maxDistance)
    Constructs the BlockIterator.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if the iteration has more elements
    net.minestom.server.coordinate.Point
    Returns the next BlockPosition in the trace
    void
     
    void
    reset(@NotNull net.minestom.server.coordinate.Vec start, @NotNull net.minestom.server.coordinate.Vec direction, double yOffset, double maxDistance, boolean smooth)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.Iterator

    forEachRemaining
  • Constructor Details

    • BlockIterator

      public BlockIterator(@NotNull @NotNull net.minestom.server.coordinate.Vec start, @NotNull @NotNull net.minestom.server.coordinate.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()
    • BlockIterator

      public BlockIterator(@NotNull @NotNull net.minestom.server.coordinate.Vec start, @NotNull @NotNull net.minestom.server.coordinate.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 net.minestom.server.coordinate.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 net.minestom.server.coordinate.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 net.minestom.server.coordinate.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

    • reset

      public void reset(@NotNull @NotNull net.minestom.server.coordinate.Vec start, @NotNull @NotNull net.minestom.server.coordinate.Vec direction, double yOffset, double maxDistance, boolean smooth)
    • hasNext

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

      public void remove()
      Specified by:
      remove in interface Iterator<net.minestom.server.coordinate.Point>
    • next

      public net.minestom.server.coordinate.Point next()
      Returns the next BlockPosition in the trace
      Specified by:
      next in interface Iterator<net.minestom.server.coordinate.Point>
      Returns:
      the next BlockPosition in the trace