Modern Industrialization

Modern Industrialization

12M Downloads

Fluid pipe tries to insert stack with size 0

raoulvdberge opened this issue ยท 4 comments

commented

Hello there,

In a Refined Storage network, try to attach a fluid pipe to an Refined Storage Interface.

Then, configure a fluid filter in the pipe.

Following crash happens:

java.lang.IllegalArgumentException: Amount must be larger than 0
	at TRANSFORMER/[email protected]/com.refinedmods.refinedstorage.api.core.CoreValidations.validateLargerThanZero(CoreValidations.java:55) ~[%23186!/:?] {re:classloading}
	at TRANSFORMER/[email protected]/com.refinedmods.refinedstorage.api.resource.ResourceAmount.validate(ResourceAmount.java:21) ~[%23186!/:?] {re:classloading}
	at TRANSFORMER/[email protected]/com.refinedmods.refinedstorage.api.resource.ResourceAmount.<init>(ResourceAmount.java:17) ~[%23186!/:?] {re:classloading}
	at TRANSFORMER/[email protected]/com.refinedmods.refinedstorage.common.support.resource.ResourceContainerImpl.insertIntoEmptySlot(ResourceContainerImpl.java:326) ~[%23186!/:?] {re:classloading}
	at TRANSFORMER/[email protected]/com.refinedmods.refinedstorage.common.support.resource.ResourceContainerImpl.insert(ResourceContainerImpl.java:303) ~[%23186!/:?] {re:classloading}
	at TRANSFORMER/[email protected]/com.refinedmods.refinedstorage.neoforge.support.resource.ResourceContainerFluidHandlerAdapter.fill(ResourceContainerFluidHandlerAdapter.java:55) ~[%23186!/:?] {re:classloading}
	at TRANSFORMER/[email protected]/aztech.modern_industrialization.util.IOFluidHandler.fill(IOFluidHandler.java:61) ~[Modern-Industrialization-2.3.10.jar%23185!/:?] {re:classloading}
	at TRANSFORMER/[email protected]/aztech.modern_industrialization.pipes.fluid.FluidNetwork$TransferOperation$1.internalTransfer(FluidNetwork.java:176) ~[Modern-Industrialization-2.3.10.jar%23185!/:?] {re:classloading}

It appears like the fluid pipe tries to insert a stack with size 0:

Image

Modern Industrialization v2.3.10

Relevant RS issue: refinedmods/refinedstorage2#997

commented

Seems like it's allowed by API indeed, because of lack of specification.

However, is there any use in sending an empty stack to fill?

commented

Hey that's actually allowed by the API as far as I know. Most of the base implementations have an early return for empty stacks that catches this case at least. Only strictly negative amounts are problematic.

commented

I've added checks in my code to check for empty stacks, should be more resilient now.

If you want, you can close this.

However, I'd rather not waste CPU cycles calling methods without any relevant data :-)

commented

You're already doing the check with your validateLargerThanZero method, seems like a net 0 change in cpu cycles to me. (or net -1 if you count the method call itsef :P)