
# -> If current block is not a campfire then remove
execute unless block ~ ~ ~ #campfires run \
    return run \
        kill @s

# -> If there are flammable items above the campfire then add to fire
execute if block ~ ~ ~ #campfires[lit=true] \
    align xyz \
    as @n[type=item,dx=0,dy=0,dz=0] \
    if items entity @s contents #overly_realistic:adds_to_campfires_all run \
        function overly_realistic:general/campfires/fuel_add_to_campfire

# -> If it is raining and the campfire is exposed then extinguish
#execute if score @s OverlyRealistic.World.CampfireFireTime matches 1.. \
    if predicate overly_realistic:world/weather/is_raining_thundering \
    if predicate overly_realistic:player/temperature/is_outside run \
        function overly_realistic:general/campfires/campfire_extinguish

# -> If there is no fire time left then set lit to false
execute if score @s OverlyRealistic.World.CampfireFireTime matches ..0 run \
    return run \
        setblock ~ ~ ~ campfire[lit=false]

# -> Particles
particle minecraft:campfire_signal_smoke ~ ~ ~ 0 1 0 0.1 0 force @a
particle minecraft:campfire_signal_smoke ~ ~ ~ 0 1 0 0.1 0 force @a

# -> Extended particles
execute if score @s OverlyRealistic.World.CampfireFireTime matches 500.. run \
    particle minecraft:campfire_signal_smoke ~ ~1 ~ 0 3 0 0.1 0 force @a
execute if score @s OverlyRealistic.World.CampfireFireTime matches 1500.. run \
    particle minecraft:campfire_signal_smoke ~ ~1 ~ 0 4 0 0.1 0 force @a
execute if score @s OverlyRealistic.World.CampfireFireTime matches 3000.. run \
    particle minecraft:campfire_signal_smoke ~ ~1 ~ 0 5 0 0.1 0 force @a

# -> Low lifetime particles
execute if score @s OverlyRealistic.World.CampfireFireTime matches ..100 run \
    particle large_smoke ~ ~0 ~ 0 0 0 0.01 2 normal @a

# -> Progress fire time
scoreboard players remove @s OverlyRealistic.World.CampfireFireTime 1

# -> 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
