mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-19 23:44:17 +00:00
Added constants for default knockback force and vertical limit
This commit is contained in:
parent
82a5ea9ed3
commit
a45763328b
@ -80,6 +80,17 @@ use const M_PI;
|
||||
abstract class Living extends Entity{
|
||||
protected const DEFAULT_BREATH_TICKS = 300;
|
||||
|
||||
/**
|
||||
* The default knockback multiplier when an entity is hit by another entity.
|
||||
* Larger values knock the entity back with increased velocity.
|
||||
*/
|
||||
public const DEFAULT_KNOCKBACK_FORCE = 0.4;
|
||||
/**
|
||||
* Limit of an entity's vertical knockback velocity when hit by another entity. Without this limit, the entity
|
||||
* may be knocked far up into the air with large knockback forces.
|
||||
*/
|
||||
public const DEFAULT_KNOCKBACK_VERTICAL_LIMIT = 0.4;
|
||||
|
||||
private const TAG_LEGACY_HEALTH = "HealF"; //TAG_Float
|
||||
private const TAG_HEALTH = "Health"; //TAG_Float
|
||||
private const TAG_BREATH_TICKS = "Air"; //TAG_Short
|
||||
@ -567,7 +578,7 @@ abstract class Living extends Entity{
|
||||
$this->broadcastAnimation(new HurtAnimation($this));
|
||||
}
|
||||
|
||||
public function knockBack(float $x, float $z, float $force = 0.4, ?float $verticalLimit = 0.4) : void{
|
||||
public function knockBack(float $x, float $z, float $force = self::DEFAULT_KNOCKBACK_FORCE, ?float $verticalLimit = self::DEFAULT_KNOCKBACK_VERTICAL_LIMIT) : void{
|
||||
$f = sqrt($x * $x + $z * $z);
|
||||
if($f <= 0){
|
||||
return;
|
||||
|
@ -36,7 +36,7 @@ class EntityDamageByEntityEvent extends EntityDamageEvent{
|
||||
/**
|
||||
* @param float[] $modifiers
|
||||
*/
|
||||
public function __construct(Entity $damager, Entity $entity, int $cause, float $damage, array $modifiers = [], private float $knockBack = 0.4){
|
||||
public function __construct(Entity $damager, Entity $entity, int $cause, float $damage, array $modifiers = [], private float $knockBack = Living::DEFAULT_KNOCKBACK_FORCE){
|
||||
$this->damagerEntityId = $damager->getId();
|
||||
parent::__construct($entity, $cause, $damage, $modifiers);
|
||||
$this->addAttackerModifiers($damager);
|
||||
|
Loading…
x
Reference in New Issue
Block a user