$execute as @n[type=minecraft:happy_ghast,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5,tag=!Happy_Ghast.Is_Mounting] at @s if items entity @s armor.body #minecraft:harnesses if entity @e[limit=1,nbt={UUID:$(to_mount)}] run tag @s add Happy_Ghast.Is_Mounting

$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5,tag=Happy_Ghast.Is_Mounting] run tag @e[limit=1,nbt={UUID:$(to_mount)}] add Happy_Ghast_Passenger.Mounted

$scoreboard players set @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}}] better_happy_ghast.happy_ghast.passengers_count 0
$execute as @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5,tag=Happy_Ghast.Is_Mounting] if predicate better_happy_ghast:have_any_passengers on passengers on vehicle unless score @s better_happy_ghast.happy_ghast.passengers_count matches 4.. run scoreboard players add @s better_happy_ghast.happy_ghast.passengers_count 1

$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5,tag=Happy_Ghast.Is_Mounting] unless score @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5] better_happy_ghast.happy_ghast.passengers_count matches 4.. unless data entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}}] CustomName run tellraw @s[scores={better_happy_ghast.player_configs.send_message=1}] ["§8[§bSky Deck§8] ",{selector:"@e[limit=1,nbt={UUID:$(to_mount)}]"}," §awas mounted."]
$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5,tag=Happy_Ghast.Is_Mounting] unless score @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5] better_happy_ghast.happy_ghast.passengers_count matches 4.. if data entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}}] CustomName run tellraw @s[scores={better_happy_ghast.player_configs.send_message=1}] ["§8[§bSky Deck§8] ",{selector:"@e[limit=1,nbt={UUID:$(to_mount)}]"}," §awas mounted on Happy Ghast named \"",{selector:"@e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},tag=Happy_Ghast.Is_Mounting]"},"§a\"."]
$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5,tag=Happy_Ghast.Is_Mounting] unless score @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5] better_happy_ghast.happy_ghast.passengers_count matches 4.. run playsound minecraft:block.note_block.snare ui @s[scores={better_happy_ghast.player_configs.play_sound=1}] ~ ~ ~ 1 2

$execute unless items entity @n[type=minecraft:happy_ghast,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5] armor.body #minecraft:harnesses unless data entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}}] CustomName run tellraw @s[scores={better_happy_ghast.player_configs.send_message=1}] "§8[§bSky Deck§8] §cThe selected Happy Ghast has no harness equipped."
$execute unless items entity @n[type=minecraft:happy_ghast,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5] armor.body #minecraft:harnesses if data entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}}] CustomName run tellraw @s[scores={better_happy_ghast.player_configs.send_message=1}] ["§8[§bSky Deck§8] §cHappy Ghast named \"",{selector:"@n[type=minecraft:happy_ghast,nbt={UUID:$(Selected),data:{Owner:$(UUID)}}]"},"§c\" has no harness equipped."]
$execute if items entity @n[type=minecraft:happy_ghast,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5,tag=!Happy_Ghast.Is_Mounting] armor.body #minecraft:harnesses unless data entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}}] CustomName run tellraw @s[scores={better_happy_ghast.player_configs.send_message=1}] "§8[§bSky Deck§8] §cNo mountable entity found within 6.5 blocks."
$execute if items entity @n[type=minecraft:happy_ghast,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5,tag=!Happy_Ghast.Is_Mounting] armor.body #minecraft:harnesses if data entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}}] CustomName run tellraw @s[scores={better_happy_ghast.player_configs.send_message=1}] ["§8[§bSky Deck§8] §cNo mountable entity found near Happy Ghast named \"",{selector:"@n[type=minecraft:happy_ghast,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},tag=!Happy_Ghast.Is_Mounting]"},"§c\"."]
$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5,tag=!Happy_Ghast.Is_Mounting] run playsound minecraft:block.note_block.snare ui @s[scores={better_happy_ghast.player_configs.play_sound=1}] ~ ~ ~ 1 0.5

$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5,scores={better_happy_ghast.happy_ghast.passengers_count=..3},tag=Happy_Ghast.Is_Mounting] at @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5,tag=Happy_Ghast.Is_Mounting] run ride @e[limit=1,nbt={UUID:$(to_mount)}] mount @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5,tag=Happy_Ghast.Is_Mounting]

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

$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5] unless data entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}}] CustomName if score @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5] better_happy_ghast.happy_ghast.passengers_count matches 4.. run tellraw @s[scores={better_happy_ghast.player_configs.send_message=1}] "§8[§bSky Deck§8] §cPassenger slots are full."
$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5] if data entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}}] CustomName if score @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5] better_happy_ghast.happy_ghast.passengers_count matches 4.. run tellraw @s[scores={better_happy_ghast.player_configs.send_message=1}] ["§8[§bSky Deck§8] §cPassenger slots are full on Happy Ghast named \"",{selector:"@e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},tag=!Happy_Ghast.Is_Mounting]"},"§c\"."]
$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5] unless score @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5] better_happy_ghast.happy_ghast.passengers_count matches ..3 run playsound minecraft:block.note_block.snare ui @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=..6.5] run tellraw @s[scores={better_happy_ghast.player_configs.send_message=1}] "§8[§bSky Deck§8] §cNo selected Happy Ghast was found within 6.5 blocks."
$execute unless entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5] run playsound minecraft:block.amethyst_block.step ui @s[scores={better_happy_ghast.player_configs.play_sound=1}] ~ ~ ~ 1 0.8