#execute at @e[tag=NoScoreSetMush,tag=!MushNoDelete] run tag @p[distance=..50,sort=nearest] add NoChestKyu
#execute at @e[tag=NoScoreSetMush,tag=!MushNoDelete] if block ~1 ~5 ~1 minecraft:ender_chest run fill ~-1 ~5 ~1 ~-1 ~5 ~1 minecraft:chest[facing=north]{Items:[{Slot:0b,id:"minecraft:written_book",Count:1b,tag:{HideFlags:1,Enchantments:[{id:"minecraft:unbreaking",lvl:10}],display:{Name:"{\"text\":\"Portable Mushroom House\",\"color\":\"red\"}",Lore:["\"Mushy!\""]},title:"",author:"",pages:["{\"text\":\"Portable Mushroom\",\"color\":\"red\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/trigger KyuMushy set 1\"},\"extra\":[{\"text\":\"\\n-------------------\",\"color\":\"gray\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/trigger KyuMushy set 1\"}},{\"text\":\"\\nClick to summon a\\ncute mushroom sprout, which quickly grows into an entire mushroom house! Once used, the book will disappear into the chest inside of the mushroom house, and once taken out, the house will vanish.\",\"color\":\"black\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/trigger KyuMushy set 1\"}}]}"]}}]} destroy
#execute at @e[tag=NoScoreSetMush,tag=!MushNoDelete] unless block ~1 ~5 ~1 minecraft:ender_chest run fill ~-1 ~5 ~1 ~-1 ~5 ~1 minecraft:chest[facing=north]{Items:[{Slot:0b,id:"minecraft:written_book",Count:1b,tag:{HideFlags:1,Enchantments:[{id:"minecraft:unbreaking",lvl:10}],display:{Name:"{\"text\":\"Portable Mushroom House\",\"color\":\"red\"}",Lore:["\"Mushy!\""]},title:"",author:"",pages:["{\"text\":\"Portable Mushroom\",\"color\":\"red\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/trigger KyuMushy set 1\"},\"extra\":[{\"text\":\"\\n-------------------\",\"color\":\"gray\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/trigger KyuMushy set 1\"}},{\"text\":\"\\nClick to summon a\\ncute mushroom sprout, which quickly grows into an entire mushroom house! Once used, the book will disappear into the chest inside of the mushroom house, and once taken out, the house will vanish.\",\"color\":\"black\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/trigger KyuMushy set 2\"}}]}"]}}]} destroy
execute at @e[tag=NoScoreSetMush,tag=!MushNoDelete] run execute if block ~1 ~5 ~1 minecraft:ender_chest run fill ~-1 ~5 ~1 ~-1 ~5 ~1 minecraft:chest[facing=north] destroy
execute at @e[tag=NoScoreSetMush,tag=!MushNoDelete] run execute if block ~1 ~5 ~1 minecraft:ender_chest run loot insert ~-1 ~5 ~1 loot minecraft:customitems/mushroomhouse
execute at @e[tag=NoScoreSetMush,tag=!MushNoDelete] run execute unless block ~1 ~5 ~1 minecraft:ender_chest run fill ~-1 ~5 ~1 ~-1 ~5 ~1 minecraft:chest[facing=north] destroy
execute at @e[tag=NoScoreSetMush,tag=!MushNoDelete] run execute unless block ~1 ~5 ~1 minecraft:ender_chest run loot insert ~-1 ~5 ~1 loot minecraft:customitems/mushroomhousenochest



execute at @e[tag=NoScoreSetMush,tag=!MushNoDelete] run fill ~-1 ~5 ~1 ~-1 ~5 ~1 air destroy
execute at @e[tag=NoScoreSetMush,tag=!MushNoDelete] run fill ~ ~5 ~1 ~ ~ ~1 air replace ladder
execute at @e[tag=NoScoreSetMush,tag=!MushNoDelete] run fill ~2 ~2 ~2 ~-2 ~8 ~-2 air replace minecraft:red_bed
execute at @e[tag=NoScoreSetMush,tag=!MushNoDelete] run fill ~ ~5 ~-1 ~ ~ ~1 air
execute at @e[tag=NoScoreSetMush,tag=!MushNoDelete] run fill ~2 ~4 ~2 ~-2 ~8 ~-2 air
execute at @e[tag=NoScoreSetMush,tag=!MushNoDelete] positioned ~ ~5 ~ run effect give @a[tag=K,distance=..7] minecraft:slow_falling 3 0
execute at @e[tag=NoScoreSetMush,tag=!MushNoDelete] positioned ~ ~5 ~ run kill @e[distance=..10,nbt={Item:{id:"minecraft:red_bed"}},type=item]
execute at @e[tag=NoScoreSetMush,tag=!MushNoDelete] positioned ~ ~5 ~ run kill @e[distance=..10,nbt={Item:{id:"minecraft:chest"}},type=item]
tag @p[nbt={Inventory:[{id:"minecraft:written_book",tag:{fakebook:1b,display:{Lore:["\"A fake mushy book! Will be replaced with \"","\"the real one once the mushy house disappears.\""]}}}]}] add FakeBookGuy
execute at @e[tag=NoScoreSetMush,tag=!MushNoDelete] run tp @e[distance=..20,type=item,nbt={Item:{id:"minecraft:written_book"}}] @p[tag=FakeBookGuy]
execute at @e[tag=NoScoreSetMush,tag=!MushNoDelete] run clear @p[nbt={Inventory:[{id:"minecraft:written_book",tag:{fakebook:1b,display:{Lore:["\"A fake mushy book! Will be replaced with \"","\"the real one once the mushy house disappears.\""]}}}]}] written_book{fakebook:1b} 1
tag @a remove FakeBookGuy

kill @e[tag=NoScoreSetMush,tag=!MushNoDelete]