
# -> If plate does not have item then return
execute unless entity @s[tag=OverlyRealistic.Block.ForgingPlate_Status_Filled] run \
    return fail

# -> If the plate's item is not forgeable then return
execute on passengers \
    unless items entity @s[tag=OverlyRealistic.Block.ForgingPlate_DisplayedItem] contents *[custom_data~{current_process:"heated"}] run \
        return fail

# -> Sound
playsound minecraft:block.anvil.land block @a ~ ~ ~ 0.85 1.3

# -> Add to percentage
scoreboard players set #or.forging_plate_hit_percentage OverlyRealistic.General.ArbitraryData 0
execute on target run \
    function overly_realistic:general/custom_blocks/forging_plate/interactions/shaping_tool_forge_process/power_usage/add_to_percentage

# -> Add to current percentage
scoreboard players operation @s OverlyRealistic.General.ArbitraryData += #or.forging_plate_hit_percentage OverlyRealistic.General.ArbitraryData

# -> Clamp
scoreboard players set @s[scores={OverlyRealistic.General.ArbitraryData=101..}] OverlyRealistic.General.ArbitraryData 100

# -> Globalize
scoreboard players operation #or.forging_plate_hit_percentage OverlyRealistic.General.ArbitraryData = @s OverlyRealistic.General.ArbitraryData

# -> Operate on player
execute on target run \
    function overly_realistic:general/custom_blocks/forging_plate/interactions/shaping_tool_forge_process/player_use_forging_hammer

# -> If process percentage < 100 then return
execute unless score @s OverlyRealistic.General.ArbitraryData matches 100.. run \
    return fail

# -> Sound
playsound minecraft:block.anvil.land block @a ~ ~ ~ 0.85 2

# -> Modify item
execute on passengers run \
    function overly_realistic:general/custom_blocks/forging_plate/interactions/forging_hammer_interactions/shape_item_modify

# -> Set data
tag @s add OverlyRealistic.Block.ForgingPlate_RequiresCoolBlock
tag @s add OverlyRealistic.Block.ForgingPlate_RequiresLoopingLogic
scoreboard players set @s OverlyRealistic.General.ArbitraryData 0
