Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phosphor causes Redstone Links to break chunk lighting #318

Closed
TropheusJ opened this issue May 25, 2022 · 5 comments
Closed

Phosphor causes Redstone Links to break chunk lighting #318

TropheusJ opened this issue May 25, 2022 · 5 comments
Labels
compatibility This issue only occurs when a separate mod is active type: bug Something isn't working upstream This is inherited from upstream Forge Create. It is highly unlikely we will change it.

Comments

@TropheusJ
Copy link
Member

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.

@TropheusJ TropheusJ added type: bug Something isn't working compatibility This issue only occurs when a separate mod is active labels May 25, 2022
@github-actions github-actions bot added the 1.18 label May 25, 2022
@TropheusJ TropheusJ added wontfix This will not be worked on upstream This is inherited from upstream Forge Create. It is highly unlikely we will change it. and removed 1.18 labels May 25, 2022
@TropheusJ
Copy link
Member Author

forgot to link forge issue

@PhiProven
Copy link

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.

@TropheusJ
Copy link
Member Author

Very useful info, thanks!

@ardissaps
Copy link

Starlight can be safely used instead

It worked.

@TropheusJ
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility This issue only occurs when a separate mod is active type: bug Something isn't working upstream This is inherited from upstream Forge Create. It is highly unlikely we will change it.
Projects
None yet
Development

No branches or pull requests

3 participants