Toolbox incorrectly serialized/deserialized when used as MountedStorage on contraption #5083
Labels
status: confirmed
Issue's details are known, it is consistently reproducible, and it needs a fix
type: bug
Issue where something isn't working
Describe the Bug
If you include a toolbox on a contraption (or another other modded storage that extends ItemStackHandler) when the BlockEntity (ToolboxBlockEntity) is used to create a MountedStorage it will use the extended implementation of ItemStackHandler (ToolboxInventory), but only until it is serialized/deserialized.
When the Contraption is deserialized the MountedStorage only uses a plain ItemStackHandler and not the extended version of ItemStackHandler. At which point it will ignore all of the extra handling from the extended class. This can lead to especially strange behavior in the case of toolboxes which have 8 compartments with 4 stacks per compartment because it can result in the contraption while using the base class ItemStackHandler filling every stack with a different item completely ignoring filters.
When the contraption is finally disassembled, the ToolboxInventory has setStackInSlot called for each stack in the base ItemStackHandler as part of the MountedStorage which leads the toolbox in a strange state.
Reproduction Steps
-- Note the blocks are picked up not dropped
-- Note the toolbox will contain 8 of the blocks but the 9th block will be missing.
-- Note that the filter for something other than the block is still there.
Expected Result
One of the following should be true:
This expends to other modded storages that implement the getCapability and have an extension of ItemStackHandler.
Screenshots and Videos
No response
Crash Report or Log
No response
Operating System
Windows 11
Mod Version
0.5.1d
Minecraft Version
1.19.2
Forge Version
43.2.14
Other Mods
No response
Additional Context
You may want to check the the ItemStackHandlers are exactly ItemStackHandlers.
Or you could go the route of adding a storage registry like was done in https://github.com/juh9870/MoreMountedStorages but require the mods that wish to add support to add their own handlers and mod specific registry components rather than building the fragile integrations into Create itself.
If you want more detailed pointers into the code let me know I've spent a long time figuring this out.
The text was updated successfully, but these errors were encountered: