Record Class BukkitSnapshotChunkData
- All Implemented Interfaces:
SnapshotChunkData
SnapshotChunkData backed by a real Bukkit ChunkSnapshot.
This backing exposes full block data, but it can only be constructed by a caller that
already holds a snapshot. Obtaining a snapshot (world.getChunkAt(...).getChunkSnapshot())
touches the live world and must be done on the main thread never on the
Netty thread inside a packet listener. Use this only when you legitimately have a snapshot in
hand; otherwise the packet-backed NmsSnapshotChunkData is the correct, safe choice.
- Since:
- 2.2.0
-
Field Summary
Fields inherited from interface SnapshotChunkData
CENTER_NOISE_XZ -
Constructor Summary
ConstructorsConstructorDescriptionBukkitSnapshotChunkData(ChunkLocation location, ChunkSnapshot snapshot) Creates an instance of aBukkitSnapshotChunkDatarecord class. -
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).final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.location()Returns the value of thelocationrecord component.snapshot()Returns the value of thesnapshotrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
BukkitSnapshotChunkData
Creates an instance of aBukkitSnapshotChunkDatarecord class.- Parameters:
location- the value for thelocationrecord componentsnapshot- the value for thesnapshotrecord component
-
-
Method Details
-
centerBiome
Description copied from interface:SnapshotChunkDataThe biome currently in the packet at the legacy "center" sample (block 7, 0, 7). Lazily computed and memoized.- Specified by:
centerBiomein interfaceSnapshotChunkData- Returns:
- the source biome at the chunk center
-
biomeAt
Description copied from interface:SnapshotChunkDataThe biome at the given chunk-relative block coordinates.yis relative to the bottom of the chunk column (section 0), not world Y.- Specified by:
biomeAtin interfaceSnapshotChunkData- 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
Description copied from interface:SnapshotChunkDataThe 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 preferSnapshotChunkData.centerBiome()orSnapshotChunkData.biomeAt(int, int, int)instead.- Specified by:
bukkitSnapshotin interfaceSnapshotChunkData- Returns:
- the snapshot, or empty if none is available
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
location
Returns the value of thelocationrecord component.- Specified by:
locationin interfaceSnapshotChunkData- Returns:
- the value of the
locationrecord component
-
snapshot
Returns the value of thesnapshotrecord component.- Returns:
- the value of the
snapshotrecord component
-