Package net.minestom.server.instance
Record Class WorldBorder
java.lang.Object
java.lang.Record
net.minestom.server.instance.WorldBorder
- Record Components:
diameter
- the diameter of this world bordercenterX
- the center x coordinate of this world bordercenterZ
- the center z coordinate of this world borderwarningDistance
- the distance from this world border before the warning indicator is displayedwarningTime
- the length of time the warning indicator is displayeddimensionTeleportBoundary
- 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 Summary
-
Constructor Summary
ConstructorDescriptionWorldBorder
(double diameter, double centerX, double centerZ, int warningDistance, int warningTime) WorldBorder
(double diameter, double centerX, double centerZ, int warningDistance, int warningTime, int dimensionTeleportBoundary) Creates an instance of aWorldBorder
record class. -
Method Summary
Modifier and TypeMethodDescriptiondouble
centerX()
Returns the value of thecenterX
record component.double
centerZ()
Returns the value of thecenterZ
record component.@NotNull WorldBorderCenterPacket
Creates aWorldBorderSizePacket
which dictates the origin of the world border.@NotNull InitializeWorldBorderPacket
createInitializePacket
(double targetDiameter, long transitionTime) Creates aInitializeWorldBorderPacket
which dictates every property of the world border.@NotNull WorldBorderLerpSizePacket
createLerpSizePacket
(double targetDiameter, long transitionTime) Creates aWorldBorderLerpSizePacket
which lerps the border from its current diameter to the target diameter over the given transition time.@NotNull WorldBorderSizePacket
Creates aWorldBorderSizePacket
with this world border's diameter.@NotNull WorldBorderWarningDelayPacket
Creates aWorldBorderWarningDelayPacket
with this world border's warning time@NotNull WorldBorderWarningReachPacket
Creates aWorldBorderWarningReachPacket
with this world border's warning distancedouble
diameter()
Returns the value of thediameter
record component.int
Returns the value of thedimensionTeleportBoundary
record component.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.boolean
Used to know if a position is located inside the world border or not.boolean
Used to know if an entity is located inside the world border or not.final String
toString()
Returns a string representation of this record class.int
Returns the value of thewarningDistance
record component.int
Returns the value of thewarningTime
record component.@NotNull WorldBorder
withCenter
(double centerX, double centerZ) @NotNull WorldBorder
withDiameter
(double diameter) @NotNull WorldBorder
withWarningDistance
(int warningDistance) @NotNull WorldBorder
withWarningTime
(int warningTime)
-
Field Details
-
DEFAULT_BORDER
-
-
Constructor Details
-
WorldBorder
public WorldBorder(double diameter, double centerX, double centerZ, int warningDistance, int warningTime, int dimensionTeleportBoundary) Creates an instance of aWorldBorder
record class.- Parameters:
diameter
- the value for thediameter
record componentcenterX
- the value for thecenterX
record componentcenterZ
- the value for thecenterZ
record componentwarningDistance
- the value for thewarningDistance
record componentwarningTime
- the value for thewarningTime
record componentdimensionTeleportBoundary
- the value for thedimensionTeleportBoundary
record component
-
WorldBorder
public WorldBorder(double diameter, double centerX, double centerZ, int warningDistance, int warningTime)
-
-
Method Details
-
withDiameter
-
withCenter
@Contract(pure=true) @NotNull public @NotNull WorldBorder withCenter(double centerX, double centerZ) -
withWarningDistance
-
withWarningTime
-
inBounds
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
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 aInitializeWorldBorderPacket
which dictates every property of the world border.- Parameters:
targetDiameter
- the target diameter if there is a current lerp in progresstransitionTime
- the transition time in milliseconds of the current lerp in progress- Returns:
- an
InitializeWorldBorderPacket
reflecting the properties of this border
-
createCenterPacket
Creates aWorldBorderSizePacket
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 aWorldBorderLerpSizePacket
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 transitiontransitionTime
- the transition time in milliseconds for this lerp- Returns:
- the
WorldBorderLerpSizePacket
representing this lerp
-
createSizePacket
Creates aWorldBorderSizePacket
with this world border's diameter.- Returns:
- the
WorldBorderSizePacket
with this world border's diameter
-
createWarningDelayPacket
Creates aWorldBorderWarningDelayPacket
with this world border's warning time- Returns:
- the
WorldBorderWarningDelayPacket
with this world border's warning time
-
createWarningReachPacket
Creates aWorldBorderWarningReachPacket
with this world border's warning distance- Returns:
- the
WorldBorderWarningReachPacket
with this world border's warning distance
-
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. -
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. -
equals
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 '=='. -
diameter
public double diameter()Returns the value of thediameter
record component.- Returns:
- the value of the
diameter
record component
-
centerX
public double centerX()Returns the value of thecenterX
record component.- Returns:
- the value of the
centerX
record component
-
centerZ
public double centerZ()Returns the value of thecenterZ
record component.- Returns:
- the value of the
centerZ
record component
-
warningDistance
public int warningDistance()Returns the value of thewarningDistance
record component.- Returns:
- the value of the
warningDistance
record component
-
warningTime
public int warningTime()Returns the value of thewarningTime
record component.- Returns:
- the value of the
warningTime
record component
-
dimensionTeleportBoundary
public int dimensionTeleportBoundary()Returns the value of thedimensionTeleportBoundary
record component.- Returns:
- the value of the
dimensionTeleportBoundary
record component
-