Closed searica closed 11 months ago
There's one major bug, where switching a restricted item with a non-restricted item causes it to be deleted.
When this is resolved and no other issues pop up, I'm going to merging it.
There's some minor cleanup left, like removing debug logging and moving the displayed text to a language file but I'll do that when the rest is done and it's fully merged.
Oh damn, thank you for catching that bug! I've just pushed some commits that include a new patch to InventoryGrid.DropItem that appears to fix the bug when I was testing it. I also removed the debug logging and cleaned up the code style a bit more.
Everything seems to be working fine now, thanks again!
This PR adds a toggle-able feature that restricts the dynamic containers it adds to only allow placing items of a specific type within the dynamic container. These restrictions can be toggled on/off in-game safely and restrictions are ignored whenever a container is loading from ZDO so that items that may have been placed inside it when it was not restricted are not accidentally deleted when loading the container with restrictions enabled.
I have tested that this feature works as intended in single-player when used alongside QuickStackStore and AzuAutoStore, even if non-allowed item are present in a container both mods do not stack new items to it if the restrictions are enabled. It also works with FastItemTransfer, AzuHoverStats, ContentsWithin, AzuCraftyBoxes, and CraftFromContainers.
All test were performing using each method of placing items in containers:
I was not able to test in a multiplayer setting, so I have not tested for possible bugs when multiple players are using the mod or when MultiUserChest is also present.
Most of the changes to code and functionally is contained within the RestrictContainers.cs file and I have done my best to match the existing code conventions within the mod.