
# --> Item/block check
execute if items entity @s weapon.mainhand flint[custom_data~{IsFlintFlake:1b}] run \
    return run \
        execute if block ~ ~ ~ #overly_realistic:is_stone run \ 
            function overly_realistic:players/misc/campfire/flint_flake_operate
execute if items entity @s weapon.mainhand iron_axe[custom_data~{IsForgingHammer:1b}] run \
    return run \
        execute if block ~ ~ ~ anvil run \ 
            function overly_realistic:players/misc/campfire/forging_hammer_operate
execute if items entity @s weapon.mainhand iron_sword[custom_data~{current_process:"forged"}] run \
    return run \
        execute if block ~ ~ ~ grindstone run \ 
            function overly_realistic:players/misc/campfire/grindstone_sharpen_tool_operate
execute unless block ~ ~ ~ campfire run \
    return fail

# -> Particle
particle small_flame ~0.5 ~0.5 ~0.5 0.15 0.15 0.15 0.01 1 normal @a
particle campfire_cosy_smoke ~0.5 ~0.5 ~0.5 0 0 0 0.001 1 normal @a
particle flame ~0.5 ~0.5 ~0.5 0 0 0 0.001 1 normal @a

# -> Sound
playsound block.fire.extinguish block @a ~0.5 ~0.5 ~0.5 0.15 2

# -> On RNG, decrease stamina
execute if predicate overly_realistic:world/campfire/stamina_decrease_rng run \
    scoreboard players remove @s OverlyRealistic.Player.Stats.Stamina 1

# -> Increase fire starter uses
scoreboard players add @s OverlyRealistic.Player.FireStarterUses 1

# -> On RNG fail, return
execute unless score @s OverlyRealistic.Player.FireStarterUses matches 60.. \
    unless predicate overly_realistic:world/campfire/light_campfire_rng run \
        return fail

# -> Reset fire starter uses
scoreboard players reset @s OverlyRealistic.Player.FireStarterUses

# -> Particle
particle lava ~0.5 ~0.5 ~0.5 0 0 0 0.1 3 normal @a

# -> Light campfire
setblock ~ ~ ~ campfire[lit=true]

# -> Set fire time
execute positioned ~0.5 ~0.5 ~0.5 run \
    scoreboard players set @n[type=marker,tag=OverlyRealistic.CampfireBlock,distance=..0.1] OverlyRealistic.World.CampfireFireTime 500

# -> Break fire starter
item replace entity @s weapon.mainhand with air
execute at @s \
    anchored eyes run \
        particle item{item:"stick"} ^ ^ ^0.1 0 0 0 0.1 3 normal @s
playsound entity.zombie.break_wooden_door block @a ~0.5 ~0.5 ~0.5 0.4 1.6