All Superinterfaces:
NMSChunk, NMSObject

public interface NMSChunkDef extends NMSChunk
Default implementation interface for NMS chunk operations.

This interface provides default implementations for common chunk operations that can be shared across different Minecraft versions. It extends the base NMSChunk interface and provides concrete implementations for complex operations like chunk saving and refreshing.

The implementation focuses on handling the nuances of chunk dirty state management across different Minecraft versions, particularly addressing the lazy saving behavior introduced in newer versions where chunks may not be saved automatically after modifications.

This interface is typically implemented by version-specific chunk wrapper classes that want to inherit the standard save and refresh behavior while providing their own version-specific implementations for other chunk operations.

  • Method Details

    • saveAndRefresh

      default void saveAndRefresh()
      Saves the chunk to disk and refreshes it for all players.

      This method performs a complete save and refresh cycle for the chunk, ensuring that all changes are persisted to disk and that all players see the updated chunk state. The implementation may vary between versions but typically involves marking the chunk as dirty, saving it, and sending update packets to relevant players.

      This operation is useful after making extensive modifications to a chunk to ensure data persistence and visual consistency.

      This implementation delegates to the internal saveAndRefreshI() method to provide a complete save and refresh cycle for the chunk.

      Specified by:
      saveAndRefresh in interface NMSChunk
    • saveAndRefreshI

      default void saveAndRefreshI()
      Internal implementation of the save and refresh operation.

      This method provides a robust implementation for chunk saving and refreshing that works across multiple Minecraft versions. It addresses the lazy saving behavior of newer versions by explicitly marking the chunk as dirty through a temporary block modification.

      The implementation strategy:

      1. Temporarily modifies a block at the world's minimum height to trigger dirty state
      2. Immediately reverts the block to its original state
      3. Refreshes the chunk for all connected clients
      4. Forces chunk unloading with save to ensure persistence

      Note: This method is marked as internal and should not be called directly by external code. Use saveAndRefresh() instead.