Applied Energistics 2

Applied Energistics 2

160M Downloads

Light P2Ps don't transfer the right light level after rejoining the world (or possibly even by default)

MageInBlack opened this issue ยท 2 comments

commented

Describe the bug

When the light P2P is first placed and connected, the output shows somewhat correct, although lesser, light level compared to the input (glowstone emits 15, when placed directly to the input, output shows light level 11), And updates correctly with placing glowstone further away from the input. After leaving the world and joining back in the output shows light level 5, the light level correctly updates to 4 if glowstone is placed 1 block away from input and correctly updates down to 0 if glowstone is further and further away.

To fix it remove the output Light P2P, place it and connect to the input again and it will show light level 11 if glowstone is directly at the input. If there are several output Light P2Ps, all of them will bug out and lower the light level on rejoining. However they can be fixed separately and one can be bugged while another working somewhat correctly. Both will adjust their light level depending on the input. One 1-2 levels lower and another ~10 levels lower.

2024-06-18_21 02 42
2024-06-18_21 02 59
2024-06-18_21 03 19

How to reproduce the bug

Create a network with an input and output Light P2Ps. Place light source to the input Light P2P. Check the output light level. it should be 1-3 levels lower than the input. Leave the world then join it again. Check the output light p2p, the light level should be ~10 levels lower than the input.

Expected behavior

The output shows the exact light level that is on the input. Not 1-3 levels lower, not ~10 levels lower after rejoining.

Additional details

I think they should emit the same light level as at the input. Not even slightly lower than it is now. However, what is interesting is they update somewhat correctly, although with reduced light levels even if they are the part of the same p2p connection and have different light levels (one 1-3 levels lower another ~10 levels lower)

Which minecraft version are you using?

1.20

On which mod loaders does it happen?

NeoForge

Crash log

https://pastebin.com/uxFd2uA5

commented

I've played around with P2P Light a bit (in 1.20.1 and 1.21 both the same behavior), here is what I've found:

  1. Create a P2P Light setup (Glowstone directly in front of P2P Light input, link with output), leave the world ("save and quit to title"), rejoin the world -> find the P2P Light output is completely dark
  2. Place a cobble (or any other solid block) directly in front of the P2P Light output and remove it again -> find the output has light level 14
  3. Bonus Bug: Remove the input -> note that the output is correctly marked as "unlinked" but still emits the light as before. Does not get fixed by placing a solid block in front of it and removing it again.

My best guess is that some triggers for updates are missing.

commented

I played around some more (1.21 only) with some debug printing and found some interesting and unintuitive behavior. When loading the level at some point very early blockLight is called in LightP2PTunnelPart with a correct value of emit = 15. There this.opacity was correctly set to -1 and thus calculated anew. The returned value of level.getMaxLocalRawBrightness(pos.relative(getSide())) is however not correct as it seems. It also is not consistent across multiple attempts to join the world. I've seen values of 14 (which effectively reduces the emitted light level to 1), 4 (which effectively reduces the light level to 11), 10, 9.

When I place a cobblestone in front of the output, this.opacity is correctly recalculated and light levels are correct. So my guess is that unless I force the update to succeed by placing a block in front of the output the opacity is some sort of garbage value.

As for the bonus bug: Enhancing getLightLevel() with another condition in the if statement (&& this.getInput() != null) solves this problem.