Phosphor causes Redstone Links to break chunk lighting
TropheusJ opened this issue ยท 5 comments
Describe the Bug
When Phosphor is installed, Redstone Links, when 2 are placed in a chunk together, break that chunk's lighting.
Phosphor issue: CaffeineMC/phosphor-fabric#82
Reproduction Steps
- Install Phosphor and Create
- Place 2 Redstone links in 1 chunk
- Relog
- See broken light
Expected Result
Correct light
Screenshots and Videos
Crash Report or Log
No response
Operating System
Windows 10
Mod Version
0.4.1
Minecraft Version
1.18.2
Other Mods
Phosphor
Additional Context
Pretty sure this cannot be fixed on our side. For now, Starlight can be safely used instead.
forgot to link forge issue
The issue is actually caused by Create and only made visible by Phosphor. Create can reload chunks in the middle of the unloading process within ThreadedAnvilChunkStorage.tryUnloadChunk(...)
. There we have the following sequence of operations
...
this.save((Chunk)chunk);
if (this.loadedChunks.remove(pos) && chunk instanceof WorldChunk) {
WorldChunk worldChunk = (WorldChunk)chunk;
this.world.unloadEntities(worldChunk);
}
this.lightingProvider.updateChunkStatus(chunk.getPos());
this.lightingProvider.tick();
...
At this point, the chunk is already out of reach for the chunk manager and a query will need to reload it. Now, World.unloadEntities(...)
contains a call to RedstoneLinkNetworkHandler.removeFromNetwork(...)
which in turn queries all remaining block entities and hence queries their chunks. In particular, if there are two redstone links in the same chunk, unloading the first will reload the chunk by querying the block entity for the second.
The light data will only be unloaded afterwards via lightingProvider.updateChunkStatus(...)
in the remainder of the unloading process, despite the chunk already being fully reloaded at that point. Since light data is stored separately from chunks, this will not only affect the old copy of the chunk but also the new one. Subsequently saving the chunk will hence not have any light data available.
The reason this does not cause lighting glitches for Vanilla is that Phosphor unloads lightmaps more aggressively.
Issues that occur on Forge as well are no longer being tracked on this repo. Please follow the respective issue on the Forge repo instead: Creators-of-Create#3068