Fabric API

Fabric API

108M Downloads

Oversized stacks should be handled more gracefully

warjort opened this issue ยท 3 comments

commented

As per #2196 and its discussion #2199

Code like this

int insertedAmount = (int) Math.min(maxAmount, getCapacity(insertedVariant) - currentStack.getCount());

can lead to unloadble worlds when the capacity < stack size.

It will always crash because working item amounts become negative which fails sanity checks elsewhere.
The crash means it can't be fixed in game.

Reasons for this to occur maybe:

  • A bug in a mod
  • Somebody cheating in an oversize stack
  • Installing a mod that increases max stack sizes then removing that mod

The transfer api should handle these oversize stacks more gracefully without crashing.

commented

The crash was caused by hopper attempting to use overstacked(10) water bottles.

commented

Probably a good addition to #2189.

commented

It's good practice to have the return inserted inside the if (inserted > 0) { for exactly this reason, I don't know why I didn't do that for a few implementations... #2189 contains a fix now.