mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-02-10 08:00:05 +00:00
![Jonathan Coates](/assets/img/avatar_default.png)
The most annoying thing about pocket computers is handling computer state (label, upgrades, etc...). Unlike other computers, which are tied to a specific block entity, pocket computers float untethered. We can't hold a reference to a specific item stack (as the computer might be moved between inventories, crafted, etc...), so instead we explicitly sync data between the computer and *current* stack, whenever the holding player/entity is ticked. In ed0b156e05ff64784f2f80346c82ab5142d954dc I rewrote this syncing code to always treat the computer as the source of truth. Upgrades would be copied to the computer, but never the other way round. However, this meant that upgrades obtained by crafting would never be detected, requiring the computer to be destroyed and recreated. A more long-term fix here is probably to rewrite IPocketAccess to only allow updating upgrade data on the main thread, and when we have a valid PocketHolder. This is a breaking API change though, and so will have to wait for 1.21.3. For now, we just add a hook that refreshes the upgrade after crafting. Fixes #1957