Package net.minestom.server.instance
Class DynamicChunk
java.lang.Object
net.minestom.server.instance.Chunk
net.minestom.server.instance.DynamicChunk
- All Implemented Interfaces:
Block.Getter
,Block.Setter
,Snapshotable
,Taggable
,TagReadable
,TagWritable
,Tickable
,Viewable
,Biome.Getter
,Biome.Setter
- Direct Known Subclasses:
LightingChunk
Represents a
Chunk
which store each individual block in memory.
WARNING: not thread-safe.
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.minestom.server.instance.block.Block.Getter
Block.Getter.Condition
-
Field Summary
Modifier and TypeFieldDescriptionprotected final it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
<Block> protected Heightmap
protected final it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
<Block> protected Heightmap
Fields inherited from class net.minestom.server.instance.Chunk
CHUNK_SECTION_SIZE, CHUNK_SIZE_X, CHUNK_SIZE_Z, chunkX, chunkZ, instance, loaded, maxSection, minSection
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription@NotNull Chunk
Creates a copy of this chunk, including blocks state id, custom block id, biomes, update data.protected LightData
createLightData
(boolean requiredFullChunk) getBiome
(int x, int y, int z) @Nullable Block
getBlock
(int x, int y, int z, @NotNull Block.Getter.Condition condition) @NotNull SendablePacket
protected net.kyori.adventure.nbt.CompoundBinaryTag
long
Gets the last time that this chunk changed.@NotNull Section
getSection
(int section) void
Invalidate the chunk cachesvoid
loadHeightmapsFromNBT
(net.kyori.adventure.nbt.CompoundBinaryTag heightmapsNBT) @NotNull Heightmap
void
reset()
Resets the chunk, this means clearing all the data making it empty.void
setBiome
(int x, int y, int z, DynamicRegistry.Key<Biome> biome) void
setBlock
(int x, int y, int z, @NotNull Block block, BlockHandler.Placement placement, BlockHandler.Destroy destroy) void
tick
(long time) Executes a chunk tick.@NotNull ChunkSnapshot
updateSnapshot
(@NotNull SnapshotUpdater updater) Updates the currently cached snapshot if required.@NotNull Heightmap
Methods inherited from class net.minestom.server.instance.Chunk
addViewer, getChunkX, getChunkZ, getIdentifier, getInstance, getMaxSection, getMinSection, getSectionAt, getViewers, isLoaded, isReadOnly, onGenerate, onLoad, removeViewer, sendChunk, sendChunk, setBlock, setReadOnly, shouldGenerate, tagHandler, toPosition, toString, unload
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.minestom.server.world.biome.Biome.Getter
getBiome
Methods inherited from interface net.minestom.server.world.biome.Biome.Setter
setBiome
Methods inherited from interface net.minestom.server.instance.block.Block.Getter
getBlock, getBlock, getBlock
Methods inherited from interface net.minestom.server.instance.block.Block.Setter
setBlock
Methods inherited from interface net.minestom.server.tag.Taggable
getAndSetTag, getAndUpdateTag, getTag, hasTag, removeTag, setTag, updateAndGetTag, updateTag
Methods inherited from interface net.minestom.server.Viewable
getViewersAsAudience, getViewersAsAudiences, isViewer, sendPacketsToViewers, sendPacketsToViewers, sendPacketToViewers, sendPacketToViewersAndSelf
-
Field Details
-
sections
-
motionBlocking
-
worldSurface
-
entries
-
tickableMap
-
-
Constructor Details
-
DynamicChunk
-
-
Method Details
-
setBlock
public void setBlock(int x, int y, int z, @NotNull @NotNull Block block, @Nullable BlockHandler.Placement placement, @Nullable BlockHandler.Destroy destroy) -
setBiome
-
getSections
- Specified by:
getSections
in classChunk
-
getSection
- Specified by:
getSection
in classChunk
-
motionBlockingHeightmap
- Specified by:
motionBlockingHeightmap
in classChunk
-
worldSurfaceHeightmap
- Specified by:
worldSurfaceHeightmap
in classChunk
-
loadHeightmapsFromNBT
public void loadHeightmapsFromNBT(net.kyori.adventure.nbt.CompoundBinaryTag heightmapsNBT) - Specified by:
loadHeightmapsFromNBT
in classChunk
-
tick
public void tick(long time) Description copied from class:Chunk
Executes a chunk tick.Should be used to update all the blocks in the chunk.
WARNING: this method doesn't necessary have to be thread-safe, proceed with caution.
-
getBlock
@Nullable public @Nullable Block getBlock(int x, int y, int z, @NotNull @NotNull Block.Getter.Condition condition) -
getBiome
-
getLastChangeTime
public long getLastChangeTime()Description copied from class:Chunk
Gets the last time that this chunk changed."Change" means here data used in
ChunkDataPacket
. It is necessary to see if the cached version of this chunk can be used instead of re-writing and compressing everything.- Specified by:
getLastChangeTime
in classChunk
- Returns:
- the last change time in milliseconds
-
getFullDataPacket
- Specified by:
getFullDataPacket
in classChunk
-
copy
Description copied from class:Chunk
Creates a copy of this chunk, including blocks state id, custom block id, biomes, update data.The chunk position (X/Z) can be modified using the given arguments.
-
reset
public void reset()Description copied from class:Chunk
Resets the chunk, this means clearing all the data making it empty. -
invalidate
public void invalidate()Description copied from class:Chunk
Invalidate the chunk caches- Specified by:
invalidate
in classChunk
-
createLightData
-
getHeightmapNBT
protected net.kyori.adventure.nbt.CompoundBinaryTag getHeightmapNBT() -
updateSnapshot
Description copied from interface:Snapshotable
Updates the currently cached snapshot if required. The updater can be used to retrieve references to other snapshots while avoiding circular dependency. Be careful to do not storeupdater
anywhere as its data will change when building requested references.This method is not thread-safe, and targeted at internal use since its execution rely on safe-points (e.g. end of ticks)
- Parameters:
updater
- the snapshot updater/context- Returns:
- the updated snapshot
-