
# -> If block is not in air then return and break
execute unless block ~ ~ ~ #air \
    unless block ~ ~ ~ #campfires run \
        return run \
            function overly_realistic:general/custom_blocks/crucible/crucible_break

# -> If block is inside another custom block then return and break
execute align xyz \
    if entity @n[type=interaction,tag=OverlyRealistic.Block.IsCustomBlock,tag=!OverlyRealistic.Block.IsFullBlock,tag=!OverlyRealistic.Block.CharcoalClump,dx=0,dy=0,dz=0] run \
        return run \
            function overly_realistic:general/custom_blocks/crucible/crucible_break

# -> Advancement
execute if block ~ ~ ~ #campfires[lit=true] run \
    advancement grant @p[tag=OverlyRealistic.Player.PlacedCustomBlock,distance=..64] only overly_realistic:advancements/copper_age/pretty_much_a_microwave

# -> Sound
playsound block.stone.place block @a ~ ~ ~ 0.45 1

# -> Place display
summon interaction ~ ~ ~ {response:1b,Tags:["OverlyRealistic.Block.Crucible","OverlyRealistic.Block.IsCustomBlock"],width:0.5f,height:0.8f,data:{interaction_call:"overly_realistic:general/custom_blocks/crucible/crucible_interaction",break_call:"overly_realistic:general/custom_blocks/crucible/crucible_break"},Passengers:[{id:"item_display",Tags:["OverlyRealistic.Block.Crucible","OverlyRealistic.Block.IsCustomBlock"],item: {count: 1, id: "minecraft:decorated_pot",components:{item_model:"overlyrealistic:blocks/placed_crucible/placed_crucible_empty"}}, transformation: {left_rotation: [0.0f, 0.0f, 0.0f, 1.0f], right_rotation: [0.0f, 0.0f, 0.0f, 1.0f], scale: [0.5f, 0.5f, 0.5f], translation: [0.0f, -0.550f, 0.0f]}}]}

# -> If crucible was placed empty then return
execute if entity @s[tag=OverlyRealistic.Block.Crucible_PlaceEmpty] run \
    return fail

# -> Edit crucible contents
function overly_realistic:general/custom_blocks/crucible/crucible_placement/crucible_place_with_contents with entity @s data
