From 0a26fbd442f4ddf79a10bde663675749773688da Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Wed, 28 Feb 2024 06:08:11 +0300 Subject: [PATCH] entity movement updates are unreliable, tweaked some AABB methods --- src/Player.php | 12 ++++++------ src/math/AxisAlignedBB.php | 20 +++----------------- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/src/Player.php b/src/Player.php index 05334c15..6447b97c 100755 --- a/src/Player.php +++ b/src/Player.php @@ -1263,18 +1263,18 @@ class Player{ $this->sendEntityMovementUpdateQueue(); } if($motionSent){ - $motion->messageIndex = $this->counter[3]++; - $motion->reliability = 2; + $motion->messageIndex = 0; //force 0 cuz reliability 0 + $motion->reliability = 0; $this->entityMovementQueue->data[] = $motion; } if($moveSent){ - $move->messageIndex = $this->counter[3]++; - $move->reliability = 2; + $move->messageIndex = 0; + $move->reliability = 0; $this->entityMovementQueue->data[] = $move; } if($headSent){ - $headyaw->messageIndex = $this->counter[3]++; - $headyaw->reliability = 2; + $headyaw->messageIndex = 0; + $headyaw->reliability = 0; $this->entityMovementQueue->data[] = $headyaw; } diff --git a/src/math/AxisAlignedBB.php b/src/math/AxisAlignedBB.php index 7eba2e67..5415c001 100644 --- a/src/math/AxisAlignedBB.php +++ b/src/math/AxisAlignedBB.php @@ -66,14 +66,7 @@ class AxisAlignedBB{ } public function expand($x, $y, $z){ - $this->minX -= $x; - $this->minY -= $y; - $this->minZ -= $z; - $this->maxX += $x; - $this->maxY += $y; - $this->maxZ += $z; - - return $this; + return new AxisAlignedBB($this->minX - $x, $this->minY - $y, $this->minZ - $z, $this->maxX + $x, $this->maxY + $y, $this->maxZ + $z); } public function offset($x, $y, $z){ @@ -92,14 +85,7 @@ class AxisAlignedBB{ } public function contract($x, $y, $z){ - $this->minX += $x; - $this->minY += $y; - $this->minZ += $z; - $this->maxX -= $x; - $this->maxY -= $y; - $this->maxZ -= $z; - - return $this; + return new AxisAlignedBB($this->minX + $x, $this->minY + $y, $this->minZ + $z, $this->maxX - $x, $this->maxY - $y, $this->maxZ - $z); } public function setBB(AxisAlignedBB $bb){ @@ -313,7 +299,7 @@ class AxisAlignedBB{ } public function __toString(){ - return "min: {$this->minX}, {$this->minY}, {$this->minZ}, max: {$this->maxX}, {$this->maxY}, {$this->maxZ}"; + return "AABB min: {$this->minX}, {$this->minY}, {$this->minZ}, max: {$this->maxX}, {$this->maxY}, {$this->maxZ}"; } } \ No newline at end of file