Record Class DimensionLink

java.lang.Object
java.lang.Record
tech.anonymoushacker1279.openportals.portal.linking.DimensionLink
Record Components:
pos1 - The first portal position.
pos2 - The second portal position.

public record DimensionLink(DimensionalBlockPos pos1, DimensionalBlockPos pos2) extends Record
Represents a bidirectional link between two portal positions. The link works in both directions - you can travel from pos1 to pos2, or from pos2 to pos1.
  • Field Details

    • CODEC

      public static final com.mojang.serialization.Codec<DimensionLink> CODEC
  • Constructor Details

    • DimensionLink

      public DimensionLink(DimensionalBlockPos pos1, DimensionalBlockPos pos2)
      Creates an instance of a DimensionLink record class.
      Parameters:
      pos1 - the value for the pos1 record component
      pos2 - the value for the pos2 record component
  • Method Details

    • connects

      public boolean connects(DimensionalBlockPos position)
      Check if this link connects the given position.
      Parameters:
      position - the position to check
      Returns:
      true if this link connects to the given position
    • getDestination

      @Nullable public @Nullable DimensionalBlockPos getDestination(DimensionalBlockPos source)
      Get the destination for the given source position. If the source is pos1, returns pos2. If the source is pos2, returns pos1.
      Parameters:
      source - the source position
      Returns:
      the destination position, or null if source doesn't match either end
    • 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 Objects::equals(Object,Object).
      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.
    • pos1

      public DimensionalBlockPos pos1()
      Returns the value of the pos1 record component.
      Returns:
      the value of the pos1 record component
    • pos2

      public DimensionalBlockPos pos2()
      Returns the value of the pos2 record component.
      Returns:
      the value of the pos2 record component