How to replace every specific item anywhere in my inventory with a specific item?
I am trying to make a datapack for weighted armors by replacing all normal armors with ones with specific attributes. I understand how attributes work, but I can't seem to find a way to replace normal ones correctly. I tried to modify nbt data of items in your inventory, but it appears impossible to do.
I'm not sure if it's possible to replace armour anywhere in a player's inventory, but you would be able to replace the armour if a player equips it using the execute
command
execute as @a[nbt={Inventory:[{Slot: 102b,id:"minecraft:netherite_chestplate",Count:1b}]}] run replaceitem entity @s armor.chest netherite_chestplate{NBT}
This command would replace a netherite chestplate in the chestplate slot of a player with a chestplate with modified NBT data (I assume you're using this for attributes, if so, just replace the "NBT" placeholder with the actual NBT data)
Command found here: Can you /testfor a specific inventory slot?