Interface NMSChunkDef
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 Summary
Modifier and TypeMethodDescriptiondefault void
Saves the chunk to disk and refreshes it for all players.default void
Internal implementation of the save and refresh operation.Methods inherited from interface com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunk
clearTileEntities, getBukkitChunk, getNMSChunkProvider, getOrCreateSection, getSection, getX, getZ, sendUpdatePacket
-
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 interfaceNMSChunk
-
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:
- Temporarily modifies a block at the world's minimum height to trigger dirty state
- Immediately reverts the block to its original state
- Refreshes the chunk for all connected clients
- 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.
-