Overview
Folia is Paper’s experimental multi-threaded server implementation that splits the world into independent regions, each running on separate threads. BetterModel fully supports Folia with region-aware scheduling and thread-safe operations.Region-Based Threading
Each region runs on its own thread with independent tick loop
Automatic Scheduling
BetterModel automatically uses region-aware schedulers
Thread-Safe Operations
All model operations are safe across region boundaries
Zero Configuration
Works out-of-the-box with the Paper JAR
What is Folia?
Folia fundamentally changes how Minecraft servers handle concurrency:1
World Splitting
The world is divided into independent regions (typically chunks or chunk groups).
2
Parallel Execution
Each region runs on a separate thread, allowing true parallel processing.
3
Region Isolation
Entities in different regions cannot directly interact without thread synchronization.
4
Scheduler Changes
Traditional Bukkit scheduler is replaced with region and async schedulers.
Folia is designed for high-player-count servers where regions can be processed independently. It’s not always faster than Paper for small servers.
Detection and Installation
BetterModel automatically detects Folia at runtime:Folia Detection
Installation Steps
1
Install Folia
Download Folia from PaperMC:
2
Use Paper JAR
Install BetterModel using the Paper JAR:
Folia is detected as a Paper fork, so always use the Paper version of BetterModel.
3
Verify detection
Check the console on startup:
Region-Aware Scheduling
The key difference with Folia is the scheduler. BetterModel automatically uses Folia’s region scheduler when detected:Paper Scheduler (Folia-Compatible)
Region vs Global Schedulers
Region Scheduler
Region Scheduler
Used for tasks that must run in a specific region (entity operations):
Region-Specific Task
Location-based tasks automatically execute in the correct region thread.
Async Scheduler
Async Scheduler
Used for tasks that don’t touch world state:
Async Task
Global Region Scheduler
Global Region Scheduler
Folia also has a global region scheduler for tasks that span regions:BetterModel uses this internally for plugin-wide operations.
Global Task
Thread Safety Considerations
Safe Operations
BetterModel’s API is thread-safe across regions:Thread-Safe API Usage
Region Ownership
Each entity “belongs” to a specific region:Region Ownership
Plugin Configuration
Thepaper-plugin.yml explicitly declares Folia support:
paper-plugin.yml
The
folia-supported: true flag tells Folia that BetterModel is tested and compatible with regionized threading.Performance Implications
Benefits on Folia
Parallel Processing
Models in different regions update simultaneously on separate threads
No Main Thread Blocking
Display entity updates don’t bottleneck on single thread
Region Isolation
Performance issues in one region don’t affect others
Async Operations
Resource pack generation and I/O operations remain async
Potential Overhead
Common Patterns
Spawning Models
Folia-Safe Model Spawning
Updating Models
Cross-Region Updates
Async Pre-processing
Async + Region Pattern
Debugging Folia Issues
Thread Assertions
Folia will throw exceptions if you violate thread rules:scheduler().task(location, runnable).
Checking Current Thread
Debug Thread Context
Monitoring Regions
Check Folia’s region status with:Limitations
No Global Entity Iteration
No Global Entity Iteration
You cannot safely iterate all entities across regions:Instead, track entities in your own region-aware data structures.
Event Handler Limitations
Event Handler Limitations
Event handlers run in the region where the event occurred:But you can’t safely access entities in other regions from the event.
Plugin Messaging
Plugin Messaging
Plugin channels work differently on Folia. BetterModel handles this internally, but be aware if you’re implementing custom cross-region communication.
MythicMobs Integration
BetterModel’s MythicMobs integration is Folia-aware:Folia-Safe Mechanics
Best Practices
1
Always schedule region tasks
Never modify entities or world state without scheduling in the correct region:
2
Use async for I/O
Keep file operations, network calls, and heavy computations async:
3
Minimize cross-region dependencies
Design your systems to work within single regions when possible.
4
Test on Folia
If supporting Folia, test your integration on actual Folia servers. Race conditions may only appear under load.
Migration from Paper
Good news: If you’re using BetterModel’s API correctly, your code should work on Folia without changes!
Platform-Agnostic Code
- Paper: Uses
Bukkit.getScheduler() - Folia: Uses
Bukkit.getRegionScheduler()andBukkit.getAsyncScheduler()
Next Steps
Paper Platform
Learn about standard Paper/Bukkit implementation
Trackers
Understand tracker lifecycle and management
Performance Optimization
Optimize BetterModel for high-player-count servers
Examples
See complete API usage examples
