##############################
##
##        WorldEdit
##    Made By M7mdTG ;)
##
##############################

execute @e[type=worldedit:pos1,tag=!we_measured] ~~~ function we/high-end/optimization/measure
execute @e[type=worldedit:pos1,tag=we_measured,tag=!we_tested_good] ~~~ function we/high-end/optimization/check-condition
execute @e[type=worldedit:pos1,tag=we_tested_good,tag=!we_found_good_surface] ~~~ function we/high-end/optimization/find-surface
 
execute @e[type=worldedit:pos1,tag=we_dead] ~~~ tellraw @a {"rawtext":[{"text":"               §7>\n§r               Outline Built Successfully:\n               Size: <"},{"score":{"name":"@e[type=worldedit:pos1]","objective":"we_x_scale"}},{"text":", "},{"score":{"name":"@e[type=worldedit:pos1]","objective":"we_y_scale"}},{"text":", "},{"score":{"name":"@e[type=worldedit:pos1]","objective":"we_z_scale"}},{"text":">"}]}
execute @e[type=worldedit:pos1,tag=we_dead] ~~~ execute @a[tag=we_host] ~~~ playsound random.levelup @s ~~~ 0.5 1
execute @e[type=worldedit:pos1,tag=we_dead] ~~~ structure delete we_selection
kill @e[tag=we_dead]

execute @e[type=worldedit:pos2] ~~~ execute @e[type=worldedit:pos1,tag=we_found_good_surface,tag=!we_savedblock] ~~~ structure save we_selection ~~~ ~~~ false disk true
execute @e[type=worldedit:pos2] ~~~ execute @e[type=worldedit:pos1,tag=we_found_good_surface,tag=!we_savedblock] ~~~ scoreboard players operation @s we_mask_mode = @a[tag=we_host] we_mask_mode
execute @e[type=worldedit:pos2] ~~~ execute @e[type=worldedit:pos1,tag=we_found_good_surface,tag=!we_savedblock] ~~~ tellraw @a {"rawtext":[{"text":"<WorldEdit> Started Fill Operation Successfully:\n               Mode: <Outline>"}]}
execute @e[type=worldedit:pos2] ~~~ execute @e[type=worldedit:pos1,tag=we_found_good_surface,tag=!we_savedblock] ~~~ tag @s add we_savedblock

execute @e[type=worldedit:pos1,tag=we_found_good_surface,scores={we_x_score=2,we_y_score=..1,we_z_score=..1}] ~~~ function we/high-end/outlines/outline-yz
execute @e[type=worldedit:pos1,tag=we_found_good_surface,scores={we_x_score=..1,we_y_score=2,we_z_score=..1}] ~~~ function we/high-end/outlines/outline-xz
execute @e[type=worldedit:pos1,tag=we_found_good_surface,scores={we_x_score=..1,we_y_score=..1,we_z_score=2}] ~~~ function we/high-end/outlines/outline-xy
execute @e[type=worldedit:pos1,tag=we_found_good_surface,scores={we_x_score=2,we_y_score=2,we_z_score=0}] ~~~ function we/high-end/outlines/outline-xz
execute @e[type=worldedit:pos1,tag=we_found_good_surface,scores={we_x_score=0,we_y_score=2,we_z_score=2}] ~~~ function we/high-end/outlines/outline-xz
execute @e[type=worldedit:pos1,tag=we_found_good_surface,scores={we_x_score=2,we_y_score=0,we_z_score=2}] ~~~function we/high-end/outlines/outline-xy
execute @e[type=worldedit:pos1,tag=we_found_good_surface,scores={we_x_score=2,we_y_score=2,we_z_score=2}] ~~~ function we/high-end/outlines/outline-xz
