Mod No Null Processors by telepathicgrunt
- 12.77 KB
- 1.18
- November 13, 2021
- September 13, 2022
- Server UtilityStructures
Name | No Null Processors | Author | telepathicgrunt | Description | Fixes structure crash in 1.17+ due to null processor lists coming from nowhere |
---|---|---|---|---|---|
Information | Downloads: Version: 1.18 Size: 12.77 KB Updated at: September 13, 2022 Created at: November 13, 2021 | Tags | Server Utility Structures |
Files
Forge download: Click here
Fabric download: Click here
--------------------------------------------------------------------------------------------------------------
NOTE: 1.18.2 FIXED NULL PROCESSORS SO THIS MOD IS NO LONGER NEEDED FOR THAT MC VERSION AND NEWER
INFO
Have you been trying to pre-generate large areas of your world with pregenerator mods and keep randomly crashing with this error?
Caused by: java.lang.NullPointerException: Cannot invoke "net.minecraft.structure.processor.StructureProcessorList.getList()" because the return value of "java.util.function.Supplier.get()" is null
at net.minecraft.structure.pool.SinglePoolElement.createPlacementData(SinglePoolElement:148) ~[?:?]
at net.minecraft.structure.pool.SinglePoolElement.generate(SinglePoolElement:124) ~[?:?]
Caused by: java.lang.NullPointerException: Cannot invoke "net.minecraft.class_5497.method_31027()" because the return value of "java.util.function.Supplier.get()" is null
at net.minecraft.structure.pool.SinglePoolElement.createPlacementData(SinglePoolElement:148) ~[?:?]
at net.minecraft.structure.pool.SinglePoolElement.generate(SinglePoolElement:124) ~[?:?]
If so, congrats! You found a really wacky bug in 1.17.1 Minecraft! This mod aims to fix that.
The bug is tricky to explain but basically to trigger it, you need a mod or datapack that has processor lists created by worldgen json files, use a chunk pregenerator mod or something to load a massive amount of chunks, and then load all those chunks that contains structures that uses json processor lists. Randomly, that may crash due to a null processor list.
So what's going on? Well, Minecraft has a registry of processor lists inside that should be created at world startup. Then when the game needs it, it grabs it from the registry but it shouldn't be rewriting that registry at runtime. Cause that would be bad right? Well...
When a structure layout is created during worldgen, the game saves that layout and what pieces were picked into the chunk itself. Then later, as the chunk is being made, it loads that piece from the chunk to spawn in the world. Except, upon reading that structure piece from the chunk, it also needs to read the processor list attached to the piece to know what processors should run for that piece. And it's here that the bug is done. The code to read the processor list is incorrect and will take the processor it reads and register it again to the registry, replacing itself with itself, and then use it.
And this registry replacing with itself is not threadsafe. And since minecraft creates chunks in a multithreaded way... there exists a point where two structure pieces using the same processor could try reading/writing to that same exact entry in the registry. And when this rare collision occurs, one of the structure pieces may end up with a null processor which then crashes the game because the game cannot handle spawning a null processor because it doesn't exist!
Wacky right? Super weird and painful to debug but thanks to another modder, we were able to figure this out and create this fix. As far as we know, 1.16.5 does not have this issue. The problem started in 1.17.0 and continues to persist to 1.18.1. However, 1.18.2 fixed this bug. The fix this mod does is it caches the RegistryOps used for each individual processor list so it only writes itself to the registry once and reuses that forever. Thus avoiding the whole issue with multiple read/writes to that same specific registry entry. (In theory lol)
Hope this helps!
Discord Link to #telepathicgrunt-mods channel for my mods! :
My Patreon page if you wish to help donate to support me! :