
# -> Sound
playsound minecraft:item.ink_sac.use block @a ~ ~ ~ 0.55 1



# -> Rotate perm marker
execute rotated as @p[tag=OverlyRealistic.Player.PlacedCustomBlock] run \
    rotate 00000001-0000-002a-0000-00010000002a ~ ~

# -> Get rotation
execute store result score #or.global OverlyRealistic.General.ArbitraryData run \
    data get entity 00000001-0000-002a-0000-00010000002a Rotation[0]

# -> Reset success
scoreboard players set #or.placement_success OverlyRealistic.General.ArbitraryData 0

# -> Set rotation data
function overly_realistic:general/custom_blocks/cave_painting/place_cave_painting_from_rotation

# -> If placement was successful or has already broken then return
execute if score #or.placement_success OverlyRealistic.General.ArbitraryData matches 1.. run \
    return fail

# -> South
execute unless block ~ ~ ~1 #air run \
    return run \
        function overly_realistic:general/custom_blocks/cave_painting/place_painting/painting_s with entity @s data

# -> East
execute unless block ~1 ~ ~ #air run \
    return run \
        function overly_realistic:general/custom_blocks/cave_painting/place_painting/painting_e with entity @s data

# -> West
execute unless block ~-1 ~ ~ #air run \
    return run \
        function overly_realistic:general/custom_blocks/cave_painting/place_painting/painting_w with entity @s data

# -> North
execute unless block ~ ~ ~-1 #air run \
    return run \
        function overly_realistic:general/custom_blocks/cave_painting/place_painting/painting_n with entity @s data

# -> Break if no support was found
function overly_realistic:general/custom_blocks/cave_painting/cave_painting_break_from_placement with entity @s data
