ChunkGenerationManager is the central orchestrator for Voxy World Gen V2’s chunk pre-generation system. It manages a dedicated worker thread, tracks generation progress across dimensions, and coordinates with the Minecraft server’s chunk loading system.
Singleton Pattern
getInstance()
Retrieve the singleton instance of ChunkGenerationManager.The singleton instance
getCurrentLevel()
Get the current active dimension level that generation is focused on.The current ServerLevel, or null if no dimension is active
Lifecycle Methods
initialize()
Initialize the manager and start the worker thread. Must be called once on server startup.The Minecraft server instance
shutdown()
Cleanly shut down the manager, stop the worker thread, and save all state.tick()
Process pending chunk tickets, reload config if scheduled, and update stats. Call this every server tick.Configuration
scheduleConfigReload()
Schedule a config reload on the next tick. Thread-safe.Control Methods
setPauseCheck()
Set a custom pause condition that stops generation when true.A supplier that returns
true to pause generation, false to allow itQuery Methods
isAnyPlayerNear()
Thread-safe check if any player is near a chunk position. Safe to call from C2ME storage threads.The dimension to check
The chunk position to check
true if any player is within view distance + 2 chunksgetStats()
Get the generation statistics tracker.Statistics object with methods:
getQueued()- Total chunks queuedgetCompleted()- Total chunks completedgetFailed()- Total chunks failedgetSkipped()- Total chunks skipped (already existed)getChunksPerSecond()- Rolling 10-second average generation rate
getActiveTaskCount()
Get the number of currently active generation tasks.Number of chunks currently being generated
getRemainingInRadius()
Get the number of chunks remaining to generate in the current dimension’s generation radius.Number of chunks remaining in radius around players
isThrottled()
Check if generation is currently throttled due to low TPS.true if generation is paused due to server performancegetQueueSize()
Get the size of the pending chunk queue.Number of chunks in the queue (currently always returns 0 as queue is managed internally)
Complete Usage Example
Thread Safety
All public methods are thread-safe:getInstance(),initialize(),shutdown(),tick()- Safe from server threadisAnyPlayerNear()- Explicitly designed for C2ME storage threadsgetStats(),getActiveTaskCount(),getRemainingInRadius()- Use atomic operationssetPauseCheck(),scheduleConfigReload()- Thread-safe atomic operations
Internal Architecture
The manager maintains:- Worker Thread: Dedicated background thread (
Voxy-WorldGen-Worker) that finds and dispatches generation work - Per-Dimension State: Tracks completed chunks, distance graphs, and batch counters for each dimension
- Throttling: Semaphore-based throttling respects
Config.DATA.maxActiveTasks - TPS Monitoring: Automatically pauses when server performance degrades
- Ticket Queue: C2ME-compatible queued ticket operations processed on main thread
See Also
- Config API - Configuration management
- PlayerTracker API - Player position tracking
- GenerationStats - Statistics tracking (if you create this page)