
# -> If block is not a torch then return and remove the marker
execute unless block ~ ~ ~ #overly_realistic:torches run \
    return run \
        kill @s

# -> Function tag
function #overly_realistic:mechanics/block_torch_operations

# -> Burn entities
#execute align xyz run \
    damage @n[type=!#overly_realistic:no_ai,dx=0,dy=0,dz=0] 2 on_fire

# -> Add to PlayerNearbyTime
scoreboard players add @s OverlyRealistic.World.PlayerNearbyTime 1

# -> If PlayerNearbyTime >= max then affect players
execute if score @s OverlyRealistic.World.PlayerNearbyTime matches 4.. run \
    function overly_realistic:general/campfires/campfire_affect_near_players

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

# -> If fire time >= max then return and remove torch
execute if score @s OverlyRealistic.General.ArbitraryData matches 10800.. run \
    return run \
        function overly_realistic:general/torches/torch_break

# -> Fire sound
playsound block.furnace.fire_crackle block @a ~ ~ ~ 0.6 0

# -> Run fire RNG
execute unless predicate overly_realistic:world/campfire/campfire_fire_rng run \
    return fail

# -> Check for flammable blocks around
execute positioned ~ ~ ~1 run \
    function overly_realistic:general/torches/torch_burn_attempt
execute positioned ~1 ~ ~ run \
    function overly_realistic:general/torches/torch_burn_attempt
execute positioned ~ ~ ~-1 run \
    function overly_realistic:general/torches/torch_burn_attempt
execute positioned ~-1 ~ ~ run \
    function overly_realistic:general/torches/torch_burn_attempt
