$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..8,tag=!Happy_Ghast.Is_Placing_Placeable_Areas] at @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..8,tag=!Happy_Ghast.Is_Placing_Placeable_Areas] positioned ~ ~3 ~ if entity @e[type=!#better_happy_ghast:no_mob_exept_player,distance=..2.5] positioned ~ ~-3 ~ unless entity @e[type=minecraft:marker,tag=Happy_Ghast_Supplementary.Placeable_Area,distance=..8] run tag @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..8,tag=!Happy_Ghast.Is_Placing_Placeable_Areas] add Happy_Ghast.Is_Placing_Placeable_Areas

$execute as @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},tag=Happy_Ghast.Is_Placing_Placeable_Areas] at @s store result entity @s Pos[0] int 1 run data get entity @s Pos[0] 1
$execute as @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},tag=Happy_Ghast.Is_Placing_Placeable_Areas] at @s store result entity @s Pos[1] int 1 run data get entity @s Pos[1] 1
$execute as @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},tag=Happy_Ghast.Is_Placing_Placeable_Areas] at @s store result entity @s Pos[2] int 1 run data get entity @s Pos[2] 1

$execute as @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},tag=Happy_Ghast.Is_Placing_Placeable_Areas] run data modify entity @s data.FixedPos.x set from entity @s Pos[0]
$execute as @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},tag=Happy_Ghast.Is_Placing_Placeable_Areas] run data modify entity @s data.FixedPos.y set from entity @s Pos[1]
$execute as @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},tag=Happy_Ghast.Is_Placing_Placeable_Areas] run data modify entity @s data.FixedPos.z set from entity @s Pos[2]

$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..8,tag=Happy_Ghast.Is_Placing_Placeable_Areas] at @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..8,tag=Happy_Ghast.Is_Placing_Placeable_Areas] positioned ~ ~3 ~ run function better_happy_ghast:tick/player/happy_ghast_order_menu/place_placeable_areas/summon_marker_entities {Owner:$(UUID),Happy_Ghast:$(Selected)}

$execute unless entity @e[type=minecraft:marker,tag=Happy_Ghast_Supplementary.Placeable_Area,distance=..8] run tag @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..8,tag=Happy_Ghast.Is_Placing_Placeable_Areas] remove Happy_Ghast.Is_Placing_Placeable_Areas

$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},tag=Happy_Ghast.Is_Placing_Placeable_Areas] unless data entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}}] CustomName at @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..8] positioned ~ ~3 ~ if entity @e[type=!#better_happy_ghast:no_mob_exept_player,distance=..2.5] run tellraw @s[scores={better_happy_ghast.player_configs.send_message=1}] "§7[§r§6§lBetter §r§7§lHappy Ghast§r§7] §aPlaced placeable areas around the Happy Ghast."
$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},tag=Happy_Ghast.Is_Placing_Placeable_Areas] if data entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}}] CustomName at @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..8] positioned ~ ~3 ~ if entity @e[type=!#better_happy_ghast:no_mob_exept_player,distance=..2.5] run tellraw @s[scores={better_happy_ghast.player_configs.send_message=1}] ["§7[§r§6§lBetter §r§7§lHappy Ghast§r§7] §aPlaced placeable areas around the Happy Ghast named \"",{selector:"@e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}}]"},"§a\"."]

$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..8,tag=!Happy_Ghast.Is_Placing_Placeable_Areas] unless data entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}}] CustomName at @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..8] positioned ~ ~3 ~ if entity @e[type=!#better_happy_ghast:no_mob_exept_player,distance=..2.5] run tellraw @s[scores={better_happy_ghast.player_configs.send_message=1}] "§7[§r§6§lBetter §r§7§lHappy Ghast§r§7] §cCan\'t place placeable areas at the Happy Ghast."
$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..8,tag=!Happy_Ghast.Is_Placing_Placeable_Areas] if data entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}}] CustomName at @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..8] positioned ~ ~3 ~ if entity @e[type=!#better_happy_ghast:no_mob_exept_player,distance=..2.5] run tellraw @s[scores={better_happy_ghast.player_configs.send_message=1}] ["§7[§r§6§lBetter §r§7§lHappy Ghast§r§7] §cCan\'t place placeable areas at the Happy Ghast named \"",{selector:"@e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}}]"},"§c\"."]
$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..8,tag=!Happy_Ghast.Is_Placing_Placeable_Areas] at @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..8] positioned ~ ~3 ~ if entity @e[type=!#better_happy_ghast:no_mob_exept_player,distance=..2.5] positioned ~ ~-3 ~ run playsound minecraft:block.stone.place master @s[scores={better_happy_ghast.player_configs.play_sound=1}] ~ ~ ~ 1 0.5

$tag @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},tag=Happy_Ghast.Is_Placing_Placeable_Areas] remove Happy_Ghast.Is_Placing_Placeable_Areas

$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..8] unless data entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}}] CustomName at @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..8] positioned ~ ~3 ~ unless entity @e[type=!#better_happy_ghast:no_mob_exept_player,distance=..2.5] run tellraw @s[scores={better_happy_ghast.player_configs.send_message=1}] "§7[§r§6§lBetter §r§7§lHappy Ghast§r§7] §cThere is no mob or player on the selected Happy Ghast."
$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..8] if data entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}}] CustomName at @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..8] positioned ~ ~3 ~ unless entity @e[type=!#better_happy_ghast:no_mob_exept_player,distance=..2.5] run tellraw @s[scores={better_happy_ghast.player_configs.send_message=1}] ["§7[§r§6§lBetter §r§7§lHappy Ghast§r§7] §cThere is no mob or player on the selected Happy Ghast \"",{selector:"@e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}}]"},"§c\"."]
$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..8] at @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..8] positioned ~ ~3 ~ unless entity @e[type=!#better_happy_ghast:no_mob_exept_player,distance=..2.5] positioned ~ ~-3 ~ run playsound block.note_block.pling master @s[scores={better_happy_ghast.player_configs.play_sound=1}] ~ ~ ~ 1 0.5

$execute unless entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..8] run tellraw @s[scores={better_happy_ghast.player_configs.send_message=1}] "§7[§r§6§lBetter §r§7§lHappy Ghast§r§7] §cNo selected Happy Ghast in a distance of 8 blocks as been found."
$execute unless entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..8] run playsound block.note_block.pling master @s[scores={better_happy_ghast.player_configs.play_sound=1}] ~ ~ ~ 1 0.5