# Repairs newly added items if they were already obtained before they were fully wired up.
# Uses current advancements if present, and falls back to current inventories for pre-fix worlds.

execute if entity @a[advancements={minecraft:border/oxidized_copper_trapdoor=true}] unless data storage bordercraft:once {item:{oxidized_copper_trapdoor:1b}} run function bordercraft:reloadui/repair_oxidized_copper_trapdoor
execute if entity @a[advancements={minecraft:border/cactus_flower=true}] unless data storage bordercraft:once {item:{cactus_flower:1b}} run function bordercraft:reloadui/repair_cactus_flower
execute if entity @a[advancements={minecraft:border/copper_torch=true}] unless data storage bordercraft:once {item:{copper_torch:1b}} run function bordercraft:reloadui/repair_copper_torch
execute if entity @a[advancements={minecraft:border/waxed_lightning_rod=true}] unless data storage bordercraft:once {item:{waxed_lightning_rod:1b}} run function bordercraft:reloadui/repair_waxed_lightning_rod

execute if entity @a[nbt={Inventory:[{id:"minecraft:oxidized_copper_trapdoor"}]}] unless data storage bordercraft:once {item:{oxidized_copper_trapdoor:1b}} run function bordercraft:reloadui/repair_oxidized_copper_trapdoor
execute if entity @a[nbt={Inventory:[{id:"minecraft:cactus_flower"}]}] unless data storage bordercraft:once {item:{cactus_flower:1b}} run function bordercraft:reloadui/repair_cactus_flower
execute if entity @a[nbt={Inventory:[{id:"minecraft:copper_torch"}]}] unless data storage bordercraft:once {item:{copper_torch:1b}} run function bordercraft:reloadui/repair_copper_torch
execute if entity @a[nbt={Inventory:[{id:"minecraft:waxed_lightning_rod"}]}] unless data storage bordercraft:once {item:{waxed_lightning_rod:1b}} run function bordercraft:reloadui/repair_waxed_lightning_rod
execute if entity @a[advancements={minecraft:border/exposed_copper_bars=true}] unless data storage bordercraft:once {item:{exposed_copper_bars:1b}} run function bordercraft:reloadui/repair_exposed_copper_bars
execute if entity @a[nbt={Inventory:[{id:"minecraft:exposed_copper_bars"}]}] unless data storage bordercraft:once {item:{exposed_copper_bars:1b}} run function bordercraft:reloadui/repair_exposed_copper_bars
execute if entity @a[advancements={minecraft:border/weathered_copper_bars=true}] unless data storage bordercraft:once {item:{weathered_copper_bars:1b}} run function bordercraft:reloadui/repair_weathered_copper_bars
execute if entity @a[nbt={Inventory:[{id:"minecraft:weathered_copper_bars"}]}] unless data storage bordercraft:once {item:{weathered_copper_bars:1b}} run function bordercraft:reloadui/repair_weathered_copper_bars
execute if entity @a[advancements={minecraft:border/oxidized_copper_bars=true}] unless data storage bordercraft:once {item:{oxidized_copper_bars:1b}} run function bordercraft:reloadui/repair_oxidized_copper_bars
execute if entity @a[nbt={Inventory:[{id:"minecraft:oxidized_copper_bars"}]}] unless data storage bordercraft:once {item:{oxidized_copper_bars:1b}} run function bordercraft:reloadui/repair_oxidized_copper_bars
execute if entity @a[advancements={minecraft:border/waxed_copper_bars=true}] unless data storage bordercraft:once {item:{waxed_copper_bars:1b}} run function bordercraft:reloadui/repair_waxed_copper_bars
execute if entity @a[nbt={Inventory:[{id:"minecraft:waxed_copper_bars"}]}] unless data storage bordercraft:once {item:{waxed_copper_bars:1b}} run function bordercraft:reloadui/repair_waxed_copper_bars
execute if entity @a[advancements={minecraft:border/waxed_exposed_copper_bars=true}] unless data storage bordercraft:once {item:{waxed_exposed_copper_bars:1b}} run function bordercraft:reloadui/repair_waxed_exposed_copper_bars
execute if entity @a[nbt={Inventory:[{id:"minecraft:waxed_exposed_copper_bars"}]}] unless data storage bordercraft:once {item:{waxed_exposed_copper_bars:1b}} run function bordercraft:reloadui/repair_waxed_exposed_copper_bars
execute if entity @a[advancements={minecraft:border/waxed_weathered_copper_bars=true}] unless data storage bordercraft:once {item:{waxed_weathered_copper_bars:1b}} run function bordercraft:reloadui/repair_waxed_weathered_copper_bars
execute if entity @a[nbt={Inventory:[{id:"minecraft:waxed_weathered_copper_bars"}]}] unless data storage bordercraft:once {item:{waxed_weathered_copper_bars:1b}} run function bordercraft:reloadui/repair_waxed_weathered_copper_bars
execute if entity @a[advancements={minecraft:border/waxed_oxidized_copper_bars=true}] unless data storage bordercraft:once {item:{waxed_oxidized_copper_bars:1b}} run function bordercraft:reloadui/repair_waxed_oxidized_copper_bars
execute if entity @a[nbt={Inventory:[{id:"minecraft:waxed_oxidized_copper_bars"}]}] unless data storage bordercraft:once {item:{waxed_oxidized_copper_bars:1b}} run function bordercraft:reloadui/repair_waxed_oxidized_copper_bars
