Class GlowChunk

java.lang.Object
net.glowstone.chunk.GlowChunk
All Implemented Interfaces:
org.bukkit.Chunk, org.bukkit.persistence.PersistentDataHolder

public class GlowChunk extends Object implements org.bukkit.Chunk
Represents a chunk of the map.
  • Field Details

    • WIDTH

      public static final int WIDTH
      The width of a chunk (x axis).
      See Also:
    • HEIGHT

      public static final int HEIGHT
      The height of a chunk (z axis).
      See Also:
    • DEPTH

      public static final int DEPTH
      The depth of a chunk (y axis).
      See Also:
    • SEC_DEPTH

      public static final int SEC_DEPTH
      The Y depth of a single chunk section.
      See Also:
    • SEC_COUNT

      public static final int SEC_COUNT
      The number of chunk sections in a single chunk column.
      See Also:
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getBlock

      @NotNull public @NotNull GlowBlock getBlock(int x, int y, int z)
      Specified by:
      getBlock in interface org.bukkit.Chunk
    • getEntities

      public org.bukkit.entity.Entity[] getEntities()
      Specified by:
      getEntities in interface org.bukkit.Chunk
    • getRawEntities

      public Collection<GlowEntity> getRawEntities()
    • getTileEntities

      @Deprecated public GlowBlockState[] getTileEntities()
      Deprecated.
      Specified by:
      getTileEntities in interface org.bukkit.Chunk
    • getTileEntities

      @NotNull public @NotNull org.bukkit.block.BlockState[] getTileEntities(boolean useSnapshot)
      Specified by:
      getTileEntities in interface org.bukkit.Chunk
    • getTileEntities

      @NotNull public @NotNull Collection<org.bukkit.block.BlockState> getTileEntities(@NotNull @NotNull Predicate<org.bukkit.block.Block> blockPredicate, boolean useSnapshot)
      Specified by:
      getTileEntities in interface org.bukkit.Chunk
    • getBlockEntities

      public GlowBlockState[] getBlockEntities()
      Returns the states of the block entities (e.g. container blocks) in this chunk.
      Returns:
      the states of the block entities in this chunk
    • getRawBlockEntities

      public Collection<BlockEntity> getRawBlockEntities()
    • isSlimeChunk

      public boolean isSlimeChunk()
      Formula taken from Minecraft Gamepedia. https://minecraft.gamepedia.com/Slime#.22Slime_chunks.22
      Specified by:
      isSlimeChunk in interface org.bukkit.Chunk
    • isForceLoaded

      public boolean isForceLoaded()
      Specified by:
      isForceLoaded in interface org.bukkit.Chunk
    • setForceLoaded

      public void setForceLoaded(boolean b)
      Specified by:
      setForceLoaded in interface org.bukkit.Chunk
    • addPluginChunkTicket

      public boolean addPluginChunkTicket(@NotNull @NotNull org.bukkit.plugin.Plugin plugin)
      Specified by:
      addPluginChunkTicket in interface org.bukkit.Chunk
    • removePluginChunkTicket

      public boolean removePluginChunkTicket(@NotNull @NotNull org.bukkit.plugin.Plugin plugin)
      Specified by:
      removePluginChunkTicket in interface org.bukkit.Chunk
    • getPluginChunkTickets

      @NotNull public @NotNull Collection<org.bukkit.plugin.Plugin> getPluginChunkTickets()
      Specified by:
      getPluginChunkTickets in interface org.bukkit.Chunk
    • contains

      public boolean contains(@NotNull @NotNull org.bukkit.block.data.BlockData block)
      Specified by:
      contains in interface org.bukkit.Chunk
    • getChunkSnapshot

      @NotNull public @NotNull GlowChunkSnapshot getChunkSnapshot()
      Specified by:
      getChunkSnapshot in interface org.bukkit.Chunk
    • getChunkSnapshot

      @NotNull public @NotNull GlowChunkSnapshot getChunkSnapshot(boolean includeMaxBlockY, boolean includeBiome, boolean includeBiomeTempRain)
      Specified by:
      getChunkSnapshot in interface org.bukkit.Chunk
    • isLoaded

      public boolean isLoaded()
      Specified by:
      isLoaded in interface org.bukkit.Chunk
    • load

      public boolean load()
      Specified by:
      load in interface org.bukkit.Chunk
    • load

      public boolean load(boolean generate)
      Specified by:
      load in interface org.bukkit.Chunk
    • unload

      public boolean unload()
      Specified by:
      unload in interface org.bukkit.Chunk
    • unload

      public boolean unload(boolean save)
      Specified by:
      unload in interface org.bukkit.Chunk
    • unload

      @Deprecated public boolean unload(boolean save, boolean safe)
      Deprecated.
    • initializeSections

      public void initializeSections(ChunkSection[] initSections)
      Initialize this chunk from the given sections.
      Parameters:
      initSections - The ChunkSections to use. Should have a length of 16.
    • createEntity

      @Deprecated public BlockEntity createEntity(int cx, int cy, int cz, int type)
      Deprecated.
      Uses ordinals in place of old integer IDs.
      If needed, create a new block entity at the given location.
      Parameters:
      cx - the X coordinate of the BlockEntity
      cy - the Y coordinate of the BlockEntity
      cz - the Z coordinate of the BlockEntity
      type - the type of BlockEntity
      Returns:
      The BlockEntity that was created.
    • createEntity

      public BlockEntity createEntity(int cx, int cy, int cz, org.bukkit.Material type)
      If needed, create a new block entity at the given location.
      Parameters:
      cx - the X coordinate of the BlockEntity
      cy - the Y coordinate of the BlockEntity
      cz - the Z coordinate of the BlockEntity
      type - the type of BlockEntity
      Returns:
      The BlockEntity that was created.
    • getEntity

      public BlockEntity getEntity(int x, int y, int z)
      Attempt to get the block entity located at the given coordinates.
      Parameters:
      x - The X coordinate.
      z - The Z coordinate.
      y - The Y coordinate.
      Returns:
      A GlowBlockState if the entity exists, or null otherwise.
    • getBlockData

      public org.bukkit.block.data.BlockData getBlockData(int x, int z, int y)
    • getType

      @Deprecated public int getType(int x, int z, int y)
      Deprecated.
      Removed in 1.13.
      Gets the type of a block within this chunk.
      Parameters:
      x - The X coordinate.
      z - The Z coordinate.
      y - The Y coordinate.
      Returns:
      The type.
      See Also:
    • setType

      public void setType(int x, int z, int y, org.bukkit.Material type)
      Sets the type of a block within this chunk.
      Parameters:
      x - The X coordinate.
      z - The Z coordinate.
      y - The Y coordinate.
      type - The type.
    • setType

      public void setType(int x, int z, int y, org.bukkit.block.data.BlockData blockData)
    • getMetaData

      public int getMetaData(int x, int z, int y)
      Gets the metadata of a block within this chunk.
      Parameters:
      x - The X coordinate.
      z - The Z coordinate.
      y - The Y coordinate.
      Returns:
      The metadata.
    • setMetaData

      @Deprecated public void setMetaData(int x, int z, int y, int metaData)
      Deprecated.
      Unused in 1.13+
      Sets the metadata of a block within this chunk.
      Parameters:
      x - The X coordinate.
      z - The Z coordinate.
      y - The Y coordinate.
      metaData - The metadata.
    • getSkyLight

      public byte getSkyLight(int x, int z, int y)
      Gets the sky light level of a block within this chunk.
      Parameters:
      x - The X coordinate.
      z - The Z coordinate.
      y - The Y coordinate.
      Returns:
      The sky light level.
    • setSkyLight

      public void setSkyLight(int x, int z, int y, int skyLight)
      Sets the sky light level of a block within this chunk.
      Parameters:
      x - The X coordinate.
      z - The Z coordinate.
      y - The Y coordinate.
      skyLight - The sky light level.
    • getBlockLight

      public byte getBlockLight(int x, int z, int y)
      Gets the block light level of a block within this chunk.
      Parameters:
      x - The X coordinate.
      z - The Z coordinate.
      y - The Y coordinate.
      Returns:
      The block light level.
    • setBlockLight

      public void setBlockLight(int x, int z, int y, int blockLight)
      Sets the block light level of a block within this chunk.
      Parameters:
      x - The X coordinate.
      z - The Z coordinate.
      y - The Y coordinate.
      blockLight - The block light level.
    • getBiome

      public int getBiome(int x, int z)
      Gets the biome of a column within this chunk.
      Parameters:
      x - The X coordinate.
      z - The Z coordinate.
      Returns:
      The biome.
    • setBiome

      public void setBiome(int x, int z, int biome)
      Sets the biome of a column within this chunk.
      Parameters:
      x - The X coordinate.
      z - The Z coordinate.
      biome - The biome.
    • setBiomes

      public void setBiomes(byte... newBiomes)
      Set the entire biome array of this chunk.
      Parameters:
      newBiomes - The biome array.
    • getHeight

      public int getHeight(int x, int z)
      Get the height map value of a column within this chunk.
      Parameters:
      x - The X coordinate.
      z - The Z coordinate.
      Returns:
      The height map value.
    • getRegionalDifficulty

      public double getRegionalDifficulty()
      Gets the regional difficulty for this chunk.
      Returns:
      the regional difficulty
    • getClampedRegionalDifficulty

      public double getClampedRegionalDifficulty()
      Returns 0.0 if the regional difficulty is below 2.0 and 1.0 if it is above 4.0, with a linear increase between those values.
      Returns:
      a rescaled regional difficulty clamped to the range [0.0, 1.0]
    • setHeightMap

      public void setHeightMap(int... newHeightMap)
      Set the entire height map of this chunk.
      Parameters:
      newHeightMap - The height map.
    • automaticHeightMap

      public void automaticHeightMap()
      Automatically fill the height map after chunks have been initialized.
    • toMessage

      public ChunkDataMessage toMessage()
      Creates a new ChunkDataMessage which can be sent to a client to stream this entire chunk to them.
      Returns:
      The ChunkDataMessage.
    • toMessage

      public ChunkDataMessage toMessage(boolean skylight)
      Creates a new ChunkDataMessage which can be sent to a client to stream this entire chunk to them.
      Parameters:
      skylight - Whether to include skylight data.
      Returns:
      The ChunkDataMessage.
    • toMessage

      public ChunkDataMessage toMessage(boolean skylight, boolean entireChunk)
      Creates a new ChunkDataMessage which can be sent to a client to stream parts of this chunk to them.
      Parameters:
      skylight - Whether to include skylight data.
      entireChunk - Whether to send all chunk sections.
      Returns:
      The ChunkDataMessage.
    • toMessage

      public ChunkDataMessage toMessage(boolean skylight, boolean entireChunk, io.netty.buffer.ByteBufAllocator alloc)
    • addTick

      public void addTick()
    • getPersistentDataContainer

      @NotNull public @NotNull org.bukkit.persistence.PersistentDataContainer getPersistentDataContainer()
      Specified by:
      getPersistentDataContainer in interface org.bukkit.persistence.PersistentDataHolder
    • getWorld

      public GlowWorld getWorld()
      The world of this chunk.
      Specified by:
      getWorld in interface org.bukkit.Chunk
    • getX

      public int getX()
      The x-coordinate of this chunk.
      Specified by:
      getX in interface org.bukkit.Chunk
    • getZ

      public int getZ()
      The z-coordinate of this chunk.
      Specified by:
      getZ in interface org.bukkit.Chunk
    • getSections

      public ChunkSection[] getSections()
      The array of chunk sections this chunk contains, or null if it is unloaded.
      Returns:
      The chunk sections array.
    • isPopulated

      public boolean isPopulated()
      Whether the chunk has been populated by special features. Used in map generation.
      Returns:
      Population status.
    • setPopulated

      public void setPopulated(boolean populated)
      Whether the chunk has been populated by special features. Used in map generation.
      Parameters:
      populated - Population status.
    • setIsSlimeChunk

      public void setIsSlimeChunk(int isSlimeChunk)
    • getInhabitedTime

      public long getInhabitedTime()
      Specified by:
      getInhabitedTime in interface org.bukkit.Chunk
    • setInhabitedTime

      public void setInhabitedTime(long inhabitedTime)
      Specified by:
      setInhabitedTime in interface org.bukkit.Chunk