Fluid dupe with Inspirations mod
josephcsible opened this issue ยท 3 comments
Issue description:
It's possible to create unlimited quantities of any fluid when using both Mekanism and Inspirations.
Steps to reproduce:
- Put some fluid in a cauldron
- Attach an elite mechanical pipe to the cauldron, and set it to extract from it
- "Prime" the pipe by adding fluid to the cauldron until the pipe is full and the cauldron stops draining. This will take 17 buckets: 16 to fill the pipe and 1 more to fill the cauldron
- Connect the other end of the pipe to something that uses less than 1000mB of that fluid at a time
Version (make sure you are on the latest version before reporting):
Forge: 14.23.5.2831
Mekanism: 9.7.7.378
Other relevant version: Inspirations 0.2.4
If a (crash)log is relevant for this issue, link it here: (It's almost always relevant)
Nothing appears in the log about the dupe.
The cause of this problem is here:
First, we call container.drain(1600, false)
on the cauldron to see how much fluid it will give us. It only has 1000mB in it, so it returns a FluidStack with an amount of 1000. Next, we call takeFluid(1000, true)
to try to put all 1000mB in the pipe. Suppose that there's 15800mB in the pipe, so it can only hold 200mB more. Now, takeFluid
will only add 200mB (since that's all that fits), and will thus return 200. Finally, we call container.drain(200, true)
to remove the fluid from the cauldron. Since the cauldron doesn't have the granularity to remove only 200mB of fluid, that returns 0 and it removes nothing. Our mistake is that we ignore the result of that call and let the fluid be added to the pipe anyway.
My report about this at KnightMiner/Inspirations#124 was closed, with @KnightMiner saying the problem is on our side.
I guess the only way to handle this is to simulate the amount we have room for instead of the amount we are able to pull. Probably by making a method getAvailablePull
, that does a Math.min(getPullAmount(), space remaining)
. Honestly we probably should go through and check to see if there are any other places we have fluid pulling (or gas pulling) and make sure they also don't try to simulate more than they can receive anyways.
Fix available in 9.7.8