Tropicraft

Tropicraft

9M Downloads

AreaScanner multi-threaded code causing entity tracker errors

radfast opened this issue ยท 2 comments

commented

This is seen in logs quite regularly:

01:24:31 [SEVERE] net.minecraft.util.ReportedException: Exception getting block type in world
01:24:31 [SEVERE] at net.minecraft.world.World.func_72798_a(World.java:688)
01:24:31 [SEVERE] at tropicraft.ai.WorldDirector.isCoordAndNearAreaNaturalBlocks(WorldDirector.java:172)
01:24:31 [SEVERE] at tropicraft.ai.AreaScanner.findGoodSurfaceSpot(AreaScanner.java:129)
01:24:31 [SEVERE] at tropicraft.ai.AreaScanner.run(AreaScanner.java:51)
01:24:31 [SEVERE] at java.lang.Thread.run(Thread.java:744)
01:24:31 [SEVERE] Caused by: java.lang.IllegalStateException: Asynchronous entity track!
01:24:31 [SEVERE] at net.minecraft.entity.EntityTracker.func_72785_a(EntityTracker.java:192)
01:24:31 [SEVERE] at cpw.mods.fml.common.registry.EntityRegistry.tryTrackingEntity(EntityRegistry.java:400)
01:24:31 [SEVERE] at net.minecraft.entity.EntityTracker.func_72786_a(EntityTracker.java:64)
01:24:31 [SEVERE] at net.minecraft.world.WorldManager.func_72703_a(WorldManager.java:37)
01:24:31 [SEVERE] at net.minecraft.world.World.func_72923_a(World.java:2026)
01:24:31 [SEVERE] at net.minecraft.world.WorldServer.func_72923_a(WorldServer.java:1292)
01:24:31 [SEVERE] at net.minecraft.world.World.func_72868_a(World.java:4438)
01:24:31 [SEVERE] at net.minecraft.world.chunk.Chunk.func_76631_c(Chunk.java:1154)
01:24:31 [SEVERE] at org.bukkit.craftbukkit.v1_6_R3.chunkio.ChunkIOProvider.callStage2(ChunkIOProvider.java:44)
01:24:31 [SEVERE] at org.bukkit.craftbukkit.v1_6_R3.chunkio.ChunkIOProvider.callStage2(ChunkIOProvider.java:15)
01:24:31 [SEVERE] at org.bukkit.craftbukkit.v1_6_R3.util.AsynchronousExecutor.skipQueue(AsynchronousExecutor.java:337)
01:24:31 [SEVERE] at org.bukkit.craftbukkit.v1_6_R3.util.AsynchronousExecutor.getSkipQueue(AsynchronousExecutor.java:295)
01:24:31 [SEVERE] at org.bukkit.craftbukkit.v1_6_R3.chunkio.ChunkIOExecutor.syncChunkLoad(ChunkIOExecutor.java:12)
01:24:31 [SEVERE] at net.minecraft.world.gen.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:189)
01:24:31 [SEVERE] at net.minecraft.world.gen.ChunkProviderServer.func_73158_c(ChunkProviderServer.java:162)
01:24:31 [SEVERE] at net.minecraft.world.gen.ChunkProviderServer.func_73154_d(ChunkProviderServer.java:285)
01:24:31 [SEVERE] at net.minecraft.world.World.func_72964_e(World.java:803)
01:24:31 [SEVERE] at net.minecraft.world.World.func_72798_a(World.java:679)
01:24:31 [SEVERE] ... 4 more

In my experience, this can happen whenever multi-threaded code calls a chunk provider. (It might be a chunk provider in some different dimension than you expect - this error was seen on a B-Team server which has a few extra dimensions, for example Biomes O'Plenty Promised Land.) Due to this type of synchronicity error, I think a chunk provider can only safely be called from the main Minecraft thread.

(By the way, most mod authors do not seem to know that any call in Minecraft to World.getBlockId() or World.getBlockTileEntity() can result in a call to the chunk provider, if the chunk is unloaded. Best practice is to use World.ifBlockExists() to check the chunk is loaded, before calling World.getBlockId() etc. That will also improve performance overall, as there will be less chunk loading.)

commented

Yeah exactly, learned that lesson a while back when I started doing long term testing / playing on servers. However looks like this particular usage circumvented my own getBlockID method that does a chunkExists check, this shall be fixed for the next bugfix push or whatever next update we're planning.

commented

Again, fixed by the amazing Corosus.