Memory card is not completely cleared
Mithi83 opened this issue ยท 2 comments
Describe the bug
Right-clicking a memory card used for P2P Tunnel setup does not properly clear the memory card.
How to reproduce the bug
- Take a blank memory card from the creative tab, inspect NBT: {count: 1, id: "ae2:memory_card"}
- Right-click a ME P2P Tunnel to initialize the card, inspect NBT: {components: {"ae2:memory_card_colors": ["black", "black", "green", "green", "cyan", "cyan", "red", "red"], "ae2:exported_p2p_frequency": 16360s, "ae2:exported_settings_source": {translate: "item.ae2.me_p2p_tunnel"}, "ae2:exported_p2p_type": "ae2:me_p2p_tunnel"}, count: 1, id: "ae2:memory_card"}
- Right-click into the air, notice message "Memory card cleared." Inspect NBT: {components: {"ae2:exported_p2p_frequency": 16360s, "ae2:exported_settings_source": {translate: "item.ae2.me_p2p_tunnel"}, "ae2:exported_p2p_type": "ae2:me_p2p_tunnel"}, count: 1, id: "ae2:memory_card"}
Expected behavior
I'd expect the NBT after a clear to match that of a totally blank card.
Additional details
1.20.1 was still ok, git blame makes me think the bug was introduced in 1.20.5
Which minecraft version are you using?
1.21
On which mod loaders does it happen?
NeoForge
Crash log
Self compiled 1.21
Manually adding card.remove(AEComponents.EXPORTED_*) calls (for EXPORTED_P2P_TYPE, EXPORTED_P2P_FREQUENCY, and EXPORTED_SETTINGS_SOURCE in my example) makes things work as expected.
The intention of the code seems to be that all those potential AEComponents.EXPORTED_* are stored inside the BuiltInRegistries.DATA_COMPONENT_TYPE.getTagOrEmpty(ConventionTags.EXPORTED_SETTINGS) and removed from the memory card by iterating over that container. Debug prints showed that the for-loop is never called, leading me to believe that the registry is never filled in the first place.