Fix sneaking hitbox height (#6771)

This commit is contained in:
Darya Markova
2025-09-03 09:53:32 +03:00
committed by GitHub
parent 925b34e5c6
commit 3999a1f9f4
2 changed files with 9 additions and 1 deletions

View File

@ -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.
*/

View File

@ -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()));
}