Interface NMSChunkProvider
- All Superinterfaces:
NMSObject
This interface provides a version-independent abstraction for working with Minecraft's chunk management system. The chunk provider is responsible for loading, saving, and managing chunks within a world, acting as the bridge between the world and its constituent chunks.
The chunk provider manages chunk lifecycle operations and provides factory methods for creating NMS chunk wrappers from Bukkit chunk objects. It maintains the relationship between chunks and their world context while abstracting away version-specific implementation details.
Example usage:
// Get chunk provider from world
NMSWorld nmsWorld = worldWrapper.getNMSWorld();
NMSChunkProvider provider = nmsWorld.getChunkProvider();
// Wrap Bukkit chunk
NMSChunk nmsChunk = provider.wrap(bukkitChunk);
// Save chunk modifications
provider.saveChunk(nmsChunk);
-
Method Summary
Modifier and TypeMethodDescription@NotNull NMSWorld
Retrieves the NMS world that this chunk provider manages.default boolean
Checks if force chunk loading is enabled.void
Saves the specified chunk to persistent storage.default void
setForceChunkLoad
(boolean value) Sets the force chunk loading behavior.@NotNull NMSChunk
Creates an NMS chunk wrapper for the specified Bukkit chunk.
-
Method Details
-
getNMSWorld
Retrieves the NMS world that this chunk provider manages.The chunk provider is associated with a specific world and manages all chunks within that world. This method provides access to the parent world wrapper for context and world-level operations.
- Returns:
- the
NMSWorld
that this provider manages chunks for
-
isForceChunkLoad
default boolean isForceChunkLoad()Checks if force chunk loading is enabled.Force chunk loading determines whether chunks are loaded synchronously when requested, regardless of the server's normal chunk loading policies. This can affect performance but ensures immediate chunk availability.
The default implementation returns
true
as most versions either support this feature or have it enabled by default.- Returns:
true
if force chunk loading is enabled,false
otherwise
-
setForceChunkLoad
default void setForceChunkLoad(boolean value) Sets the force chunk loading behavior.This method attempts to configure whether chunks should be loaded synchronously when requested. Not all Minecraft versions support changing this setting, so the default implementation does nothing.
Implementations for versions that support this feature should override this method to provide the appropriate functionality.
- Parameters:
value
-true
to enable force chunk loading,false
to disable
-
saveChunk
Saves the specified chunk to persistent storage.This method forces the chunk to be written to disk, ensuring that any modifications made through NMS operations are persisted. This is particularly important after making direct chunk modifications that might not trigger automatic save mechanisms.
The save operation may include chunk data, tile entities, and any other persistent chunk state depending on the implementation.
- Parameters:
chunk
- theNMSChunk
to save to disk
-
wrap
Creates an NMS chunk wrapper for the specified Bukkit chunk.This factory method converts a Bukkit chunk object into its corresponding NMS wrapper, providing access to low-level chunk operations and internal chunk state. The wrapper maintains references to both the NMS and Bukkit representations.
The returned wrapper is tied to this chunk provider and world, ensuring proper context and management relationships.
-