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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionWorldBorder(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 aWorldBorderrecord class. -
Method Summary
Modifier and TypeMethodDescriptiondoublecenterX()Returns the value of thecenterXrecord component.doublecenterZ()Returns the value of thecenterZrecord component.Creates aWorldBorderSizePacketwhich dictates the origin of the world border.createInitializePacket(double targetDiameter, long transitionTime) Creates aInitializeWorldBorderPacketwhich dictates every property of the world border.createLerpSizePacket(double targetDiameter, long transitionTime) Creates aWorldBorderLerpSizePacketwhich lerps the border from its current diameter to the target diameter over the given transition time.Creates aWorldBorderSizePacketwith this world border's diameter.Creates aWorldBorderWarningDelayPacketwith this world border's warning timeCreates aWorldBorderWarningReachPacketwith this world border's warning distancedoublediameter()Returns the value of thediameterrecord component.intReturns the value of thedimensionTeleportBoundaryrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanUsed to know if a position is located inside the world border or not.booleanUsed to know if an entity is located inside the world border or not.final StringtoString()Returns a string representation of this record class.intReturns the value of thewarningDistancerecord component.intReturns the value of thewarningTimerecord component.withCenter(double centerX, double centerZ) withDiameter(double diameter) withWarningDistance(int warningDistance) 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 aWorldBorderrecord class.- Parameters:
diameter- the value for thediameterrecord componentcenterX- the value for thecenterXrecord componentcenterZ- the value for thecenterZrecord componentwarningDistance- the value for thewarningDistancerecord componentwarningTime- the value for thewarningTimerecord componentdimensionTeleportBoundary- the value for thedimensionTeleportBoundaryrecord component
-
WorldBorder
public WorldBorder(double diameter, double centerX, double centerZ, int warningDistance, int warningTime)
-
-
Method Details
-
withDiameter
-
withCenter
-
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
positionis 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
entityis inside the world border, false otherwise
-
createInitializePacket
public InitializeWorldBorderPacket createInitializePacket(double targetDiameter, long transitionTime) Creates aInitializeWorldBorderPacketwhich 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
InitializeWorldBorderPacketreflecting the properties of this border
-
createCenterPacket
Creates aWorldBorderSizePacketwhich dictates the origin of the world border.- Returns:
- the
WorldBorderSizePacketwith the center values of this world border
-
createLerpSizePacket
Creates aWorldBorderLerpSizePacketwhich 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
WorldBorderLerpSizePacketrepresenting this lerp
-
createSizePacket
Creates aWorldBorderSizePacketwith this world border's diameter.- Returns:
- the
WorldBorderSizePacketwith this world border's diameter
-
createWarningDelayPacket
Creates aWorldBorderWarningDelayPacketwith this world border's warning time- Returns:
- the
WorldBorderWarningDelayPacketwith this world border's warning time
-
createWarningReachPacket
Creates aWorldBorderWarningReachPacketwith this world border's warning distance- Returns:
- the
WorldBorderWarningReachPacketwith this world border's warning distance
-
toString
-
hashCode
-
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 thecomparemethod from their corresponding wrapper classes. -
diameter
-
centerX
-
centerZ
-
warningDistance
public int warningDistance()Returns the value of thewarningDistancerecord component.- Returns:
- the value of the
warningDistancerecord component
-
warningTime
public int warningTime()Returns the value of thewarningTimerecord component.- Returns:
- the value of the
warningTimerecord component
-
dimensionTeleportBoundary
public int dimensionTeleportBoundary()Returns the value of thedimensionTeleportBoundaryrecord component.- Returns:
- the value of the
dimensionTeleportBoundaryrecord component
-