Record Class PointRange2D

java.lang.Object
java.lang.Record
dev.wyck.misc.PointRange2D

@NullMarked @AsOf("0.0.1") public record PointRange2D(int minX, int maxX, int minZ, int maxZ) extends Record
Represents a 2D range of points in a Minecraft world. The range is defined by minimum and maximum X and Z coordinates.
Since:
0.0.1
  • Constructor Summary

    Constructors
    Constructor
    Description
    PointRange2D(int minX, int maxX, int minZ, int maxZ)
    Creates an instance of a PointRange2D record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the maximum location within the range.
    Returns the minimum location within the range.
    final int
    Returns a hash code value for this object.
    int
    Returns the value of the maxX record component.
    int
    Returns the value of the maxZ record component.
    int
    Returns the value of the minX record component.
    int
    Returns the value of the minZ record component.
    of(Location from, Location to)
    Creates a new PointRange2D from two given locations.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • PointRange2D

      public PointRange2D(int minX, int maxX, int minZ, int maxZ)
      Creates an instance of a PointRange2D record class.
      Parameters:
      minX - the value for the minX record component
      maxX - the value for the maxX record component
      minZ - the value for the minZ record component
      maxZ - the value for the maxZ record component
  • Method Details

    • of

      @AsOf("0.0.1") public static PointRange2D of(Location from, Location to)
      Creates a new PointRange2D from two given locations. The minimum and maximum X and Z coordinates are calculated from the given locations.
      Parameters:
      from - The first location.
      to - The second location.
      Returns:
      A new PointRange2D that spans from the minimum to the maximum coordinates of the given locations.
      Since:
      0.0.1
    • getMinLocation

      @AsOf("0.0.2") public Location getMinLocation(World world)
      Returns the minimum location within the range. The minimum location is defined by the minimum X and Z coordinates. The Y coordinate is always 0.
      Parameters:
      world - The world in which the location is.
      Returns:
      The minimum location within the range.
      Since:
      0.0.2
    • getMaxLocation

      @AsOf("0.0.2") public Location getMaxLocation(World world)
      Returns the maximum location within the range. The maximum location is defined by the maximum X and Z coordinates. The Y coordinate is always 0.
      Parameters:
      world - The world in which the location is.
      Returns:
      The maximum location within the range.
      Since:
      0.0.2
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • minX

      public int minX()
      Returns the value of the minX record component.
      Returns:
      the value of the minX record component
    • maxX

      public int maxX()
      Returns the value of the maxX record component.
      Returns:
      the value of the maxX record component
    • minZ

      public int minZ()
      Returns the value of the minZ record component.
      Returns:
      the value of the minZ record component
    • maxZ

      public int maxZ()
      Returns the value of the maxZ record component.
      Returns:
      the value of the maxZ record component