Package net.minestom.server.instance
Class WorldBorder
java.lang.Object
net.minestom.server.instance.WorldBorder
Represents the world border of an
Instance
,
can be retrieved with Instance.getWorldBorder()
.-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfloat
Gets the center X of the world border.float
Gets the center Z of the world border.@NotNull WorldBorder.CollisionAxis
getCollisionAxis
(@NotNull Point point) Used to check at which axis does the position collides with the world border.double
Gets the diameter of the world border.@NotNull Instance
Gets theInstance
linked to this world border.int
int
void
Sends the world border init packet to a player.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.void
setCenter
(float centerX, float centerZ) Changes the X and Z position of the center.void
setCenterX
(float centerX) Changes the center X of the world border.void
setCenterZ
(float centerZ) Changes the center Z of the world border.void
setDiameter
(double diameter) Changes the diameter of the world border.void
setDiameter
(double diameter, long speed) Changes the diameter todiameter
inspeed
milliseconds (interpolation).void
setWarningBlocks
(int warningBlocks) void
setWarningTime
(int warningTime) protected void
update()
Used to update in real-time the current diameter time.
-
Constructor Details
-
WorldBorder
-
-
Method Details
-
setCenter
public void setCenter(float centerX, float centerZ) Changes the X and Z position of the center.- Parameters:
centerX
- the X centercenterZ
- the Z center
-
getCenterX
public float getCenterX()Gets the center X of the world border.- Returns:
- the X center
-
setCenterX
public void setCenterX(float centerX) Changes the center X of the world border.- Parameters:
centerX
- the new center X
-
getCenterZ
public float getCenterZ()Gets the center Z of the world border.- Returns:
- the Z center
-
setCenterZ
public void setCenterZ(float centerZ) Changes the center Z of the world border.- Parameters:
centerZ
- the new center Z
-
getWarningTime
public int getWarningTime() -
setWarningTime
public void setWarningTime(int warningTime) - Parameters:
warningTime
- In seconds as /worldborder warning time
-
getWarningBlocks
public int getWarningBlocks() -
setWarningBlocks
public void setWarningBlocks(int warningBlocks) - Parameters:
warningBlocks
- In meters
-
setDiameter
public void setDiameter(double diameter, long speed) Changes the diameter todiameter
inspeed
milliseconds (interpolation).- Parameters:
diameter
- the diameter targetspeed
- the time it will take to reachdiameter
in milliseconds
-
getDiameter
public double getDiameter()Gets the diameter of the world border. It takes lerp in consideration.- Returns:
- the current world border diameter
-
setDiameter
public void setDiameter(double diameter) Changes the diameter of the world border.- Parameters:
diameter
- the new diameter of the world border
-
getCollisionAxis
Used to check at which axis does the position collides with the world border.- Parameters:
point
- the point to check- Returns:
- the axis where the position collides with the world border
-
isInside
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
-
isInside
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
-
update
protected void update()Used to update in real-time the current diameter time. Called in the instance tick update. -
init
Sends the world border init packet to a player.- Parameters:
player
- the player to send the packet to
-
getInstance
Gets theInstance
linked to this world border.- Returns:
- the
Instance
of this world border
-