Class Chunk

java.lang.Object
com.welcome234.pluginsystem.Chunk

public class Chunk extends Object
Represents a world chunk
  • Method Summary

    Modifier and Type
    Method
    Description
    getBiome​(int x)
    Gets the current biome for the specified chunk coordinates.
    getBlock​(int x, int y)
    Gets the current block for the specified chunk coordinates.
    Gets all alive and loaded entities in this chunk.
    getSign​(int x, int y)
    Gets the sign text for the specified chunk coordinates.
    int
    Gets the current X-coordinate of this chunk
    boolean
    Gets whether the chunk is in the end dimension
    boolean
    Gets if the chunk is loaded
    boolean
    Gets whether this chunk is loaded by a player
    void
    Loads the chunk
    void
    setBiome​(int x, Biome biome)
    Sets the current biome for the specified chunk coordinates.
    void
    setBlock​(int x, int y, Block block)
    Sets the current block for the specified chunk coordinates.
    void
    setSign​(int x, int y, String message)
    Sets the sign text for the specified chunk coordinates.
    void
    Unloads the chunk

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • isLoaded

      public boolean isLoaded()
      Gets if the chunk is loaded
      Returns:
      Whether chunk is loaded
    • isPlayerLoaded

      public boolean isPlayerLoaded()
      Gets whether this chunk is loaded by a player
      Returns:
      Whether player loaded
      Throws:
      IllegalStateException - if chunk is not loaded
    • getX

      public int getX()
      Gets the current X-coordinate of this chunk
      Returns:
      X-coordinate position
    • isInEnd

      public boolean isInEnd()
      Gets whether the chunk is in the end dimension
      Returns:
      Whether in end dimension
    • setBlock

      public void setBlock(int x, int y, Block block)
      Sets the current block for the specified chunk coordinates.
      Parameters:
      x - Chunk X-coordinate of this block
      y - Chunk Y-coordinate of this block
      block - Block type to set
      Throws:
      IllegalArgumentException - if block position is outside chunk bounds
      IllegalStateException - if chunk is not loaded
      IllegalArgumentException - if block is null
    • getBlock

      public Block getBlock(int x, int y)
      Gets the current block for the specified chunk coordinates.
      Parameters:
      x - Chunk X-coordinate of this block
      y - Chunk Y-coordinate of this block
      Returns:
      Block type for this position
      Throws:
      IllegalArgumentException - if block position is outside chunk bounds
      IllegalStateException - if chunk is not loaded
    • setSign

      public void setSign(int x, int y, String message)
      Sets the sign text for the specified chunk coordinates.
      Parameters:
      x - Chunk X-coordinate of this sign
      y - Chunk Y-coordinate of this sign
      message - Sign message to set
      Throws:
      IllegalArgumentException - if the block is not a sign
      IllegalArgumentException - if block position is outside chunk bounds
      IllegalStateException - if chunk is not loaded
      IllegalArgumentException - if message is null
    • getSign

      public String getSign(int x, int y)
      Gets the sign text for the specified chunk coordinates.
      Parameters:
      x - Chunk X-coordinate of this sign
      y - Chunk Y-coordinate of this sign
      Returns:
      Sign message on this sign
      Throws:
      IllegalArgumentException - if the block is not a sign
      IllegalArgumentException - if block position is outside chunk bounds
      IllegalStateException - if chunk is not loaded
    • setBiome

      public void setBiome(int x, Biome biome)
      Sets the current biome for the specified chunk coordinates.

      Biomes changes only update after a players chunk reloads.

      Parameters:
      x - Chunk X-coordinate of this biome
      biome - Biome type to set
      Throws:
      IllegalArgumentException - if block position is outside chunk bounds
      IllegalStateException - if chunk is not loaded
      IllegalArgumentException - if biome is null
    • getBiome

      public Biome getBiome(int x)
      Gets the current biome for the specified chunk coordinates.
      Parameters:
      x - Chunk X-coordinate of this block
      Returns:
      Biome type for this position
      Throws:
      IllegalArgumentException - if block position is outside chunk bounds
      IllegalStateException - if chunk is not loaded
    • getEntities

      public ArrayList<Entity> getEntities()
      Gets all alive and loaded entities in this chunk.
      Returns:
      Array list of loaded entities
      Throws:
      IllegalStateException - if chunk is not loaded
    • load

      public void load()
      Loads the chunk

      The chunk will remain always loaded until unloaded by a plugin

    • unload

      public void unload()
      Unloads the chunk
      Throws:
      IllegalStateException - if chunk is not loaded