From 3999a1f9f439c16a81685ae461f20b1cf501461f Mon Sep 17 00:00:00 2001 From: Darya Markova <122279000+Dasciam@users.noreply.github.com> Date: Wed, 3 Sep 2025 09:53:32 +0300 Subject: [PATCH] Fix sneaking hitbox height (#6771) --- src/entity/Human.php | 4 ++++ src/entity/Living.php | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/entity/Human.php b/src/entity/Human.php index c94b76097..d2637a3f9 100644 --- a/src/entity/Human.php +++ b/src/entity/Human.php @@ -247,6 +247,10 @@ class Human extends Living implements ProjectileSource, InventoryHolder{ return $this->enderInventory; } + public function getSneakOffset() : float{ + return 0.31; + } + /** * For Human entities which are not players, sets their properties such as nametag, skin and UUID from NBT. */ diff --git a/src/entity/Living.php b/src/entity/Living.php index 6d62c85d2..5ae1fd4e6 100644 --- a/src/entity/Living.php +++ b/src/entity/Living.php @@ -242,6 +242,10 @@ abstract class Living extends Entity{ $this->absorptionAttr->setValue($absorption); } + public function getSneakOffset() : float{ + return 0.0; + } + public function isSneaking() : bool{ return $this->sneaking; } @@ -292,7 +296,7 @@ abstract class Living extends Entity{ $width = $size->getWidth(); $this->setSize((new EntitySizeInfo($width, $width, $width * 0.9))->scale($this->getScale())); }elseif($this->isSneaking()){ - $this->setSize((new EntitySizeInfo(3 / 4 * $size->getHeight(), $size->getWidth(), 3 / 4 * $size->getEyeHeight()))->scale($this->getScale())); + $this->setSize((new EntitySizeInfo($size->getHeight() - $this->getSneakOffset(), $size->getWidth(), $size->getEyeHeight() - $this->getSneakOffset()))->scale($this->getScale())); }else{ $this->setSize($size->scale($this->getScale())); }