Immersive Engineering

Immersive Engineering

134M Downloads

[1.16.5] Filling Jerrycan with water causes client crash

NielsPilgaard opened this issue ยท 6 comments

commented

Description of the issue:

Holding a Jerrycan and right-clicking while looking at water causes a client crash - The server the client is connected to does not crash.

Crashlog:

https://gist.github.com/NillerMedDild/3f26127eb12afc0a76133417dc3086a5

Versions & Modlist

  • ImmersiveEngineering-1.16.5-4.2.1-131
  • Forge-1.16.5-36.0.40
  • Apotheosis-1.16.3-4.4.1 (Also mentioned in crash report)

Modpack is Enigmatica 6 v0.4.0: https://www.curseforge.com/minecraft/modpacks/enigmatica6/files/3214669
Modlist: https://github.com/NillerMedDild/Enigmatica6/blob/master/MODLIST.md

commented

Caused by Apotheosis' placable items or something like that? It looks like they have removed the code that caused that issue, I presume their next release would fix this.

commented

Cool, thank you :)

commented

That code in place is for a pseudo-event hook that I have in place to allow me to hook onto item usage, the call being done from my code is just a copy of ItemStack#onItemUse(ItemUseContext, Function<ItemUseContext, ActionResultType>) which itself is called from a copy of ItemStack#onItemUse(ItemUseContext). That code is presently missing as it is being changed into an event in Placebo @ https://github.com/Shadows-of-Fire/Placebo/blob/ba42eb8bb9f5271fa48a7f216a65dff4a466b879/src/main/java/shadows/placebo/events/PlaceboEventHooks.java#L23-L49

That code itself needs to be improved to not clone vanilla code, but unless you had a hook in either of those methods that I'm interrupting, this crash is still very much coming out of something that ImmEng is doing, and could show up without apoth present

commented

Right, so the only way this code can crash is when a FluidStack somehow ends up being null. It shouldn't ever be null, because all methods related to that return EMPTY, but never null.

EXCEPT, that Forge made a change to that in Version 40 (which is what you produced this crash on):
https://github.com/pupnewfster/MinecraftForge/blob/dispense_behavior/src/main/java/net/minecraftforge/fluids/FluidUtil.java#L445

That wonderful change that @pupnewfster made makes it so that the method can return Optional.empty(), which it previously only did when it was given an Empty ItemStack.
That's a change in Forge's behavior we obviously hadn't accounted for when that code was originally written, so now it crashes.

So yeah, Forge changed method behavior here, and our safeguard that existed for catching empty ItemStacks now also triggers falsely on empty containers.
I'll try to reproduce this with Version 40 in my dev environment and then I'll produce a fix.

commented

Thank you :)

commented

It doesn't crash anymore, but the Jerrycan is unable to pick up fluids from the world now, and if you fill it up through a tank and try to place the liquid a bucket is removed from the Jerrycan, but nothing is placed in-world. Tested in SP with Creosote from IE.