Record Class WorldBorder

java.lang.Object
java.lang.Record
net.minestom.server.instance.WorldBorder
Record Components:
diameter - the diameter of this world border
centerX - the center x coordinate of this world border
centerZ - the center z coordinate of this world border
warningDistance - the distance from this world border before the warning indicator is displayed
warningTime - the length of time the warning indicator is displayed
dimensionTeleportBoundary - restricts the distance travelled when entering this world from another dimension (should be at least the diameter of the world border)

public record WorldBorder(double diameter, double centerX, double centerZ, int warningDistance, int warningTime, int dimensionTeleportBoundary) extends Record
Represents the world border state of an Instance, can be retrieved with Instance.getWorldBorder().
  • Field Details

    • DEFAULT_BORDER

      public static final WorldBorder DEFAULT_BORDER
  • Constructor Details

    • WorldBorder

      public WorldBorder(double diameter, double centerX, double centerZ, int warningDistance, int warningTime, int dimensionTeleportBoundary)
      Creates an instance of a WorldBorder record class.
      Parameters:
      diameter - the value for the diameter record component
      centerX - the value for the centerX record component
      centerZ - the value for the centerZ record component
      warningDistance - the value for the warningDistance record component
      warningTime - the value for the warningTime record component
      dimensionTeleportBoundary - the value for the dimensionTeleportBoundary record component
    • WorldBorder

      public WorldBorder(double diameter, double centerX, double centerZ, int warningDistance, int warningTime)
  • Method Details

    • withDiameter

      @Contract(pure=true) @NotNull public @NotNull WorldBorder withDiameter(double diameter)
    • withCenter

      @Contract(pure=true) @NotNull public @NotNull WorldBorder withCenter(double centerX, double centerZ)
    • withWarningDistance

      @Contract(pure=true) @NotNull public @NotNull WorldBorder withWarningDistance(int warningDistance)
    • withWarningTime

      @Contract(pure=true) @NotNull public @NotNull WorldBorder withWarningTime(int warningTime)
    • inBounds

      public boolean inBounds(@NotNull @NotNull Point point)
      Used to know if a position is located inside the world border or not.
      Parameters:
      point - the point to check
      Returns:
      true if position is inside the world border, false otherwise
    • inBounds

      public boolean inBounds(@NotNull @NotNull Entity entity)
      Used to know if an entity is located inside the world border or not.
      Parameters:
      entity - the entity to check
      Returns:
      true if entity is inside the world border, false otherwise
    • createInitializePacket

      @NotNull public @NotNull InitializeWorldBorderPacket createInitializePacket(double targetDiameter, long transitionTime)
      Creates a InitializeWorldBorderPacket which dictates every property of the world border.
      Parameters:
      targetDiameter - the target diameter if there is a current lerp in progress
      transitionTime - the transition time in milliseconds of the current lerp in progress
      Returns:
      an InitializeWorldBorderPacket reflecting the properties of this border
    • createCenterPacket

      @NotNull public @NotNull WorldBorderCenterPacket createCenterPacket()
      Creates a WorldBorderSizePacket which dictates the origin of the world border.
      Returns:
      the WorldBorderSizePacket with the center values of this world border
    • createLerpSizePacket

      @NotNull public @NotNull WorldBorderLerpSizePacket createLerpSizePacket(double targetDiameter, long transitionTime)
      Creates a WorldBorderLerpSizePacket which lerps the border from its current diameter to the target diameter over the given transition time.
      Parameters:
      targetDiameter - the final diameter of the border after this transition
      transitionTime - the transition time in milliseconds for this lerp
      Returns:
      the WorldBorderLerpSizePacket representing this lerp
    • createSizePacket

      @NotNull public @NotNull WorldBorderSizePacket createSizePacket()
      Creates a WorldBorderSizePacket with this world border's diameter.
      Returns:
      the WorldBorderSizePacket with this world border's diameter
    • createWarningDelayPacket

      @NotNull public @NotNull WorldBorderWarningDelayPacket createWarningDelayPacket()
      Creates a WorldBorderWarningDelayPacket with this world border's warning time
      Returns:
      the WorldBorderWarningDelayPacket with this world border's warning time
    • createWarningReachPacket

      @NotNull public @NotNull WorldBorderWarningReachPacket createWarningReachPacket()
      Creates a WorldBorderWarningReachPacket with this world border's warning distance
      Returns:
      the WorldBorderWarningReachPacket with this world border's warning distance
    • 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 '=='.
      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.
    • diameter

      public double diameter()
      Returns the value of the diameter record component.
      Returns:
      the value of the diameter record component
    • centerX

      public double centerX()
      Returns the value of the centerX record component.
      Returns:
      the value of the centerX record component
    • centerZ

      public double centerZ()
      Returns the value of the centerZ record component.
      Returns:
      the value of the centerZ record component
    • warningDistance

      public int warningDistance()
      Returns the value of the warningDistance record component.
      Returns:
      the value of the warningDistance record component
    • warningTime

      public int warningTime()
      Returns the value of the warningTime record component.
      Returns:
      the value of the warningTime record component
    • dimensionTeleportBoundary

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