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

execute @e[type=worldedit:pos2] ~~~ execute @e[type=worldedit:pos1,tag=!we_measuring,tag=!we_measured] ~~~ summon worldedit:dummy "we_measure" ~~~
execute @e[type=worldedit:pos2] ~~~ execute @e[type=worldedit:pos1,tag=!we_measuring,tag=!we_measured] ~~~ scoreboard players set @s we_x_scale 1
execute @e[type=worldedit:pos2] ~~~ execute @e[type=worldedit:pos1,tag=!we_measuring,tag=!we_measured] ~~~ scoreboard players set @s we_y_scale 1
execute @e[type=worldedit:pos2] ~~~ execute @e[type=worldedit:pos1,tag=!we_measuring,tag=!we_measured] ~~~ scoreboard players set @s we_z_scale 1
execute @e[type=worldedit:pos2] ~~~ execute @e[type=worldedit:pos1,tag=!we_measuring,tag=!we_measured] ~~~ tag @s add we_measuring
 
#stage 1
 
execute @e[type=worldedit:pos1,tag=we_measuring] ~~~ execute @e[type=worldedit:pos2] ~~~ execute @e[x=~-1,dx=-9999,y=9999,dy=-19999,z=~9999,dz=-19999,type=worldedit:dummy,name="we_measure"] ~~~ scoreboard players add @e[type=worldedit:pos1,tag=we_measuring] we_x_scale 1
execute @e[type=worldedit:pos1,tag=we_measuring] ~~~ execute @e[type=worldedit:pos2] ~~~ execute @e[x=~-1,dx=-9999,y=9999,dy=-19999,z=~9999,dz=-19999,type=worldedit:dummy,name="we_measure"] ~~~ tp ~1~~
 
 
execute @e[type=worldedit:pos1,tag=we_measuring] ~~~ execute @e[type=worldedit:pos2] ~~~ execute @e[x=~1,dx=9999,y=9999,dy=-19999,z=~9999,dz=-19999,type=worldedit:dummy,name="we_measure"] ~~~ scoreboard players add @e[type=worldedit:pos1,tag=we_measuring] we_x_scale 1
execute @e[type=worldedit:pos1,tag=we_measuring] ~~~ execute @e[type=worldedit:pos2] ~~~ execute @e[x=~1,dx=9999,y=9999,dy=-19999,z=~9999,dz=-19999,type=worldedit:dummy,name="we_measure"] ~~~ tp ~-1~~
 
#stage 2
 
execute @e[type=worldedit:pos1,tag=we_measuring] ~~~ execute @e[type=worldedit:pos2] ~~~ execute @e[x=~,dx=0,y=~-1,dy=-9999,z=~9999,dz=-19999,type=worldedit:dummy,name="we_measure"] ~~~ scoreboard players add @e[type=worldedit:pos1,tag=we_measuring] we_y_scale 1
execute @e[type=worldedit:pos1,tag=we_measuring] ~~~ execute @e[type=worldedit:pos2] ~~~ execute @e[x=~,dx=0,y=~-1,dy=-9999,z=~9999,dz=-19999,type=worldedit:dummy,name="we_measure"] ~~~ tp ~~1~
 
 
execute @e[type=worldedit:pos1,tag=we_measuring] ~~~ execute @e[type=worldedit:pos2] ~~~ execute @e[x=~,dx=0,y=~1,dy=9999,z=~9999,dz=-19999,type=worldedit:dummy,name="we_measure"] ~~~ scoreboard players add @e[type=worldedit:pos1,tag=we_measuring] we_y_scale 1
execute @e[type=worldedit:pos1,tag=we_measuring] ~~~ execute @e[type=worldedit:pos2] ~~~ execute @e[x=~,dx=0,y=~1,dy=9999,z=~9999,dz=-19999,type=worldedit:dummy,name="we_measure"] ~~~ tp ~~-1~
 
#stage 3
 
execute @e[type=worldedit:pos1,tag=we_measuring] ~~~ execute @e[type=worldedit:pos2] ~~~ execute @e[x=~,dx=0,y=~,dy=0,z=~1,dz=9999,type=worldedit:dummy,name="we_measure"] ~~~ scoreboard players add @e[type=worldedit:pos1,tag=we_measuring] we_z_scale 1
execute @e[type=worldedit:pos1,tag=we_measuring] ~~~ execute @e[type=worldedit:pos2] ~~~ execute @e[x=~,dx=0,y=~,dy=0,z=~1,dz=9999,type=worldedit:dummy,name="we_measure"] ~~~ tp ~~~-1
 
execute @e[type=worldedit:pos1,tag=we_measuring] ~~~ execute @e[type=worldedit:pos2] ~~~ execute @e[x=~,dx=0,y=~,dy=0,z=~-1,dz=-9999,type=worldedit:dummy,name="we_measure"] ~~~ scoreboard players add @e[type=worldedit:pos1,tag=we_measuring] we_z_scale 1
execute @e[type=worldedit:pos1,tag=we_measuring] ~~~ execute @e[type=worldedit:pos2] ~~~ execute @e[x=~,dx=0,y=~,dy=0,z=~-1,dz=-9999,type=worldedit:dummy,name="we_measure"] ~~~ tp ~~~1
 
#stage 4
execute @e[type=worldedit:pos2] ~~~ execute @e[type=worldedit:dummy,name="we_measure",x=~,dx=0,y=~,dy=0,z=~,dz=0] ~~~ tag @s add we_dead
execute @e[tag=we_dead,type=worldedit:dummy,name="we_measure"] ~~~ tag @e[type=worldedit:pos1] remove we_measuring
execute @e[tag=we_dead,type=worldedit:dummy,name="we_measure"] ~~~ tag @e[type=worldedit:pos1] add we_measured
#execute @e[tag=we_dead,type=worldedit:dummy,name="we_measure"] ~~~ tellraw @a[tag=host] {"rawtext":[{"text":"X: <"},{"score":{"name":"@e[type=worldedit:pos1,tag=we_measured]","objective":"we_x_scale"}},{"text":">, Y: <"},{"score":{"name":"@e[type=worldedit:pos1,tag=we_measured]","objective":"we_y_scale"}},{"text":">, Z: <"},{"score":{"name":"@e[type=worldedit:pos1,tag=we_measured]","objective":"we_z_scale"}},{"text":">"}]}
kill @e[tag=we_dead]
 
execute @e[tag=!we_dead,type=worldedit:dummy,name="we_measure"] ~~~ function we/high-end/optimization/measure