Class WorldBorder

java.lang.Object
net.minestom.server.instance.WorldBorder

public class WorldBorder extends Object
Represents the world border of an Instance, can be retrieved with Instance.getWorldBorder().
  • Constructor Details

    • WorldBorder

      protected WorldBorder(@NotNull @NotNull Instance instance)
  • Method Details

    • setCenter

      public void setCenter(float centerX, float centerZ)
      Changes the X and Z position of the center.
      Parameters:
      centerX - the X center
      centerZ - 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 to diameter in speed milliseconds (interpolation).
      Parameters:
      diameter - the diameter target
      speed - the time it will take to reach diameter 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

      @NotNull public @NotNull WorldBorder.CollisionAxis getCollisionAxis(@NotNull @NotNull Point point)
      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

      public boolean isInside(@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
    • isInside

      public boolean isInside(@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
    • update

      protected void update()
      Used to update in real-time the current diameter time. Called in the instance tick update.
    • init

      @Internal public void init(@NotNull @NotNull Player player)
      Sends the world border init packet to a player.
      Parameters:
      player - the player to send the packet to
    • getInstance

      @NotNull public @NotNull Instance getInstance()
      Gets the Instance linked to this world border.
      Returns:
      the Instance of this world border