Interface SnapshotChunkData
- All Known Implementing Classes:
BukkitSnapshotChunkData
A read-only, lazily evaluated view of the chunk currently being sent to a player,
handed to biome conditionals so they can inspect the real biome/block data
before a phony biome is applied.
Every accessor is a method (not a field) on purpose: a backing may compute its value lazily and memoize it, so a conditional that never reads the biome pays nothing, and several conditionals that read the same value share a single computation.
Two backings exist:
NmsSnapshotChunkData(NMS module) wraps the already-decoded chunk sections from the outgoing packet. Cheap, lazy, safe on the Netty thread. This is what the packet listener uses.BukkitSnapshotChunkDatawraps a realChunkSnapshotthe caller obtained elsewhere (on the main thread). Full block data, but only available if a snapshot was supplied.
- Since:
- 2.2.0
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbiomeAt(int x, int y, int z) The biome at the given chunk-relative block coordinates.The full BukkitChunkSnapshot, if one is available.The biome currently in the packet at the legacy "center" sample (block 7, 0, 7).location()
-
Field Details
-
CENTER_NOISE_XZ
static final int CENTER_NOISE_XZ- See Also:
-
-
Method Details
-
location
ChunkLocation location()- Returns:
- the chunk this data belongs to
-
centerBiome
Biome centerBiome()The biome currently in the packet at the legacy "center" sample (block 7, 0, 7). Lazily computed and memoized.- Returns:
- the source biome at the chunk center
-
biomeAt
The biome at the given chunk-relative block coordinates.yis relative to the bottom of the chunk column (section 0), not world Y.- Parameters:
x- chunk-relative block X (0-15)y- chunk-relative block Y (0 .. sectionCount*16 - 1)z- chunk-relative block Z (0-15)- Returns:
- the source biome at those coordinates
-
bukkitSnapshot
Optional<ChunkSnapshot> bukkitSnapshot()The full BukkitChunkSnapshot, if one is available.Expensive / restricted. The packet-backed implementation returns
Optional.empty()on purpose building a real snapshot requires touching the live world chunk, which is not safe on the Netty thread. A snapshot is only present when the caller explicitly constructed aBukkitSnapshotChunkDatafrom a snapshot they obtained on the main thread. Most conditionals should prefercenterBiome()orbiomeAt(int, int, int)instead.- Returns:
- the snapshot, or empty if none is available
-