# Codex Hub — Help Guide — GUI Clear Confirm
# Run as the player who triggered (at @s via tick)
# Kills floating GUI entities (text_display + interaction) in the area.
# SPARED (2026-06-23): placed furnishings (ec.dec_disp bodies / ec.dec_click footprints /
# ec.shelf_name nameplates) and custom blocks (smithed.entity overlays) are NOT GUIs — this
# sweep used to permanently destroy a player's decor (bodies wiped, anchor orphaned). Decor is
# now excluded so it survives untouched; only genuine floating menu junk is cleared.

# Kill floating text_display entities nearby (except village name signs, shelf nameplates, custom blocks)
execute at @s run kill @e[type=text_display,tag=!bestiary.village.name,tag=!ec.shelf_name,tag=!smithed.entity,distance=..5]

# Kill floating interaction entities nearby (except decor click footprints)
execute at @s run kill @e[type=interaction,tag=!ec.dec_click,distance=..5]

# Kill floating block_display entities nearby (GUI backgrounds; except decor bodies + custom blocks)
execute at @s run kill @e[type=block_display,tag=!ec.dec_disp,tag=!smithed.entity,distance=..5]

# Kill floating item_display entities nearby (GUI icons; except decor item-shapes + custom blocks)
execute at @s run kill @e[type=item_display,tag=!ec.dec_disp,tag=!smithed.entity,distance=..5]

# Kill GUI marker entities (anchors from codex, pet menu, etc.)
execute at @s run kill @e[type=marker,tag=Adv.MenuAnchor,distance=..5]
execute at @s run kill @e[type=marker,tag=companion.menuanchor,distance=..5]

# Reset player GUI state
tag @s remove Adv.InMenu
tag @s remove companion.inmenuv2
scoreboard players set @s adv.gui_cd 0
scoreboard players set @s adv.gui_page 0
scoreboard players set @s adv.gui_section 0

# Confirm
execute at @s if score @s ec.fx_snd matches 1.. run playsound minecraft:block.note_block.hat master @s ~ ~ ~ 0.5 1.8
data modify storage evercraft:notify stage.c set value [{text:"\u2699 ",color:"gray"},{text:"All floating GUIs cleared!",color:"green"}]
scoreboard players set #ndur ec.temp 45
function evercraft:util/notify/emit
