Usually, this wouldn't be an issue. But there's a problem with my code running. I want to have a custom crafting recipe for Netherite Boots. It works fine, but the problem arises when you have more than one barrel around you. (My datapack has it so when you right click with a carrot on a stick and there's a barrel with the correct ingredients in the correct spots in it, it crafts the item.)
If there's just one barrel, then it works perfectly, no bugs. But if you have more than one barrel around you, the final product will be copied into every barrel around you. Here is my code.
execute unless data block ~1 ~ ~ Items[7] run data remove block ~1 ~ ~ Items
execute unless data block ~1 ~ ~ Items[7] run item replace block ~1 ~ ~ container.0 with minecraft:netherite_boots{display:{Name:'[{"text":"Diamondrite Boots","italic":false}]',Lore:['[{"text":"B O O T S.","italic":false,"bold":true,"color":"dark_red"}]']},Enchantments:[{}],AttributeModifiers:[{AttributeName:"generic.armor",Amount:5,Slot:feet,Name:"generic.armor",UUID:[I;-12307,2572,184118,-5144]},{AttributeName:"generic.armor_toughness",Amount:5,Name:"generic.armor_toughness",UUID:[I;-12307,30262,19112,-60524],Slot:"feet"},{AttributeName:"generic.knockback_resistance",Amount:0.2,Name:"generic.knockback_resistance",UUID:[I;-12307,30362,19112,-60724],Slot:"feet"},{AttributeName:"generic.movement_speed",Amount:0.4,Slot:feet,Operation:1,Name:"generic.movement_speed",UUID:[I;-12307,31662,19112,-63324]}]} 1
execute unless data block ~-1 ~ ~ Items[7] run data remove block ~-1 ~ ~ Items
execute unless data block ~-1 ~ ~ Items[7] run item replace block ~-1 ~ ~ container.0 with minecraft:netherite_boots{display:{Name:'[{"text":"Diamondrite Boots","italic":false}]',Lore:['[{"text":"Extremely tough boots.","italic":false,"bold":true,"color":"dark_red"}]']},Enchantments:[{}],AttributeModifiers:[{AttributeName:"generic.armor",Amount:5,Slot:feet,Name:"generic.armor",UUID:[I;-12307,2572,184118,-5144]},{AttributeName:"generic.armor_toughness",Amount:5,Name:"generic.armor_toughness",UUID:[I;-12307,30262,19112,-60524],Slot:"feet"},{AttributeName:"generic.knockback_resistance",Amount:0.2,Name:"generic.knockback_resistance",UUID:[I;-12307,30362,19112,-60724],Slot:"feet"},{AttributeName:"generic.movement_speed",Amount:0.4,Slot:feet,Operation:1,Name:"generic.movement_speed",UUID:[I;-12307,31662,19112,-63324]}]} 1
execute unless data block ~ ~ ~1 Items[7] run data remove block ~ ~ ~1 Items
execute unless data block ~ ~ ~1 Items[7] run item replace block ~ ~ ~1 container.0 with minecraft:netherite_boots{display:{Name:'[{"text":"Diamondrite Boots","italic":false}]',Lore:['[{"text":"Extremely tough boots.","italic":false,"bold":true,"color":"dark_red"}]']},Enchantments:[{}],AttributeModifiers:[{AttributeName:"generic.armor",Amount:5,Slot:feet,Name:"generic.armor",UUID:[I;-12307,2572,184118,-5144]},{AttributeName:"generic.armor_toughness",Amount:5,Name:"generic.armor_toughness",UUID:[I;-12307,30262,19112,-60524],Slot:"feet"},{AttributeName:"generic.knockback_resistance",Amount:0.2,Name:"generic.knockback_resistance",UUID:[I;-12307,30362,19112,-60724],Slot:"feet"},{AttributeName:"generic.movement_speed",Amount:0.4,Slot:feet,Operation:1,Name:"generic.movement_speed",UUID:[I;-12307,31662,19112,-63324]}]} 1
execute unless data block ~ ~ ~-1 Items[7] run data remove block ~ ~ ~-1 Items
execute unless data block ~ ~ ~-1 Items[7] run item replace block ~ ~ ~-1 container.0 with minecraft:netherite_boots{display:{Name:'[{"text":"Diamondrite Boots","italic":false}]',Lore:['[{"text":"Extremely tough boots.","italic":false,"bold":true,"color":"dark_red"}]']},Enchantments:[{}],AttributeModifiers:[{AttributeName:"generic.armor",Amount:5,Slot:feet,Name:"generic.armor",UUID:[I;-12307,2572,184118,-5144]},{AttributeName:"generic.armor_toughness",Amount:5,Name:"generic.armor_toughness",UUID:[I;-12307,30262,19112,-60524],Slot:"feet"},{AttributeName:"generic.knockback_resistance",Amount:0.2,Name:"generic.knockback_resistance",UUID:[I;-12307,30362,19112,-60724],Slot:"feet"},{AttributeName:"generic.movement_speed",Amount:0.4,Slot:feet,Operation:1,Name:"generic.movement_speed",UUID:[I;-12307,31662,19112,-63324]}]} 1