[Bug] Duplication of Fluid Containers when crafting Treated Planks
TheonlyTazz opened this issue · 7 comments
Description of the issue:
When crafting Treated Planks with Fluid Containers (tested with Thermal Tanks and Tinkers Seared Tanks) and you have multiple Tanks stacked ontop of eachother, the liquid gets subtracted and the tanks get duped.
This has been Tested on an Instance with just IE and Tinkers Construct
Versions & Modlist
IE Version: ImmersiveEngineering-1.18.2-8.0.2-149.jar
Tinkers Construct: Construct-1.18.2-3.5.1.31.jar
Forge: 40.1.52
Additional Information
This has been reported to the FTB Modpack Issue tracker:
FTBTeam/FTB-Modpack-Issues#1004
Any update if this is getting fixed? and if this is not an issue that IE is fixing, please do tell me
This issue is likely caused by the fact that in forge's logic, stacked fluid containers do not expose a fluid handler. I suspect this is the offending code in IE: https://github.com/BluSunrize/ImmersiveEngineering/blob/1.18.2/src/main/java/blusunrize/immersiveengineering/common/crafting/fluidaware/IngredientFluidStack.java#L107-L117. Currently you do a check if handler.isPresent()
which the logic looks correct, but your fallback to just input
is going to cause dupes in the case someone uses your fluid ingredient for a non-fluid container (I know, user error, but we can at least give them reasonable behavior if they do)
The quick fix is to switch your fallback to input.getContainerItem()
, this is what you use for non-fluid stack ingredients. The better fix is making a copy with stack size 1 before getting the fluid handler, I suspect here will work as you are already making a copy there. Probably worth doing both fixes.
My plan was to limit the recipe to just not work when there is a stacked container, because if you pull 1 bucket out of a thing that holds 16, you then need to split the stack and stuff.
Vanilla has code to split the stack already, and to shrink the stack, its how it does it for stacked items with containers. The problem is this edge case in forge's logic causes you to return a "remaining item" with a stack size of 2, they should always have a stack size of 1. The vanilla getContainerItem
notably is always stack size 1, and getRemainingItems
is expected to only ever return an item with stack size 1. So no reason to not make a copy of the fluid container with stack size 1 for the remainder of your logic, vanilla will handle shrinking it for you.