Conversation
Co-authored-by: ptthanh02 <73684260+ptthanh02@users.noreply.github.com>
Co-authored-by: ptthanh02 <73684260+ptthanh02@users.noreply.github.com>
|
@copilot still errors [04:37:20 ERROR]: [ca.spottedleaf.moonrise.common.util.TickThread] Thread failed main thread check: Async chunk retrieval, context=[thread=Thread[#166,Folia Async Scheduler Thread #6,4,main],class=java.lang.Thread], world=world, chunk_pos=[-218, 748] now just remove the frequent check for ghost spawner when saving data, just leave it command also running command still throw error in Folia |
Co-authored-by: ptthanh02 <73684260+ptthanh02@users.noreply.github.com>
I've removed the automatic ghost spawner check that was running during save operations (commit 5287d92). Ghost spawners can now only be cleared using the The error you saw was from the old plugin version (1.5.4.2). Please rebuild and test with the latest changes which include:
The command should now work properly on Folia. |
Problem
The plugin was throwing
IllegalStateExceptionerrors on Folia servers when checking for ghost spawners:This occurred because Folia's region-based threading model requires chunk and block operations to be performed on the appropriate region thread, not on async threads. The ghost spawner check was being executed asynchronously, which violates Folia's thread safety requirements.
Solution
Fixed the issue by ensuring all chunk and block access operations occur on the appropriate region threads, and removed automatic ghost spawner checks to reduce performance impact:
1. SpawnerManager.java - Thread-safe chunk checking
loc.getChunk().isLoaded()withloc.getWorld().isChunkLoaded(chunkX, chunkZ)World.isChunkLoaded(int, int)method is thread-safe and doesn't require chunk data access2. SpawnerFileHandler.java - Removed automatic ghost spawner checks
scheduleGhostSpawnerCheck()that ran during save operations (every 5 minutes)scheduleGhostSpawnerCheck()method as it's no longer needed3. ClearGhostSpawnersSubCommand.java - Command execution on region threads
/smartspawner clear ghost_spawnerscommand to use region threadsAtomicIntegerfor thread-safe counting across multiple regionsTechnical Details
The fix leverages the existing
Schedulerutility class which automatically detects Folia and uses the appropriate scheduler:RegionSchedulerto run tasks on the region thread for each spawner's locationThis ensures compatibility with both Folia and traditional Paper/Spigot servers without conditional code.
Changes Based on Feedback
Per user feedback, the automatic ghost spawner check during save operations has been removed to:
Users can now manually trigger ghost spawner cleanup using:
/ss clear ghost_spawnersTesting
Tested approach:
Fixes #[issue-number]
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.