TeamDman / SuperFactoryManager

Mozilla Public License 2.0
49 stars 19 forks source link

Fix inventory shift #62

Closed BlueAgent closed 4 years ago

BlueAgent commented 4 years ago

This PR attempts to fix https://github.com/TeamDman/SuperFactoryManager/issues/55

Prior to this PR, if the cable or connected inventories were modified and not updated before saving, it could result in the ID mappings being shifted around. This is because the IDs are based on the order of the DFS from the manager through cables.

When updateInventories() is called, it would do this DFS and re-map the old IDs to the new ones. The issue results from the initialization of the inventories which it does said DFS to initialize and assumes the IDs will match up, this may not be the case.

So the fix this PR does is saving the positions of the inventories associated with the current IDs to NBT so that when the manager is initialized and does the DFS for the first time, it has the old positions to update the ID mappings with.