Package net.glowstone.chunk
Class GlowChunk
java.lang.Object
net.glowstone.chunk.GlowChunk
- All Implemented Interfaces:
org.bukkit.Chunk
,org.bukkit.persistence.PersistentDataHolder
Represents a chunk of the map.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
A chunk key represents the X and Z coordinates of a chunk in a manner suitable for use as a key in a hash table or set. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The depth of a chunk (y axis).static final int
The height of a chunk (z axis).static final int
The number of chunk sections in a single chunk column.static final int
The Y depth of a single chunk section.static final int
The width of a chunk (x axis). -
Method Summary
Modifier and TypeMethodDescriptionboolean
addPluginChunkTicket
(@NotNull org.bukkit.plugin.Plugin plugin) void
addTick()
void
Automatically fill the height map after chunks have been initialized.boolean
contains
(@NotNull org.bukkit.block.data.BlockData block) createEntity
(int cx, int cy, int cz, int type) Deprecated.Uses ordinals in place of old integer IDs.createEntity
(int cx, int cy, int cz, org.bukkit.Material type) If needed, create a new block entity at the given location.int
getBiome
(int x, int z) Gets the biome of a column within this chunk.@NotNull GlowBlock
getBlock
(int x, int y, int z) org.bukkit.block.data.BlockData
getBlockData
(int x, int z, int y) Returns the states of the block entities (e.g.byte
getBlockLight
(int x, int z, int y) Gets the block light level of a block within this chunk.@NotNull GlowChunkSnapshot
@NotNull GlowChunkSnapshot
getChunkSnapshot
(boolean includeMaxBlockY, boolean includeBiome, boolean includeBiomeTempRain) double
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.org.bukkit.entity.Entity[]
getEntity
(int x, int y, int z) Attempt to get the block entity located at the given coordinates.int
getHeight
(int x, int z) Get the height map value of a column within this chunk.long
int
getMetaData
(int x, int z, int y) Gets the metadata of a block within this chunk.@NotNull org.bukkit.persistence.PersistentDataContainer
@NotNull Collection<org.bukkit.plugin.Plugin>
double
Gets the regional difficulty for this chunk.The array of chunk sections this chunk contains, or null if it is unloaded.byte
getSkyLight
(int x, int z, int y) Gets the sky light level of a block within this chunk.Deprecated.@NotNull org.bukkit.block.BlockState[]
getTileEntities
(boolean useSnapshot) @NotNull Collection<org.bukkit.block.BlockState>
getTileEntities
(@NotNull Predicate<org.bukkit.block.Block> blockPredicate, boolean useSnapshot) int
getType
(int x, int z, int y) Deprecated.Removed in 1.13.getWorld()
The world of this chunk.int
getX()
The x-coordinate of this chunk.int
getZ()
The z-coordinate of this chunk.void
initializeSections
(ChunkSection[] initSections) Initialize this chunk from the given sections.boolean
boolean
isLoaded()
boolean
Whether the chunk has been populated by special features.boolean
Formula taken from Minecraft Gamepedia.boolean
load()
boolean
load
(boolean generate) boolean
removePluginChunkTicket
(@NotNull org.bukkit.plugin.Plugin plugin) void
setBiome
(int x, int z, int biome) Sets the biome of a column within this chunk.void
setBiomes
(byte... newBiomes) Set the entire biome array of this chunk.void
setBlockLight
(int x, int z, int y, int blockLight) Sets the block light level of a block within this chunk.void
setForceLoaded
(boolean b) void
setHeightMap
(int... newHeightMap) Set the entire height map of this chunk.void
setInhabitedTime
(long inhabitedTime) void
setIsSlimeChunk
(int isSlimeChunk) void
setMetaData
(int x, int z, int y, int metaData) Deprecated.Unused in 1.13+void
setPopulated
(boolean populated) Whether the chunk has been populated by special features.void
setSkyLight
(int x, int z, int y, int skyLight) Sets the sky light level of a block within this chunk.void
setType
(int x, int z, int y, org.bukkit.block.data.BlockData blockData) void
setType
(int x, int z, int y, org.bukkit.Material type) Sets the type of a block within this chunk.Creates a newChunkDataMessage
which can be sent to a client to stream this entire chunk to them.toMessage
(boolean skylight) Creates a newChunkDataMessage
which can be sent to a client to stream this entire chunk to them.toMessage
(boolean skylight, boolean entireChunk) Creates a newChunkDataMessage
which can be sent to a client to stream parts of this chunk to them.toMessage
(boolean skylight, boolean entireChunk, io.netty.buffer.ByteBufAllocator alloc) toString()
boolean
unload()
boolean
unload
(boolean save) boolean
unload
(boolean save, boolean safe) Deprecated.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.bukkit.Chunk
getChunkKey
-
Field Details
-
WIDTH
public static final int WIDTHThe width of a chunk (x axis).- See Also:
-
HEIGHT
public static final int HEIGHTThe height of a chunk (z axis).- See Also:
-
DEPTH
public static final int DEPTHThe depth of a chunk (y axis).- See Also:
-
SEC_DEPTH
public static final int SEC_DEPTHThe Y depth of a single chunk section.- See Also:
-
SEC_COUNT
public static final int SEC_COUNTThe number of chunk sections in a single chunk column.- See Also:
-
-
Method Details
-
toString
-
getBlock
- Specified by:
getBlock
in interfaceorg.bukkit.Chunk
-
getEntities
public org.bukkit.entity.Entity[] getEntities()- Specified by:
getEntities
in interfaceorg.bukkit.Chunk
-
getRawEntities
-
getTileEntities
Deprecated.- Specified by:
getTileEntities
in interfaceorg.bukkit.Chunk
-
getTileEntities
@NotNull public @NotNull org.bukkit.block.BlockState[] getTileEntities(boolean useSnapshot) - Specified by:
getTileEntities
in interfaceorg.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 interfaceorg.bukkit.Chunk
-
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
-
isSlimeChunk
public boolean isSlimeChunk()Formula taken from Minecraft Gamepedia. https://minecraft.gamepedia.com/Slime#.22Slime_chunks.22- Specified by:
isSlimeChunk
in interfaceorg.bukkit.Chunk
-
isForceLoaded
public boolean isForceLoaded()- Specified by:
isForceLoaded
in interfaceorg.bukkit.Chunk
-
setForceLoaded
public void setForceLoaded(boolean b) - Specified by:
setForceLoaded
in interfaceorg.bukkit.Chunk
-
addPluginChunkTicket
public boolean addPluginChunkTicket(@NotNull @NotNull org.bukkit.plugin.Plugin plugin) - Specified by:
addPluginChunkTicket
in interfaceorg.bukkit.Chunk
-
removePluginChunkTicket
public boolean removePluginChunkTicket(@NotNull @NotNull org.bukkit.plugin.Plugin plugin) - Specified by:
removePluginChunkTicket
in interfaceorg.bukkit.Chunk
-
getPluginChunkTickets
- Specified by:
getPluginChunkTickets
in interfaceorg.bukkit.Chunk
-
contains
public boolean contains(@NotNull @NotNull org.bukkit.block.data.BlockData block) - Specified by:
contains
in interfaceorg.bukkit.Chunk
-
getChunkSnapshot
- Specified by:
getChunkSnapshot
in interfaceorg.bukkit.Chunk
-
getChunkSnapshot
@NotNull public @NotNull GlowChunkSnapshot getChunkSnapshot(boolean includeMaxBlockY, boolean includeBiome, boolean includeBiomeTempRain) - Specified by:
getChunkSnapshot
in interfaceorg.bukkit.Chunk
-
isLoaded
public boolean isLoaded()- Specified by:
isLoaded
in interfaceorg.bukkit.Chunk
-
load
public boolean load()- Specified by:
load
in interfaceorg.bukkit.Chunk
-
load
public boolean load(boolean generate) - Specified by:
load
in interfaceorg.bukkit.Chunk
-
unload
public boolean unload()- Specified by:
unload
in interfaceorg.bukkit.Chunk
-
unload
public boolean unload(boolean save) - Specified by:
unload
in interfaceorg.bukkit.Chunk
-
unload
Deprecated. -
initializeSections
Initialize this chunk from the given sections.- Parameters:
initSections
- TheChunkSection
s to use. Should have a length of 16.
-
createEntity
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 BlockEntitycy
- the Y coordinate of the BlockEntitycz
- the Z coordinate of the BlockEntitytype
- the type of BlockEntity- Returns:
- The BlockEntity that was created.
-
createEntity
If needed, create a new block entity at the given location.- Parameters:
cx
- the X coordinate of the BlockEntitycy
- the Y coordinate of the BlockEntitycz
- the Z coordinate of the BlockEntitytype
- the type of BlockEntity- Returns:
- The BlockEntity that was created.
-
getEntity
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.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.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
Creates a newChunkDataMessage
which can be sent to a client to stream this entire chunk to them.- Returns:
- The
ChunkDataMessage
.
-
toMessage
Creates a newChunkDataMessage
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
Creates a newChunkDataMessage
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 interfaceorg.bukkit.persistence.PersistentDataHolder
-
getWorld
The world of this chunk.- Specified by:
getWorld
in interfaceorg.bukkit.Chunk
-
getX
public int getX()The x-coordinate of this chunk.- Specified by:
getX
in interfaceorg.bukkit.Chunk
-
getZ
public int getZ()The z-coordinate of this chunk.- Specified by:
getZ
in interfaceorg.bukkit.Chunk
-
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 interfaceorg.bukkit.Chunk
-
setInhabitedTime
public void setInhabitedTime(long inhabitedTime) - Specified by:
setInhabitedTime
in interfaceorg.bukkit.Chunk
-