mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Living: Limit vertical knockback to 0.4 by default
this will break non-standard use cases with large forces, but they only have to stick a 'null' at the end of the parameter list. Since this function should be primarily used for vanilla knockback, it makes more sense to keep the default as vanilla, but allow people to change it if they want to. closes #4106 (this is close to #4106 anyway, but small enough that it was easier to recreate it than pull and modify it) closes #2707
This commit is contained in:
parent
3466fbe3e3
commit
e803ca0e06
@ -507,7 +507,7 @@ abstract class Living extends Entity{
|
||||
$this->broadcastAnimation(new HurtAnimation($this));
|
||||
}
|
||||
|
||||
public function knockBack(float $x, float $z, float $base = 0.4) : void{
|
||||
public function knockBack(float $x, float $z, float $base = 0.4, ?float $verticalLimit = 0.4) : void{
|
||||
$f = sqrt($x * $x + $z * $z);
|
||||
if($f <= 0){
|
||||
return;
|
||||
@ -522,8 +522,9 @@ abstract class Living extends Entity{
|
||||
$motionY += $base;
|
||||
$motionZ += $z * $f * $base;
|
||||
|
||||
if($motionY > $base){
|
||||
$motionY = $base;
|
||||
$verticalLimit ??= $base;
|
||||
if($motionY > $verticalLimit){
|
||||
$motionY = $verticalLimit;
|
||||
}
|
||||
|
||||
$this->setMotion(new Vector3($motionX, $motionY, $motionZ));
|
||||
|
Loading…
x
Reference in New Issue
Block a user