Interface SnapshotChunkData

All Known Implementing Classes:
BukkitSnapshotChunkData

@NullMarked @AsOf("2.2.0") public interface SnapshotChunkData
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.
  • BukkitSnapshotChunkData wraps a real ChunkSnapshot the caller obtained elsewhere (on the main thread). Full block data, but only available if a snapshot was supplied.
Since:
2.2.0
  • Field Details

  • 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

      Biome biomeAt(int x, int y, int z)
      The biome at the given chunk-relative block coordinates. y is 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 Bukkit ChunkSnapshot, 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 a BukkitSnapshotChunkData from a snapshot they obtained on the main thread. Most conditionals should prefer centerBiome() or biomeAt(int, int, int) instead.

      Returns:
      the snapshot, or empty if none is available