Flaxbeard / ImmersivePetroleum

Oil and oil processing for Immersive Engineering
https://minecraft.curseforge.com/projects/immersive-petroleum
54 stars 58 forks source link

Distillery Tower disappearing, and reappearing in wrong place. #202

Open Phlosioneer opened 3 years ago

Phlosioneer commented 3 years ago

Encountered this bug on a sevtech server. I'm reporting this here because I think the issue is in immersive petroleum's multiblock state code, based on F3 stuff described below. I do not expect support specifically for my sevtech setup, I've already found a workaround, but I think such a small reproducible test case is worth posting. Due to the nature of sevtech save files it's impossible to reduce the number of mods to a satisfactory degree.


2020-12-29_22 48 23

(You can see the places where the pipes connect up, and the hitboxes are fine, but the tower is rendered off-kilter. The other tower has no glitches.)

Based on a suggestion by Wuestengecko I opened up F3 and looked at the flags on all the blocks in the tower. I noted which blocks in the normal tower had multiblockslave, facing, etc. set to, and then compared it with the glitched tower. Every block in the glitched tower has all fields as their default values: _0multiblockslave: false, _1dynamicrender: false, boolean0: false, facing: north.

When I build it, it's fine, until I look away. Then, it disappears, and then after looking around a bit more, it reappears in that wrong spot and stays there. It never goes back to normal.

F3+A doesn't fix it. If I break it and re-build it, the same issue occurs. If I log out and log back on, the issue persists. If the server restarts, the issue persists. I'm an admin on the server and downloaded the region file for the region I was in. I created a new world, and then put that region file into it, and I was able to reproduce the problem; I tested breaking it again, and closing/re-opening the world again and it still happened.

After reducing the save file as much as possible, I've discovered that my Tinker's Construct smeltery was causing the issue. A sufficiently large smeltery that overlaps the tower's chunk at all will cause the tower to eventually disappear. Placing the last block of that smeltery makes the tower disappear immediately. Here's the world file; I'm running SevTech 3.1.3.

Test.zip

For that save file, follow these steps to reproduce:

  1. Break the tower if needed, and then place the block you broke back in its correct place.
  2. Form the muliblock distillery with a hammer.
  3. Stand on the diamond blocks, and look away from it for a little bit. Look around in that direction, move around a bit, occationally glance back.
  4. Once the distilllery has turned invisible, stand on any of the gold blocks, and it should reappear in the wrong place. There are many other places to look at it where it does this, but those two spots are the most reliable way. The save file's smeltery is on the 2nd floor in the same chunk as the tower. It shouldn't be too hard to find.

I spent a lot of time trying to reduce the number of mods, and/or remove sevtech entirely. I was able to strip almost everything out, but after I was down to just tinker's construct, immersive engineering, justEnoughIDs, and immersive petroleum, ip started throwing exceptions while reading the file:

[02:01:22] [Server thread/ERROR] [FML]: A TileEntity type flaxbeard.immersivepetroleum.common.blocks.metal.TileEntityPumpjack$TileEntityPumpjackParent has throw an exception trying to write state. It will not persist. Report this to the mod author
java.lang.ArithmeticException: / by zero
    at flaxbeard.immersivepetroleum.api.crafting.PumpjackHandler.getOilWorldInfo(PumpjackHandler.java:141) ~[PumpjackHandler.class:?]
    at flaxbeard.immersivepetroleum.api.crafting.PumpjackHandler.getFluid(PumpjackHandler.java:70) ~[PumpjackHandler.class:?]
    at flaxbeard.immersivepetroleum.common.blocks.metal.TileEntityPumpjack.availableFluid(TileEntityPumpjack.java:88) ~[TileEntityPumpjack.class:?]
    at flaxbeard.immersivepetroleum.common.blocks.metal.TileEntityPumpjack.writeCustomNBT(TileEntityPumpjack.java:147) ~[TileEntityPumpjack.class:?]
    at blusunrize.immersiveengineering.common.blocks.TileEntityIEBase.func_189515_b(TileEntityIEBase.java:48) ~[TileEntityIEBase.class:?]
    at net.minecraft.world.chunk.storage.AnvilChunkLoader.func_75820_a(AnvilChunkLoader.java:383) [aye.class:?]
    at net.minecraft.world.chunk.storage.AnvilChunkLoader.func_75816_a(AnvilChunkLoader.java:174) [aye.class:?]
    at net.minecraft.world.gen.ChunkProviderServer.func_73242_b(ChunkProviderServer.java:202) [on.class:?]
    at net.minecraft.world.gen.ChunkProviderServer.func_186027_a(ChunkProviderServer.java:230) [on.class:?]
    at net.minecraft.world.WorldServer.func_73044_a(WorldServer.java:1007) [oo.class:?]
    at net.minecraft.server.MinecraftServer.func_71267_a(MinecraftServer.java:408) [MinecraftServer.class:?]
    at net.minecraft.server.integrated.IntegratedServer.func_71267_a(IntegratedServer.java:252) [chd.class:?]
    at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:170) [chd.class:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526) [MinecraftServer.class:?]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_231]

There's exactly 64 copies of that exception. And then on the first tick, it finally dies with:

[02:01:23] [Server thread/ERROR] [minecraft/MinecraftServer]: Encountered an unexpected exception
net.minecraft.util.ReportedException: Exception ticking world
    at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:762) ~[MinecraftServer.class:?]
    at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:668) ~[MinecraftServer.class:?]
    at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:185) ~[chd.class:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526) [MinecraftServer.class:?]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_231]
Caused by: java.lang.ArithmeticException: / by zero
    at flaxbeard.immersivepetroleum.api.crafting.PumpjackHandler.getOilWorldInfo(PumpjackHandler.java:141) ~[PumpjackHandler.class:?]
    at flaxbeard.immersivepetroleum.api.crafting.PumpjackHandler.getFluid(PumpjackHandler.java:70) ~[PumpjackHandler.class:?]
    at flaxbeard.immersivepetroleum.common.blocks.metal.TileEntityPumpjack.availableFluid(TileEntityPumpjack.java:88) ~[TileEntityPumpjack.class:?]
    at flaxbeard.immersivepetroleum.common.blocks.metal.TileEntityPumpjack.writeCustomNBT(TileEntityPumpjack.java:147) ~[TileEntityPumpjack.class:?]
    at blusunrize.immersiveengineering.common.blocks.TileEntityIEBase.func_189517_E_(TileEntityIEBase.java:66) ~[TileEntityIEBase.class:?]
    at net.minecraft.network.play.server.SPacketChunkData.<init>(SourceFile:52) ~[je.class:?]
    at net.minecraft.server.management.PlayerChunkMapEntry.func_187272_b(PlayerChunkMapEntry.java:157) ~[ot.class:?]
    at net.minecraft.server.management.PlayerChunkMap.func_72693_b(SourceFile:165) ~[ou.class:?]
    at net.minecraft.world.WorldServer.func_72835_b(WorldServer.java:227) ~[oo.class:?]
    at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:756) ~[MinecraftServer.class:?]
    ... 4 more

Looking at the stack, and looking at the code, I'm guessing that getTotalWeight(...) is returning 0, and then that 0 is used in a modulus (%), which counts as divide by zero. Removing a mod that corresponds to the biome of the test world would make getTotalWeight's invalid biome checks fail, returning 0. I don't know where I would look to try and fix the biome data, if it's even fixable.


I took a look at what the tinker smeltery code is doing. Completing a tinker smeltery does make a multiblock structure, though it shouldn't render anything special as long as there's no fluids inside. It's particularly interesting that the size of the smeltery multiblock matters. I wonder if having too many multiblocks in one chunk is causing something weird to happen?

A friend of mine is going to check the server tomorrow and see if the rendering bug appears for him too, to rule out graphics card / OpenGL as a possible issue. I'll report back when he does.

If there's any other debugging steps you want me to do, let me know! I've mucked around with minecraft mod development before, I know how tricky it can be to reproduce this stuff.


Issue originally posted on #142 but upon reflection it's probably something new.

perecnicek commented 3 years ago

Hi i have this problem on sevtech 3.1.7 did you found fix ? EDIT I find fix. The problem is you cant have tinker smeltery in same chunk with this machines from immersive pretoleum