Skip to main content

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.
Folia is experimental and still in active development. While BetterModel is tested on Folia, expect potential issues as Folia evolves.

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

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.
Used for tasks that don’t touch world state:
Async Task
Folia also has a global region scheduler for tasks that span regions:
Global Task
BetterModel uses this internally for plugin-wide operations.

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
Critical Rule: Always schedule entity operations in the entity’s region using scheduler().task(location, runnable).

Plugin Configuration

The paper-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

Folia adds overhead for:
  • Cross-region entity tracking
  • Scheduler coordination
  • Thread synchronization
For small servers (< 50 players), Paper may perform better than Folia.

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:
Solution: Wrap the operation in scheduler().task(location, runnable).

Checking Current Thread

Debug Thread Context

Monitoring Regions

Check Folia’s region status with:

Limitations

You cannot safely iterate all entities across regions:
Instead, track entities in your own region-aware data structures.
Event handlers run in the region where the event occurred:
But you can’t safely access entities in other regions from the event.
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
Mechanics automatically set their thread safety:

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!
The scheduler abstraction handles platform differences:
Platform-Agnostic Code
Behind the scenes:
  • Paper: Uses Bukkit.getScheduler()
  • Folia: Uses Bukkit.getRegionScheduler() and Bukkit.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