execute unless entity @e[type=marker,distance=..40,tag=KyuPreventHomeSpell] run execute if entity @e[name=DayQ,tag=HomeMadeQ] run tellraw @s[level=5..,tag=!HomeCD,nbt={Dimension:"minecraft:overworld"}] ["",{"text":"Portal made!","color":"green"}]
execute unless entity @e[type=marker,distance=..40,tag=KyuPreventHomeSpell] run execute if entity @e[name=DayQ,tag=HomeMadeQ] run execute at @s[level=5..,tag=!HomeCD,nbt={Dimension:"minecraft:overworld"}] run summon minecraft:armor_stand ~2 ~2 ~  {CustomName:"\"HomeTP\"",NoGravity:1,Invisible:1b,Silent:1b}
execute unless entity @e[type=marker,distance=..40,tag=KyuPreventHomeSpell] run execute at @e[name=HomeTP,tag=!Coords] run fill ~-1 ~-3 ~-1 ~1 ~-3 ~1 minecraft:black_glazed_terracotta
execute unless entity @e[type=marker,distance=..40,tag=KyuPreventHomeSpell] run execute at @e[name=HomeTP,tag=!Coords] run fill ~-1 ~ ~-1 ~1 ~-2 ~1 minecraft:end_stone_brick_wall
execute unless entity @e[type=marker,distance=..40,tag=KyuPreventHomeSpell] run execute at @e[name=HomeTP,tag=!Coords] run fill ~-1 ~-2 ~-1 ~1 ~-2 ~1 minecraft:chiseled_red_sandstone replace minecraft:end_stone_brick_wall
execute unless entity @e[type=marker,distance=..40,tag=KyuPreventHomeSpell] run execute at @e[name=HomeTP,tag=!Coords] run fill ~-1 ~-1 ~ ~1 ~-2 ~ minecraft:air
execute unless entity @e[type=marker,distance=..40,tag=KyuPreventHomeSpell] run execute at @e[name=HomeTP,tag=!Coords] run fill ~ ~-1 ~1 ~ ~-2 ~-1 minecraft:air
execute unless entity @e[type=marker,distance=..40,tag=KyuPreventHomeSpell] run execute at @e[name=HomeTP,tag=!Coords] run setblock ~ ~-2 ~ minecraft:end_gateway
execute unless entity @e[type=marker,distance=..40,tag=KyuPreventHomeSpell] run execute at @e[name=HomeTP,tag=!Coords] run execute store result block ~ ~-2 ~ ExitPortal.X int 1 run scoreboard players get @e[name=DayQ,limit=1] PosX
execute unless entity @e[type=marker,distance=..40,tag=KyuPreventHomeSpell] run execute at @e[name=HomeTP,tag=!Coords] run execute store result block ~ ~-2 ~ ExitPortal.Y int 1 run scoreboard players get @e[name=DayQ,limit=1] PosY
execute unless entity @e[type=marker,distance=..40,tag=KyuPreventHomeSpell] run execute at @e[name=HomeTP,tag=!Coords] run execute store result block ~ ~-2 ~ ExitPortal.Z int 1 run scoreboard players get @e[name=DayQ,limit=1] PosZ
execute unless entity @e[type=marker,distance=..40,tag=KyuPreventHomeSpell] run execute at @e[name=HomeTP,tag=!Coords] run data merge block ~ ~-2 ~ {ExactTeleport:1}
execute unless entity @e[type=marker,distance=..40,tag=KyuPreventHomeSpell] run execute at @e[name=HomeTP,tag=!Coords] run clone ~ ~-2 ~ ~ ~-2 ~ ~ ~-1 ~ replace force
execute unless entity @e[type=marker,distance=..40,tag=KyuPreventHomeSpell] run tellraw @s[tag=HomeCD] ["",{"text":"You have already used this spell today - You may use it again tomorrow.","color":"yellow"}]
execute unless entity @e[type=marker,distance=..40,tag=KyuPreventHomeSpell] run tellraw @s[level=..4] ["",{"text":"You do not have the xp required to cast this.","color":"gold"}]
execute unless entity @e[type=marker,distance=..40,tag=KyuPreventHomeSpell] run tellraw @s[nbt=!{Dimension:"minecraft:overworld"}] ["",{"text":"You must be in the overworld to do this.","color":"gold"}]
execute unless entity @e[type=marker,distance=..40,tag=KyuPreventHomeSpell] run execute if entity @e[name=DayQ,tag=HomeMadeQ] run tag @s[level=5..,nbt={Dimension:"minecraft:overworld"}] add HomeCD2
execute unless entity @e[type=marker,distance=..40,tag=KyuPreventHomeSpell] run execute if entity @e[name=DayQ,tag=HomeMadeQ] run xp add @s[tag=!HomeCD,level=5..,nbt={Dimension:"minecraft:overworld"}] -55 points
execute unless entity @e[type=marker,distance=..40,tag=KyuPreventHomeSpell] run execute if entity @e[name=DayQ,tag=HomeMadeQ] run tag @a[nbt={Dimension:"minecraft:overworld"},tag=HomeCD2] add HomeCD
execute unless entity @e[type=marker,distance=..40,tag=KyuPreventHomeSpell] run tag @a remove HomeCD2
execute unless entity @e[type=marker,distance=..40,tag=KyuPreventHomeSpell] run execute unless entity @e[name=DayQ,tag=HomeMadeQ] run tellraw @s ["",{"text":"You must set a world home first in order to teleport to it!","color":"gold"}]
scoreboard players set @s KyuSpells 0

execute unless entity @e[type=marker,distance=..40,tag=KyuPreventHomeSpell] run execute at @s run playsound minecraft:item.bottle.fill_dragonbreath ambient @a[distance=..20] ~ ~ ~ 5 0.75 1





execute if entity @e[type=marker,distance=..40,tag=KyuPreventHomeSpell] run tellraw @s ["",{"text":"A mysterious force prevents you from using this spell here.","color":"gold"}]


