function GetCursorFace(p: player) :: direction:
if {_p}'s target block's location is set:
set {_loc} to vector from {_p}'s target block's location to {_p}'s head location
set {_loc::0} to x of {_loc}
set {_loc::1} to y of {_loc}
set {_loc::2} to z of {_loc}
set {_vector} to vector from yaw {_p}'s yaw and pitch {_p}'s pitch
set {_vec::0} to x of {_vector}
set {_vec::1} to y of {_vector}
set {_vec::2} to z of {_vector}
loop integers between 0 and 2: #On boucle dans les 3 dimensions
loop integers between 0 and 1: #On boucle les 2 faces des 3 dimensions
set {_d::0} to {_loc::%loop-value-1%}-0.5 + loop-value-2
set {_k} to {_d::0} / {_vec::%loop-value-1%}
loop integers between 1 and 2: #On boucle les 2 coordonnées à trouver
set {_dTemp} to mod((loop-value-1 + loop-value-3), 3)
set {_d::%loop-value-3%} to {_vec::%{_dTemp}%} * {_k}
if {_d::%loop-value-3%} is between {_loc::%{_dTemp}%}-0.5 and {_loc::%{_dTemp}%}+0.5:
set {_ok::%loop-value-3%} to true
else:
set {_ok::%loop-value-3%} to false
if {_ok::*} is true and true:
set {_face} to loop-value-1*2+loop-value-2
set {_face::%{_face}%} to vector length of vector {_d::0}, {_d::1}, {_d::2}
set {_distMin} to 10^10
loop {_face::*}:
if loop-value < {_distMin}:
set {_distMin} to loop-value
set {_face} to loop-index
if {_face} is "0":
return east
if {_face} is "1":
return west
if {_face} is "2":
return up
if {_face} is "3":
return down
if {_face} is "4":
return south
if {_face} is "5":
return north