Crossroads-Development / Crossroads

Crossroads is a mod for Minecraft. It adds a lot of content, and has the design philosophy of "simple pieces, complex contraptions".
MIT License
29 stars 18 forks source link

Failed to save chunks using Crossroads and Powah! together #276

Closed 1keponchem closed 4 months ago

1keponchem commented 4 months ago

Describe the bug Newly created world fails to save with some setups using the mod "Powah!" The log says "Failed to save chunk." The setups are included in a below section. This seems to be related with loading unloaded chunks, because similar issues exist: https://github.com/CyclopsMC/IntegratedDynamics/issues/1257 https://github.com/Technici4n/Powah/issues/90#issuecomment-1606226823 Concidering those issues, I thought it might be better to submit an issue here rather than Powah!'s repository.

To Reproduce [Optional] This procedure is only tested in singleplayer. I'm not sure if it works on a server.

  1. Create a new world
  2. Put "Powah!"'s cable and beam contraption in the same chunk (NOT in spawn chunks)
  3. Quit and save the world (don't close the game)
  4. Go to the world select screen
  5. A newly created world is not shown in the GUI

Expected behavior [Optional] The created world appears in the GUI

Screenshots [Optional] 2024-02-17_22 13 34 2024-02-17_22 20 59

Additional context [Optional] Minecraft 1.19.2 Forge: 43.3.8 Mod Versions:

log: 2024-02-17-1.log

Da-Technomancer commented 4 months ago

It looks like this is a bug on Powah's side, even if the dev closed the issue I think they should re-open it. They've got an bug that's messing up the chunk serialization process, and it's causing any other mod (be it Crossroads or Integrated Dynamics) that relies on it to fail.

Technici4n commented 4 months ago

As you can see from the stack trace, BeamRenderTE is causing the chunk to be loaded again while it is unloading. Which means that two instances of the chunk get loaded at the same time, hence Powah complains. The correct fix is to make sure this doesn't happen.

ozraru commented 4 months ago

I've investigated this issue with @1keponchem I don't know much about Minecraft modding, so my claim below may be wrong.

According to below stacktrace, BeamRenderTE.setRemoved(m7651) indirectly calls CableTile.clearRemoved(m6339). This should be wrong.

    at com.Da_Technomancer.crossroads.api.beams.BeamUtil.rayTraceBeamSimple(BeamUtil.java:129) ~[crossroads-1.19.2-2.9.5.jar%23158!/:1.19.2-2.9.5]
    at com.Da_Technomancer.crossroads.api.beams.BeamHelper.emit(BeamHelper.java:37) ~[crossroads-1.19.2-2.9.5.jar%23158!/:1.19.2-2.9.5]
    at com.Da_Technomancer.crossroads.api.templates.BeamRenderTE.m_7651_(BeamRenderTE.java:214) ~[crossroads-1.19.2-2.9.5.jar%23158!/:1.19.2-2.9.5]
Caused by: java.lang.RuntimeException: Cable added to position BlockPos{x=11, y=-60, z=-6}, but there was already one there?
    at owmii.powah.block.cable.CableNet.addCable(CableNet.java:23) ~[Powah-4.0.11.jar%23160!/:?]
    at owmii.powah.block.cable.CableTile.m_6339_(CableTile.java:44) ~[Powah-4.0.11.jar%23160!/:?]

This issue may affects not only Powah. Below is screenshot of broken light level in chunks which Crossroads beam used. There are no Powah machines. I haven't investigated this well because there are too many mods. But I'm pretty sure that this issue causing this. 2024-02-16_01 15 06

Technici4n commented 4 months ago

clearRemoved is called because the chunk is being loaded again. That is the root cause.