Applied Energistics 2

Applied Energistics 2

160M Downloads

Memory card is not completely cleared

Mithi83 opened this issue ยท 2 comments

commented

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

  1. Take a blank memory card from the creative tab, inspect NBT: {count: 1, id: "ae2:memory_card"}
  2. 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"}
  3. 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

commented

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.

commented

Yeah I had the idea that since tags now can be defined on anything, we could also define a tag on data component types!
And then use that to just clear everything in that tag, when you clear the memory card.
I probably just forgot to define the tag in the datagen.