
# -> If this block was triggered by a specialized drop then return and operate
#execute if entity @s[tag=OverlyRealistic.CaveInPosition_SpecializedItem] run \
    return run \
        function overly_realistic:players/block_placement/block_collapse/cave_in/cave_in_block_collapse_from_specialized_drop

# -> Remove previous item (bandaid fix)
item replace block -29999985 2 -29999985 container.0 with air

# -> Get block
loot replace block -29999985 2 -29999985 container.0 mine ~ ~ ~ netherite_pickaxe[enchantments={silk_touch:1}]

# -> Create falling block
execute if block ~ ~ ~ #overly_realistic:collapse_block_can_damage_entities \
    align xyz \
    positioned ~0.5 ~ ~0.5 run \
        function overly_realistic:players/block_placement/block_collapse/block_collapse_create_block_does_damage with block -29999985 2 -29999985 Items.[{Slot:0b}]
execute unless block ~ ~ ~ #overly_realistic:collapse_block_can_damage_entities \
    align xyz \
    positioned ~0.5 ~ ~0.5 run \
        function overly_realistic:players/block_placement/block_collapse/block_collapse_create_block_no_damage with block -29999985 2 -29999985 Items.[{Slot:0b}]

# -> If block can cause a cave-in then operate 
execute unless score #or.disable_cave_in_possibility OverlyRealistic.General.ArbitraryData matches 1.. \
    if block ~ ~ ~ #overly_realistic:can_cause_cave_in run \
        function overly_realistic:players/block_placement/block_collapse/cave_in/cave_in_spread

# -> Remove block
setblock ~ ~ ~ air replace

# -> If 'cave-in sounds' is enabled, on RNG, play sound
execute if score #or.setting.cavein_sounds OverlyRealistic.Settings.ArbitrarySetting matches 1 \
    if predicate overly_realistic:world/block_physics/cave_in_sound_rng run \
        playsound overlyrealistic:block.cavein.collapse block @a ~ ~ ~ 1 1

# -> If 'cave-in particles' is enabled, display particle
execute if score #or.setting.cavein_particles OverlyRealistic.Settings.ArbitrarySetting matches 1 run \
    particle campfire_signal_smoke ~ ~ ~ 0.1 0.1 0.1 0.01 2 normal @a


# -> Remove marker if possible
kill @s[type=marker]