mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-23 13:09:44 +00:00
mob fall damage
This commit is contained in:
parent
3e3a020d2e
commit
6b68b88572
2 changed files with 21 additions and 4 deletions
|
|
@ -7,7 +7,7 @@ class Entity extends Position
|
||||||
const CLASS_TYPE = - 1;
|
const CLASS_TYPE = - 1;
|
||||||
|
|
||||||
public $counter = 0;
|
public $counter = 0;
|
||||||
|
public $fallDistance = 0;
|
||||||
public static $updateOnTick, $allowedAI;
|
public static $updateOnTick, $allowedAI;
|
||||||
public $isCollidable;
|
public $isCollidable;
|
||||||
public $canBeAttacked;
|
public $canBeAttacked;
|
||||||
|
|
@ -669,7 +669,7 @@ class Entity extends Position
|
||||||
$this->server->api->handle("entity.motion", $this);
|
$this->server->api->handle("entity.motion", $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$this->updateFallState($this->speedY);
|
||||||
} elseif($this->player instanceof Player){
|
} elseif($this->player instanceof Player){
|
||||||
if($isFlying === true and ($this->player->gamemode & 0x01) === 0x00){
|
if($isFlying === true and ($this->player->gamemode & 0x01) === 0x00){
|
||||||
if($this->fallY === false or $this->fallStart === false){
|
if($this->fallY === false or $this->fallStart === false){
|
||||||
|
|
@ -729,7 +729,19 @@ class Entity extends Position
|
||||||
$this->needsUpdate = $hasUpdate;
|
$this->needsUpdate = $hasUpdate;
|
||||||
$this->lastUpdate = $now;
|
$this->lastUpdate = $now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function fall(){}
|
||||||
|
|
||||||
|
public function updateFallState($fallTick){
|
||||||
|
if($this->onGround && $this->fallDistance > 0){
|
||||||
|
$this->fall();
|
||||||
|
$this->fallDistance = 0;
|
||||||
|
}elseif($fallTick < 0){
|
||||||
|
$this->fallDistance -= $fallTick;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function updateMovement()
|
public function updateMovement()
|
||||||
{
|
{
|
||||||
if($this->closed === true){
|
if($this->closed === true){
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,12 @@ abstract class Living extends Entity implements Damageable, Pathfindable{
|
||||||
$this->hasKnockback = true;
|
$this->hasKnockback = true;
|
||||||
if(self::$despawnMobs) $this->server->schedule(self::$despawnTimer, [$this, "close"]); //900*20
|
if(self::$despawnMobs) $this->server->schedule(self::$despawnTimer, [$this, "close"]); //900*20
|
||||||
}
|
}
|
||||||
|
public function fall(){
|
||||||
|
$dmg = floor($this->fallDistance - 3);
|
||||||
|
if($dmg > 0){
|
||||||
|
$this->harm($dmg, "fall");
|
||||||
|
}
|
||||||
|
}
|
||||||
public function hasPath(){
|
public function hasPath(){
|
||||||
return $this->path != null;
|
return $this->path != null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue