Add configurable ender chest and shulker box slot counts#13733
Add configurable ender chest and shulker box slot counts#13733cev-api wants to merge 2 commits intoPaperMC:mainfrom
Conversation
It's not difficult at all to replace default ender chest inventory with custom inventory that saves items in PDC. You can ask for help in discord if you'd like, but I doubt paper would start becoming more like purpur by adding such features |
A PDC-backed inventory is still a custom replacement for the native container. Supporting this natively removes the need for faux-inventory plugins, avoids repeated implementations of the same feature, and reduces the desync/duplication risk that comes from emulating container behavior in plugin code. |
|
While doing it in the server is the only real way that entirely makes sense, we're generally not too happy with breaking the vanilla save layout, we expect people to be able to take their save data back to vanilla without any real issues |
This would be an opt-in non-vanilla feature, so any incompatibility when switching back to the standard server would result from an intentional server-side choice. Thus if a server enables larger native containers and later returns to software that only supports the default storage layout, loss of data beyond those limits seems like an expected consequence of that transition. |
| case 54: | ||
| return net.minecraft.world.inventory.MenuType.GENERIC_9x6; | ||
| default: | ||
| throw new IllegalArgumentException("Unsupported shulker inventory size " + inventory.getSize()); |
There was a problem hiding this comment.
Instead of throwing new IllegalArgumentException("Unsupported shulker inventory size " + inventory.getSize()), it would be better to return net.minecraft.world.inventory.MenuType.SHULKER_BOX and log a warning such as LOGGER.warn("Unsupported shulker inventory size {}, using the default value.", inventory.getSize());. This makes the code more compatible and resilient by falling back to a safe default instead of failing completely.
There was a problem hiding this comment.
I tested invalid config values locally. These are normalized during configuration load before they reach CraftContainer, so -52 became 9 for ender chests and 992 became 54 for shulker boxes, with startup warnings logged. Because of that, unsupported sizes should not occur through normal configuration, which is why I left the IllegalArgumentException in place here rather than silently falling back to a potentially mismatched menu type.
[15:30:56 WARN]: [io.papermc.paper.configuration.GlobalConfiguration] Invalid misc.ender-chest-slot-count value '-52', using '9'. Valid values are multiples of 9 between 9 and 54.
[15:30:56 WARN]: [io.papermc.paper.configuration.GlobalConfiguration] Invalid misc.shulker-box-slot-count value '992', using '54'. Valid values are multiples of 9 between 9 and 54.
I also tested reducing the configured size after storing items. In that case, items outside the reduced container size were not recovered after increasing the size again and restarting.
This adds configurable slot counts for ender chests and shulker boxes.
Summary:
misc.ender-chest-slot-countandmisc.shulker-box-slot-counttoGlobalConfigurationReasoning:
Ender chest and shulker box capacity changes are difficult to implement cleanly at the plugin layer, because the underlying container size, menu type, and inventory view handling all need to stay in sync. In practice, plugins that provide larger ender chests or shulker boxes often have to emulate the inventory with separate storage and custom handling rather than using the native container directly. This leads to repeated re-implementation of the same behavior across many plugins and increases the likelihood of edge cases such as desync or duplication issues. This change provides a built-in implementation for that customization while preserving the default 27-slot behavior.
Testing: