ChunkTestAdapter to query chunk status and ChunkAssert to verify loading expectations.
Chunk testing matters when your mod relies on chunks being loaded before performing operations - spawning entities, placing blocks, or running world queries. A test that assumes a chunk is loaded when it is not can produce false positives or cryptic failures. Chunk assertions make these dependencies explicit.
Complete Example Suite
Adapter Methods
| Method | Parameters | Returns | Description |
|---|---|---|---|
isChunkLoaded | Object world, int chunkX, int chunkZ | boolean | Check if the chunk at the given chunk coordinates is loaded |
Assertion Methods
| Method | Parameters | Failure Message |
|---|---|---|
assertChunkLoaded | Object world, int chunkX, int chunkZ | ”Expected chunk [chunkX, chunkZ] to be loaded” |
assertChunkNotLoaded | Object world, int chunkX, int chunkZ | ”Expected chunk [chunkX, chunkZ] to not be loaded” |
Key Details
- Chunk coordinates are block coordinates divided by chunk size, not raw block positions. Block (160, 64, 160) with a chunk size of 16 falls in chunk (10, 10).
- Spawning an entity or placing a block may trigger chunk loading - wait a few ticks before asserting.
- Use
assertChunkNotLoadedto verify that chunks outside the active area are properly unloaded, which is important for memory testing.
Next Steps
- World Testing - block and entity operations
- Blocks - block placement and type verification
- Scheduling - world thread execution