PrettyPipes icon indicating copy to clipboard operation
PrettyPipes copied to clipboard

Quick and dirty workaround for functional storage drawers

Open unikmhz opened this issue 1 year ago • 2 comments

Sorry if this PR is subpar, as I have not touched anything Java in about 15 years.

Finally tried to address a long-standing bug in mod interaction between PrettyPipes and Functional Storage: sporadic inability to insert into functional storage drawers when a void upgrade is installed.

If my code reading is correct - this is caused by integer overflow here, as Functional Storage adds a pseudo-slot to its inventory when voiding upgrade is installed, which has a slot limit of Integer.MAX_VALUE.

More correct way to handle this is to use saturating math, or check for overflows explicitly. But my Java is way too rusty to remember how to do that, sorry.

Closes #224 Related to discussion in #131

unikmhz avatar Jan 10 '25 05:01 unikmhz

Aaah, that totally makes sense, thanks so much for this investigation! I'm used to working with C#/.NET nowadays, where integer overflows throw an exception rather than silently wrapping around in a checked context by default, so I probably never would've caught this hahaha

I'll have to see if I want to merge this exact version of the fix, but this is definitely very helpful either way, thanks so much! :)

Ellpeck avatar Jan 10 '25 10:01 Ellpeck

I googled around a bit, and can rewrite this as an explicit exception check, using Math.addExact. Would you be interested in that?

unikmhz avatar Jan 10 '25 12:01 unikmhz