Leaf icon indicating copy to clipboard operation
Leaf copied to clipboard

Remove buffering in CraftBlock getNMS and getNMSFluid

Open Biquaternions opened this issue 5 months ago • 0 comments

Did as requested. Honestly, I'd recommend preferably doing a little context analysis of the internal calls before actually merging.

For context, calls involved in getNMS include:

  1. Retrieving a Chunk in net.minecraft.world.level.Level#getBlockState using net.minecraft.world.level.Level#getChunk.
  2. If the Chunk is not loaded, it will fallback using net.minecraft.world.level.ServerChunkCache#getChunkFallback.
  3. If the fallback fails to load the chunk asynchronously, it will schedule the load in the main thread and will force the async thread to wait using net.minecraft.world.level.ServerChunkCache#syncLoad.

If there were a lock, syncLoad can become troublesome, but seems like this is not the case on Leaf as it was on Fish. Still, a little bit more research will be required to see if every buffered call to functions in CraftBlock that internally call getNMS are actually safe and free of possible deadlocks.

Biquaternions avatar Aug 18 '25 03:08 Biquaternions