
# --> (@EVENT: clicked on square 4 in a clay mold ui /// ID: 100,005)

# -> Globalize clay mold ID
scoreboard players operation #or.current_clay_mold_id OverlyRealistic.General.ArbitraryData = @s OverlyRealistic.Player.UseItem_ClayMold

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

# -> Toggle square from clay mold
execute if score @s OverlyRealistic.World.ClayMoldSquare_4 matches 1 \
    as @e[type=interaction,tag=OverlyRealistic.Block.ClayMold,distance=..16] \
        if score @s OverlyRealistic.General.ArbitraryData = #or.current_clay_mold_id OverlyRealistic.General.ArbitraryData run \
            function overly_realistic:players/non_setting_triggers/events/event_100005/unmold_square
execute unless score @s OverlyRealistic.World.ClayMoldSquare_4 matches 1 \
    as @e[type=interaction,tag=OverlyRealistic.Block.ClayMold,distance=..16] \
        if score @s OverlyRealistic.General.ArbitraryData = #or.current_clay_mold_id OverlyRealistic.General.ArbitraryData run \
            function overly_realistic:players/non_setting_triggers/events/event_100005/mold_square

# -> If unsuccessful then return
execute if score #or.clay_mold_interaction_success OverlyRealistic.General.ArbitraryData matches 0 run \
    return fail

# -> Message
tellraw @s \
    [\
        {text:"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"},\
        {text:"Molded a piece of clay!\nCheck your advancements tab to check clay mold recipes!\n",color:"#5e5e5e"}\
    ]

# -> Particles
execute anchored eyes run \
    particle block{block_state:"clay"} ^ ^ ^0.7 0 0 0 0.1 3 normal @a

# -> Sound
playsound block.gravel.break block @a ~ ~ ~ 0.3 1

# -> Show UI
function overly_realistic:general/custom_blocks/clay_mold/player_interact_with_clay_mold
