Interface NativeChunkPacketHandler
Internal handler for NMS-level chunk packet manipulation. Implemented by the NMS module.
- Since:
- 2.0.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final int -
Method Summary
Modifier and TypeMethodDescriptionstatic NativeChunkPacketHandlerinstance()voidmodifyChunkBiomes(Object chunkData, ChunkLocation chunkLocation, VirtualBiomeResolver resolver, int sectionCount) Decodes a clientbound chunk packet exactly once, lets the supplied resolver inspect the real biome/block data and choose a custom biome, and only if one is chosen rewrites the packet to use that biome's ID and apply its block replacements.default voidmodifyChunkBiomes(Object chunkData, ChunkLocation chunkLocation, VirtualBiomeResolver resolver, PacketHandler.DimensionSectionCount dimensionSectionCount) Rewrites a chunk using one of the legacy environment height presets.rewriteChunkPacket(Object packet, ChunkLocation chunkLocation, VirtualBiomeResolver resolver, int sectionCount) Rewrites a clientbound chunk packet for one player without touching the packet itself.
-
Field Details
-
CHUNK_SECTION_SIZE
static final int CHUNK_SECTION_SIZE- See Also:
-
CHUNK_SECTIONS
static final int CHUNK_SECTIONS- See Also:
-
-
Method Details
-
instance
-
modifyChunkBiomes
@AsOf("3.3.0") void modifyChunkBiomes(Object chunkData, ChunkLocation chunkLocation, VirtualBiomeResolver resolver, int sectionCount) Decodes a clientbound chunk packet exactly once, lets the supplied resolver inspect the real biome/block data and choose a custom biome, and only if one is chosen rewrites the packet to use that biome's ID and apply its block replacements.If the resolver returns
null, the packet is left untouched and no serialization or reflection write occurs.- Parameters:
chunkData- the NMS ClientboundLevelChunkPacketData (passed as Object since the API module cannot reference NMS types directly)chunkLocation- the chunk being sent, used to build the snapshot viewresolver- chooses the custom biome to apply based on the decoded chunk data, or returnsnullto leave the packet unmodifiedsectionCount- how many sections the dimension has- Since:
- 3.3.0
-
rewriteChunkPacket
@AsOf("3.4.0") @Nullable Object rewriteChunkPacket(Object packet, ChunkLocation chunkLocation, VirtualBiomeResolver resolver, int sectionCount) Rewrites a clientbound chunk packet for one player without touching the packet itself.The server may send a single packet instance to several players -- Paper's chunk refresh and
BiomeUpdaterboth do -- so a rewrite has to land in a copy, or every later recipient receives the first player's biomes. The copy shares everything except the rewritten section data with the original.- Parameters:
packet- the NMS ClientboundLevelChunkWithLightPacket (passed as Object since the API module cannot reference NMS types directly)chunkLocation- the chunk being sent, used to build the snapshot viewresolver- chooses the custom biome to apply based on the decoded chunk datasectionCount- how many sections the dimension has- Returns:
- a rewritten copy to send in the packet's place, or
nullif nothing applied and the original can go out as it is - Since:
- 3.4.0
-
modifyChunkBiomes
@AsOf("2.2.0") default void modifyChunkBiomes(Object chunkData, ChunkLocation chunkLocation, VirtualBiomeResolver resolver, PacketHandler.DimensionSectionCount dimensionSectionCount) Rewrites a chunk using one of the legacy environment height presets.- Parameters:
chunkData- the NMS chunk packet datachunkLocation- the chunk being sentresolver- the virtual-biome resolverdimensionSectionCount- the legacy dimension section count- Since:
- 2.2.0
-