Class WorldBorder

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

public class WorldBorder
extends java.lang.Object
Represents the world border of an Instance, can be retrieved with Instance.getWorldBorder().
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static class  WorldBorder.CollisionAxis  
  • Constructor Summary

    Constructors 
    Modifier Constructor Description
    protected WorldBorder​(Instance instance)  
  • Method Summary

    Modifier and Type Method Description
    float getCenterX()
    Gets the center X of the world border.
    float getCenterZ()
    Gets the center Z of the world border.
    WorldBorder.CollisionAxis getCollisionAxis​(Position position)
    Used to check at which axis does the position collides with the world border.
    double getDiameter()
    Gets the diameter of the world border.
    Instance getInstance()
    Gets the Instance linked to this world border.
    int getWarningBlocks()  
    int getWarningTime()  
    protected void init​(Player player)
    Sends the world border init packet to a player.
    boolean isInside​(Entity entity)
    Used to know if an entity is located inside the world border or not.
    boolean isInside​(Position position)
    Used to know if a position 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 to diameter in speed milliseconds (interpolation).
    void setWarningBlocks​(int warningBlocks)  
    void setWarningTime​(int warningTime)  
    protected void update()
    Used to update in real-time the current diameter time.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • 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 WorldBorder.CollisionAxis getCollisionAxis​(@NotNull Position position)
      Used to check at which axis does the position collides with the world border.
      Parameters:
      position - the position to check
      Returns:
      the axis where the position collides with the world border
    • isInside

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

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

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

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