Interface NativeChunkPacketHandler


@NullMarked @AsOf("2.0.0") @Internal public interface NativeChunkPacketHandler
Internal handler for NMS-level chunk packet manipulation. Implemented by the NMS module.
Since:
2.0.0
  • Field Details

  • Method Details

    • instance

      static NativeChunkPacketHandler 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 view
      resolver - chooses the custom biome to apply based on the decoded chunk data, or returns null to leave the packet unmodified
      sectionCount - 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 BiomeUpdater both 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 view
      resolver - chooses the custom biome to apply based on the decoded chunk data
      sectionCount - how many sections the dimension has
      Returns:
      a rewritten copy to send in the packet's place, or null if 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 data
      chunkLocation - the chunk being sent
      resolver - the virtual-biome resolver
      dimensionSectionCount - the legacy dimension section count
      Since:
      2.2.0