mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 12:39:43 +00:00
Player::teleport will set motion to 0, fixed possible divby0 when skeletonm shooting the player, fixed entities not untargetting dead players, fixed wrong distance calculations
This commit is contained in:
parent
2cd42fb605
commit
81aa575749
7 changed files with 84 additions and 30 deletions
|
|
@ -21,11 +21,18 @@ abstract class Creature extends Living{
|
|||
return parent::update($now);
|
||||
}
|
||||
|
||||
|
||||
public function handlePrePlayerSearcher(){
|
||||
parent::handlePrePlayerSearcher();
|
||||
if($this->closestPlayerEID !== false && !isset($this->level->entityList[$this->closestPlayerEID])){
|
||||
$this->closestPlayerEID = false;
|
||||
$this->closestPlayerDist = INF;
|
||||
if($this->closestPlayerEID !== false){
|
||||
$player = $this->level->entityList[$this->closestPlayerEID] ?? false;
|
||||
if($player === false){
|
||||
$this->closestPlayerEID = false;
|
||||
$this->closestPlayerDist = INF;
|
||||
}else{
|
||||
$dist = ($this->x - $player->x)*($this->x - $player->x) + ($this->y - $player->y)*($this->y - $player->y) + ($this->z - $player->z)*($this->z - $player->z);
|
||||
$this->closestPlayerDist = $dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue