
# -> Untag player
tag @s remove OverlyRealistic.Player.InventoryChangedTemperatureModifier

# -> Reset temperature modifier
scoreboard players reset @s OverlyRealistic.Player.TemperatureModifier

scoreboard players set #or.temperature_modifier_helmet OverlyRealistic.General.ArbitraryData 0
scoreboard players set #or.temperature_modifier_chestplate OverlyRealistic.General.ArbitraryData 0
scoreboard players set #or.temperature_modifier_leggings OverlyRealistic.General.ArbitraryData 0
scoreboard players set #or.temperature_modifier_boots OverlyRealistic.General.ArbitraryData 0

# -> Get temperature from helmet
execute if items entity @s armor.head *[custom_data~{or_has_temperature_modifier:1b}] run \
    function overly_realistic:players/armor/temperature_modifiers/modify_from_helmet
execute if items entity @s armor.chest *[custom_data~{or_has_temperature_modifier:1b}] run \
    function overly_realistic:players/armor/temperature_modifiers/modify_from_chestplate
execute if items entity @s armor.legs *[custom_data~{or_has_temperature_modifier:1b}] run \
    function overly_realistic:players/armor/temperature_modifiers/modify_from_leggings
execute if items entity @s armor.feet *[custom_data~{or_has_temperature_modifier:1b}] run \
    function overly_realistic:players/armor/temperature_modifiers/modify_from_boots

# -> Add up modifiers
scoreboard players operation @s OverlyRealistic.Player.TemperatureModifier += #or.temperature_modifier_helmet OverlyRealistic.General.ArbitraryData
scoreboard players operation @s OverlyRealistic.Player.TemperatureModifier += #or.temperature_modifier_chestplate OverlyRealistic.General.ArbitraryData
scoreboard players operation @s OverlyRealistic.Player.TemperatureModifier += #or.temperature_modifier_leggings OverlyRealistic.General.ArbitraryData
scoreboard players operation @s OverlyRealistic.Player.TemperatureModifier += #or.temperature_modifier_boots OverlyRealistic.General.ArbitraryData
