
# -> Check for hot blocks
scoreboard players set #or.plate_is_in_hot_block OverlyRealistic.General.ArbitraryData 0
execute if block ~ ~ ~ #overly_realistic:forging_plate/is_hot_block run \
    scoreboard players set #or.plate_is_in_hot_block OverlyRealistic.General.ArbitraryData 1
execute if block ~ ~-1 ~ #overly_realistic:forging_plate/is_hot_block run \
    scoreboard players set #or.plate_is_in_hot_block OverlyRealistic.General.ArbitraryData 1
execute if block ~ ~ ~ #overly_realistic:forging_plate/is_cool_block run \
    scoreboard players set #or.plate_is_in_hot_block OverlyRealistic.General.ArbitraryData 0

# -> If plate is not connected to a hot block then return
execute unless score #or.plate_is_in_hot_block OverlyRealistic.General.ArbitraryData matches 1 run \
    return fail

# -> Particle
particle campfire_signal_smoke ~ ~ ~ 0 0.25 0 0.1 0 normal @a
particle campfire_signal_smoke ~ ~ ~ 0.1 0.1 0.1 0.01 1 normal @a

# -> Add to time value
scoreboard players add @s OverlyRealistic.General.ArbitraryData 1

# -> Add extra to time value if the block heating the forging plate is lava
execute if block ~ ~-1 ~ lava run \
    scoreboard players add @s OverlyRealistic.General.ArbitraryData 1
execute if block ~ ~ ~ lava run \
    scoreboard players add @s OverlyRealistic.General.ArbitraryData 1

# -> If time value < max then return
execute unless score @s OverlyRealistic.General.ArbitraryData matches 350.. run \
    return fail

# -> Sound
playsound block.lava.extinguish block @a ~ ~ ~ 0.8 1

# -> Particle
particle campfire_signal_smoke ~ ~ ~ 0.1 0.1 0.1 0.01 8 normal @a
particle lava ~ ~ ~ 0.1 0.1 0.1 0.1 3 normal @a

# -> Modify item
execute on passengers \
    if entity @s[tag=OverlyRealistic.Block.ForgingPlate_DisplayedItem] run \
        function overly_realistic:general/custom_blocks/forging_plate/looping_operations/heat_item_modify

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