Bed: bounce doesn't apply if the entity was sneaking

This commit is contained in:
Dylan K. Taylor 2021-09-05 20:14:17 +01:00
parent ded778f422
commit 8e2486b96a
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -30,6 +30,7 @@ use pocketmine\block\utils\DyeColor;
use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\data\bedrock\DyeColorIdMap;
use pocketmine\entity\Entity;
use pocketmine\entity\Living;
use pocketmine\item\Item;
use pocketmine\lang\KnownTranslationFactory;
use pocketmine\math\AxisAlignedBB;
@ -172,6 +173,9 @@ class Bed extends Transparent{
}
public function onEntityLand(Entity $entity) : ?float{
if($entity instanceof Living && $entity->isSneaking()){
return null;
}
$entity->fallDistance *= 0.5;
return $entity->getMotion()->y * -3 / 4; // 2/3 in Java, according to the wiki
}