Create Fabric

Create Fabric

10M Downloads

Phosphor causes Redstone Links to break chunk lighting

TropheusJ opened this issue ยท 5 comments

commented

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

  1. Install Phosphor and Create
  2. Place 2 Redstone links in 1 chunk
  3. Relog
  4. See broken light

Expected Result

Correct light

Screenshots and Videos

image

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.

commented

forgot to link forge issue

commented

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.

commented

Very useful info, thanks!

commented

Starlight can be safely used instead

It worked.

commented

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