Kerosene lamp causes weird chunk corruption
belathus opened this issue ยท 7 comments
Describe the bug
Chunks aren't getting deleted -- they're getting moved around.
I placed a kerosene lamp down, fueled by biodiesel which was supplied by a requester frame and a logistics module, and put a daylight sensor on top of it that was inverted (emits signal at night). Set the kerosene lamp to a radius of 30 blocks, and to turn on only with a redstone signal. Then the server restarted, so I went to bed for the night.
The next time I rejoined the world on the next day, the chunks in the same region file were jumbled up. Some chunks were copied. Some were in their original locations. I had a backup of the world from a few hours before I rejoined the server, restored the backup and restarted the server. Things seemed fine then, but when the server restarted later that day, the chunks got jumbled up again. Frustrated, I played something else for a while. When I rejoined later, more chunks got moved around. It got pretty bad after leaving and rejoining a few times.
I restored the world from backup and went to work. Later on, someone asked me to restart the server, so I used SSH to stop the server from the console and got the following:
> stop
[15:17:51] [Server thread/INFO] [minecraft/DedicatedServer]: Stopping the server
[15:17:52] [Server thread/INFO] [minecraft/MinecraftServer]: Stopping server
[15:17:52] [Server thread/INFO] [minecraft/MinecraftServer]: Saving players
[15:17:52] [Server thread/INFO] [minecraft/MinecraftServer]: Saving worlds
[15:17:52] [Server thread/ERROR] [minecraft/ChunkSerializer]: Chunk file at [-230, -318] is in the wrong location; relocating. (Expected [-230, -318], got [-231, -316])
[15:17:53] [Server thread/ERROR] [minecraft/ChunkSerializer]: Chunk file at [-237, -320] is in the wrong location; relocating. (Expected [-237, -320], got [-232, -318])
[15:17:53] [Server thread/ERROR] [minecraft/ChunkSerializer]: Chunk file at [-236, -320] is in the wrong location; relocating. (Expected [-236, -320], got [-231, -318])
[15:17:53] [Server thread/ERROR] [minecraft/ChunkSerializer]: Chunk file at [-232, -318] is in the wrong location; relocating. (Expected [-232, -318], got [-230, -315])
[15:17:53] [Server thread/ERROR] [minecraft/ChunkSerializer]: Chunk file at [-229, -318] is in the wrong location; relocating. (Expected [-229, -318], got [-229, -316])
[15:17:53] [Server thread/ERROR] [minecraft/ChunkSerializer]: Chunk file at [-232, -317] is in the wrong location; relocating. (Expected [-232, -317], got [-232, -316])
[15:17:53] [Server thread/ERROR] [minecraft/ChunkSerializer]: Chunk file at [-230, -317] is in the wrong location; relocating. (Expected [-230, -317], got [-229, -315])
[15:17:53] [Server thread/ERROR] [minecraft/ChunkSerializer]: Chunk file at [-232, -316] is in the wrong location; relocating. (Expected [-232, -316], got [-232, -315])
[15:17:53] [Server thread/ERROR] [minecraft/ChunkSerializer]: Chunk file at [-230, -316] is in the wrong location; relocating. (Expected [-230, -316], got [-229, -315])
[15:17:53] [Server thread/ERROR] [minecraft/ChunkSerializer]: Chunk file at [-229, -316] is in the wrong location; relocating. (Expected [-229, -316], got [-231, -317])
[15:17:53] [Server thread/ERROR] [minecraft/ChunkSerializer]: Chunk file at [-232, -315] is in the wrong location; relocating. (Expected [-232, -315], got [-230, -317])
[15:17:53] [Server thread/ERROR] [minecraft/ChunkSerializer]: Chunk file at [-230, -315] is in the wrong location; relocating. (Expected [-230, -315], got [-232, -317])
[15:17:53] [Server thread/ERROR] [minecraft/ChunkSerializer]: Chunk file at [-229, -315] is in the wrong location; relocating. (Expected [-229, -315], got [-230, -316])
>
The chunks listed are all in the same region file as the kerosene lamp. None of these chunks are chunkloaded and I don't think those chunks got loaded since I had restored the world from backup.
In any case, the reason I suspect that this is the fault of the kerosene lamp is that I was able to load the chunk just fine in a single-player world, broke the kerosene lamp and daylight sensor, then uploaded it to the server, and finally the chunk corruption stopped.
After Corruption (this was right after I restored from backup, so before it got really bad):
How to reproduce the bug
Screenshot of my set-up is below (except add a daylight sensor on top). The posts below the lamp are camouflaged advanced tubes with a logistics module pointing towards the lamp. The requester frame is requesting biodiesel.
Expected behavior
Chunks shouldn't be mobile.
Additional details
No response
Which Minecraft version are you using?
1.18
Which version of PneumaticCraft: Repressurized are you using?
1.18.2-6.6.4
Crash log
No response
Hmm, that's a weird one. You mentioned none of the chunks were chunkloaded, but I presume the lamp itself is in a loaded chunk if it was actually doing stuff while you weren't around? So then the chunks around the lamp were not chunkloaded, but the lamp itself is?
Looking at the code, there probably is more that could be done to validate chunk loaded status, but it would good to know first exactly what was loaded and what wasn't at the time of the problem.
There is one chunk loaded in the base, and it is not near the kerosene lamp; I think it'd be outside of the lamp's range, anyway.
I've made some changes to the lamp block entity to ensure that chunks are definitely loaded before any invisible light blocks are placed or removed (these are basically air blocks which emit light). If you're in a position to test, https://github.com/TeamPneumatic/pnc-repressurized/actions/runs/3059080678 has the build (download the zip file at the bottom and extract the main JAR file).
If that doesn't help, I'm not sure what else might cause it - the lamp just places and removes blocks as necessary dependent on range and active status; it doesn't do anything fancy or unusual with chunks. But it's possible that causing lighting updates without verifying chunks are loaded could cause some weirdness?
And yes the lamp is definitely far enough away from the loaded chunk. But if the lamp itself isn't chunkloaded, it also can't be doing anything since tile entities in an unloaded chunk don't get ticked. So that's kind of confusing.
Yeah, it really is weird. I admit I really don't know exactly what was going on here, but I'll try testing that build.