apace100/apoli

[1.20.1 & 1.20.2] Merge NBT [Equipped item Action] issue

Reniel80 opened this issue · 1 comments

merge_nbt (Item action type) from equipped_item_action (Entity action type) in active_self (Power type) it's not merging as it should... it's replacing all NBT data of the equipped item.

Code Example:

{
"type": "origins:active_self",
"entity_action": {
"type": "origins:equipped_item_action",
"equipment_slot": "mainhand",
"action": {
"type": "origins:merge_nbt",
"nbt": "{Enchantments:[{id:"minecraft:bane_of_arthropods",lvl:3s}]}"
}
},
"cooldown": 1,
"key": {
"key": "key.origins.primary_active"
}
}

If i have an enchanted item in the main hand.. all enchantments are replaced by bane of arthropods in this case.

The merge_nbt item action type does not replace all NBTs, it only replaces the NBTs that you've specified, which in this case, is the Enchantments NBT. This is the intentional behavior of merging NBTs, which you can also observe by using the minecraft:set_nbt type in an item modifier (since both uses the same logic)

If you don't want to replace already defined enchantments, then you should be using an item modifier with the minecraft:set_enchantments type. It has an add boolean field, which determines whether the specified enchantments should be added, or outright replace the current enchantments from the affected item stack