I need to retrieve a TileEntity from another thread. I have the BlockPos of the entity, as well as the appropriate ServerWorld. However, I keep running afoul of this line in net.minecraft.world.World (line 639):
} else if (!this.isRemote && Thread.currentThread() != this.mainThread) {
return null;
}
(Specifically, it's detecting that the current thread isn't the main thread)
I've also tried variations of this with no luck (Kotlin code):
val queue = SynchronousQueue<TileEntity>()
Minecraft.getInstance().enqueue {
val tileEntity = dimension.getTileEntity(BlockPos(destination.x, destination.y, destination.z))
queue.put(tileEntity)
}
val tileEntity = queue.take()
However, this seems to run on a rendering thread rather than the "main" thread. Is there any way to get a TileEntity from another thread? (FYI, the part of TileEntity in that I'm planning to access uses thread safe code, so I'm not concerned about that part of the equation.)
(Side note: Just getting the TileEntity from the ServerWorld worked in 1.12, so I'm guessing that "safety check" is new...)