World: clamp clickVector components from 0-1

this ensures that #5827 won't randomly start crashing if clients give bad values.
This commit is contained in:
Dylan K. Taylor 2023-06-21 16:59:14 +01:00
parent 6f82942c64
commit 8dedbb7471
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -2032,6 +2032,12 @@ class World implements ChunkManager{
if($clickVector === null){
$clickVector = new Vector3(0.0, 0.0, 0.0);
}else{
$clickVector = new Vector3(
min(1.0, max(0.0, $clickVector->x)),
min(1.0, max(0.0, $clickVector->y)),
min(1.0, max(0.0, $clickVector->z))
);
}
if(!$this->isInWorld($blockReplace->getPosition()->x, $blockReplace->getPosition()->y, $blockReplace->getPosition()->z)){