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
Nested ClassesModifier and TypeClassDescriptionstatic final classA 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
FieldsModifier and TypeFieldDescriptionstatic final intThe depth of a chunk (y axis).static final intThe height of a chunk (z axis).static final intThe number of chunk sections in a single chunk column.static final intThe Y depth of a single chunk section.static final intThe width of a chunk (x axis). -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddPluginChunkTicket(@NotNull org.bukkit.plugin.Plugin plugin) voidaddTick()voidAutomatically fill the height map after chunks have been initialized.booleancontains(@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.intgetBiome(int x, int z) Gets the biome of a column within this chunk.@NotNull GlowBlockgetBlock(int x, int y, int z) org.bukkit.block.data.BlockDatagetBlockData(int x, int z, int y) Returns the states of the block entities (e.g.bytegetBlockLight(int x, int z, int y) Gets the block light level of a block within this chunk.@NotNull GlowChunkSnapshot@NotNull GlowChunkSnapshotgetChunkSnapshot(boolean includeMaxBlockY, boolean includeBiome, boolean includeBiomeTempRain) doubleReturns 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.intgetHeight(int x, int z) Get the height map value of a column within this chunk.longintgetMetaData(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>doubleGets the regional difficulty for this chunk.The array of chunk sections this chunk contains, or null if it is unloaded.bytegetSkyLight(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) intgetType(int x, int z, int y) Deprecated.Removed in 1.13.getWorld()The world of this chunk.intgetX()The x-coordinate of this chunk.intgetZ()The z-coordinate of this chunk.voidinitializeSections(ChunkSection[] initSections) Initialize this chunk from the given sections.booleanbooleanisLoaded()booleanWhether the chunk has been populated by special features.booleanFormula taken from Minecraft Gamepedia.booleanload()booleanload(boolean generate) booleanremovePluginChunkTicket(@NotNull org.bukkit.plugin.Plugin plugin) voidsetBiome(int x, int z, int biome) Sets the biome of a column within this chunk.voidsetBiomes(byte... newBiomes) Set the entire biome array of this chunk.voidsetBlockLight(int x, int z, int y, int blockLight) Sets the block light level of a block within this chunk.voidsetForceLoaded(boolean b) voidsetHeightMap(int... newHeightMap) Set the entire height map of this chunk.voidsetInhabitedTime(long inhabitedTime) voidsetIsSlimeChunk(int isSlimeChunk) voidsetMetaData(int x, int z, int y, int metaData) Deprecated.Unused in 1.13+voidsetPopulated(boolean populated) Whether the chunk has been populated by special features.voidsetSkyLight(int x, int z, int y, int skyLight) Sets the sky light level of a block within this chunk.voidsetType(int x, int z, int y, org.bukkit.block.data.BlockData blockData) voidsetType(int x, int z, int y, org.bukkit.Material type) Sets the type of a block within this chunk.Creates a newChunkDataMessagewhich can be sent to a client to stream this entire chunk to them.toMessage(boolean skylight) Creates a newChunkDataMessagewhich can be sent to a client to stream this entire chunk to them.toMessage(boolean skylight, boolean entireChunk) Creates a newChunkDataMessagewhich 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()booleanunload()booleanunload(boolean save) booleanunload(boolean save, boolean safe) Deprecated.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:
getBlockin interfaceorg.bukkit.Chunk
-
getEntities
public org.bukkit.entity.Entity[] getEntities()- Specified by:
getEntitiesin interfaceorg.bukkit.Chunk
-
getRawEntities
-
getTileEntities
Deprecated.- Specified by:
getTileEntitiesin interfaceorg.bukkit.Chunk
-
getTileEntities
@NotNull public @NotNull org.bukkit.block.BlockState[] getTileEntities(boolean useSnapshot) - Specified by:
getTileEntitiesin 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:
getTileEntitiesin 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:
isSlimeChunkin interfaceorg.bukkit.Chunk
-
isForceLoaded
public boolean isForceLoaded()- Specified by:
isForceLoadedin interfaceorg.bukkit.Chunk
-
setForceLoaded
public void setForceLoaded(boolean b) - Specified by:
setForceLoadedin interfaceorg.bukkit.Chunk
-
addPluginChunkTicket
public boolean addPluginChunkTicket(@NotNull @NotNull org.bukkit.plugin.Plugin plugin) - Specified by:
addPluginChunkTicketin interfaceorg.bukkit.Chunk
-
removePluginChunkTicket
public boolean removePluginChunkTicket(@NotNull @NotNull org.bukkit.plugin.Plugin plugin) - Specified by:
removePluginChunkTicketin interfaceorg.bukkit.Chunk
-
getPluginChunkTickets
- Specified by:
getPluginChunkTicketsin interfaceorg.bukkit.Chunk
-
contains
public boolean contains(@NotNull @NotNull org.bukkit.block.data.BlockData block) - Specified by:
containsin interfaceorg.bukkit.Chunk
-
getChunkSnapshot
- Specified by:
getChunkSnapshotin interfaceorg.bukkit.Chunk
-
getChunkSnapshot
@NotNull public @NotNull GlowChunkSnapshot getChunkSnapshot(boolean includeMaxBlockY, boolean includeBiome, boolean includeBiomeTempRain) - Specified by:
getChunkSnapshotin interfaceorg.bukkit.Chunk
-
isLoaded
public boolean isLoaded()- Specified by:
isLoadedin interfaceorg.bukkit.Chunk
-
load
public boolean load()- Specified by:
loadin interfaceorg.bukkit.Chunk
-
load
public boolean load(boolean generate) - Specified by:
loadin interfaceorg.bukkit.Chunk
-
unload
public boolean unload()- Specified by:
unloadin interfaceorg.bukkit.Chunk
-
unload
public boolean unload(boolean save) - Specified by:
unloadin interfaceorg.bukkit.Chunk
-
unload
Deprecated. -
initializeSections
Initialize this chunk from the given sections.- Parameters:
initSections- TheChunkSections 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 newChunkDataMessagewhich can be sent to a client to stream this entire chunk to them.- Returns:
- The
ChunkDataMessage.
-
toMessage
Creates a newChunkDataMessagewhich 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 newChunkDataMessagewhich 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:
getPersistentDataContainerin interfaceorg.bukkit.persistence.PersistentDataHolder
-
getWorld
The world of this chunk.- Specified by:
getWorldin interfaceorg.bukkit.Chunk
-
getX
public int getX()The x-coordinate of this chunk.- Specified by:
getXin interfaceorg.bukkit.Chunk
-
getZ
public int getZ()The z-coordinate of this chunk.- Specified by:
getZin 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:
getInhabitedTimein interfaceorg.bukkit.Chunk
-
setInhabitedTime
public void setInhabitedTime(long inhabitedTime) - Specified by:
setInhabitedTimein interfaceorg.bukkit.Chunk
-