Overview
Instances are what Minecraft calls “worlds”. Each instance contains entities, chunks, and has its own properties like dimension type, time, and weather.InstanceManager
The InstanceManager handles the registration and lifecycle of all instances in the server.Creating Instances
Creates and registers a new InstanceContainer with default settings (Overworld dimension).Returns: The created and registered InstanceContainer
Creates an instance with a specific dimension type.Parameters:
dimensionType- The dimension type (e.g., DimensionType.OVERWORLD, DimensionType.NETHER)
Creates an instance with a dimension type and chunk loader for persistence.Parameters:
dimensionType- The dimension typeloader- ChunkLoader for loading/saving chunks (null for no persistence)
Shared Instances
Creates a shared instance that shares chunks with a parent InstanceContainer.Parameters:
instanceContainer- The parent instance container
Managing Instances
Manually registers an instance. Required if you instantiate an instance directly.Parameters:
instance- The instance to register
Not necessary if using
createInstanceContainer() or createSharedInstance()Unregisters an instance and unloads all its chunks.Parameters:
instance- The instance to unregister
Gets all registered instances.Returns: Unmodifiable set of all instances
Gets an instance by its UUID.Parameters:
uuid- The instance UUID
Instance
The Instance class represents a world with chunks, entities, time, and weather.Block Operations
Sets a block at the specified coordinates.Parameters:
x- Block X coordinatey- Block Y coordinatez- Block Z coordinateblock- The block to place
Sets a block at the specified position.Parameters:
blockPosition- The block positionblock- The block to place
Sets a block with control over block updates.Parameters:
x,y,z- Block coordinatesblock- The block to placedoBlockUpdates- Whether to trigger block updates
Gets the block at specified coordinates.Parameters:
x,y,z- Block coordinates
Gets the block at the specified point.Parameters:
point- The position
Chunk Management
Forces loading of a chunk, generating it if needed.Parameters:
chunkX- Chunk X coordinatechunkZ- Chunk Z coordinate
Loads the chunk at the given point.Parameters:
point- Position in the chunk
Loads a chunk only if auto chunk loading is enabled or chunk is already loaded.Parameters:
chunkX,chunkZ- Chunk coordinates
Schedules a chunk for unloading. All non-player entities will be removed.Parameters:
chunk- The chunk to unload
Unloads the chunk at the specified coordinates.Parameters:
chunkX,chunkZ- Chunk coordinates
Gets an already loaded chunk.Parameters:
chunkX,chunkZ- Chunk coordinates
Checks if a chunk is loaded.Parameters:
chunkX,chunkZ- Chunk coordinates
Gets all loaded chunks in this instance.Returns: Unmodifiable collection of loaded chunks
Chunk Generation
Sets the chunk generator for this instance.Parameters:
generator- The generator (null to disable)
Gets the current chunk generator.Returns: The generator, or null if not set
Enables or disables automatic chunk loading.Parameters:
enable- true to enable auto chunk loading
Checks if auto chunk loading is enabled.Returns: true if enabled
World Properties
Gets the dimension type registry key.Returns: The dimension type key
Gets the dimension name.Returns: The dimension name as a string
Gets the instance UUID.Returns: The instance UUID
Time Management
Gets the current time in the instance (sun/moon position).Returns: The time in ticks (0-24000)
Sets the instance time.Parameters:
time- Time in ticks (0 = dawn, 6000 = noon, 12000 = dusk, 18000 = midnight)
Gets the age of the instance in ticks.Returns: The world age
Sets the world age in ticks.Parameters:
worldAge- The new world age
Sets how fast time advances (default: 1).Parameters:
timeRate- Ticks to advance per server tick (0 to stop time)
Persistence
Saves instance data (tags only, not chunks).Returns: Future completed when save finishes
Saves a specific chunk to permanent storage.Parameters:
chunk- The chunk to save
Saves all loaded chunks to permanent storage.Returns: Future completed when all chunks are saved
Examples
Instances must be registered before players can join them. Use
createInstanceContainer() which automatically registers, or manually call registerInstance().