Bundivision
ArchivedFixes MC-269644 by forcing the weight of every item to be at least 1.
Compatibility
Minecraft: Java Edition
Platforms
Supported environments
75% of ad revenue goes to creators
Support creators and Modrinth ad-free with Modrinth+Links
Creators
Details
As of 24w14a, Mojang has silently fixed this bug to the point where it no longer crashes the game. This mod is no longer relevant, and thus, will not be maintained.
This mod fixes MC-269644 by forcing items entering bundles to have a weight of at least 1. This mod should work on any version starting in 24w12a and ending whenever Mojang fixes this bug. As this may not be a detailed enough description on its own, here is a simplified explanation of why the crash happens to begin with:
When inserting an item into a bundle, that item is given a weight based on its stack size. Items that stack up to 64 have a weight of 1, those that stack up to 16 have a weight of 4, and those that only stack up to 1 have a weight of 64. This is calculated as 64 divided by the maximum stack size of the item.
If an item has a stack size greater than 64, this ends up being less than 1, which gets truncated to 0 due to how integer division works. Another section of code divides a number by this value, and dividing by zero throws an ArithmeticException which promptly crashes the game.
The fix for this is rather simple. If the final weight would end up being less than 1, this mod forces it to become 1 instead. This is a rather bandaid-y solution, and Mojang could come up with something better, but this is at least better than crashing the game outright.