
# -> 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/hardened_clay_mold/hardened_clay_mold_break_from_place

# -> 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,dx=0,dy=0,dz=0] run \
        return run \
            function overly_realistic:general/custom_blocks/hardened_clay_mold/hardened_clay_mold_break_from_place

# -> Advancement
advancement grant @p[tag=OverlyRealistic.Player.PlacedCustomBlock,distance=..64] only overly_realistic:advancements/copper_age/molded_building

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

# -> Place display
summon interaction ~ ~ ~ {response:1b,Tags:["OverlyRealistic.Block.HardenedClayMold","OverlyRealistic.Block.IsCustomBlock","OverlyRealistic.Block.HardenedClayMold_TempMold","OverlyRealistic.Block.SpecializedLifeTimeBlock"],width:0.8f,height:0.3f,data:{or_custom_block_id:"hardened_clay_mold",interaction_call:"overly_realistic:general/custom_blocks/hardened_clay_mold/hardened_clay_mold_interaction",break_call:"overly_realistic:general/custom_blocks/hardened_clay_mold/hardened_clay_mold_break"},Passengers:[{id:"item_display",Tags:["OverlyRealistic.Block.HardenedClayMold"],item: {components: {"minecraft:custom_data": {IsCustomBlock: "hardened_clay_mold", or_edited_item: 1b}, "minecraft:item_model": "overlyrealistic:blocks/hardened_clay_molds/empty/hardened_clay_mold_axe_head", "minecraft:entity_data": {Tags: ["OverlyRealistic.Block.IsCustomBlockMarker", "OverlyRealistic.Block.HardenedClayMold_HasMoldType"], data: {or_is_custom_block:1b,IsCustomBlock: "hardened_clay_mold", clay_mold_type: "axe_head", mold_contents: "empty", placement_function: "overly_realistic:general/custom_blocks/hardened_clay_mold/hardened_clay_mold_pre_placed"}, id: "minecraft:marker"}, "minecraft:item_model": "minecraft:brick", "minecraft:item_name": {color: "white", extra: [{color: "gray", text: "[Axe Head]"}], text: "Hardened Clay Mold "}, "minecraft:lore": [{color: "gray", italic: 0b, text: "[Empty]"}], "minecraft:max_stack_size": 1}, count: 1, id: "minecraft:allay_spawn_egg"}, transformation: {left_rotation: [-5.1391045E-5f, -0.7071068f, 0.7071068f, -5.1391045E-5f], right_rotation: [0.0f, 0.0f, 0.0f, 1.0f], scale: [0.7500002f, 0.7500001f, 0.74999976f], translation: [0.0f, -0.27499998f, 0.0f]}}]}

# -> If clay mold has been molded already then place with data
#execute if entity @s[tag=OverlyRealistic.Block.HardenedClayMold_HasMoldType] run \
    return run \
        function overly_realistic:general/custom_blocks/hardened_clay_mold/hardened_clay_mold_placed_edit_with_data with entity @s data

# -> Get if the mold has contents
scoreboard players reset #or.hardened_clay_mold_has_contents OverlyRealistic.General.ArbitraryData
execute if entity @s[tag=OverlyRealistic.Block.HardenedClayMold_HasContents] run \
    scoreboard players set #or.hardened_clay_mold_has_contents OverlyRealistic.General.ArbitraryData 1

# -> Get if the mold drops an item
scoreboard players reset #or.hardened_clay_mold_drops_item OverlyRealistic.General.ArbitraryData
execute if entity @s[tag=OverlyRealistic.Block.HardenedClayMold_DropsItem] run \
    scoreboard players set #or.hardened_clay_mold_drops_item OverlyRealistic.General.ArbitraryData 1

# -> Store mold data
data modify storage overly_realistic:blocks hardened_clay_mold_data set from entity @s data

# -> Edit interaction & display
execute align xyz \
    as @n[type=interaction,tag=OverlyRealistic.Block.HardenedClayMold_TempMold,dx=0,dy=0,dz=0,sort=arbitrary] run \
        function overly_realistic:general/custom_blocks/hardened_clay_mold/hardened_clay_mold_placed_edit with storage overly_realistic:blocks hardened_clay_mold_data
