mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 04:29:43 +00:00
fixed target invalidation
This commit is contained in:
parent
7ad98fe444
commit
75844b5a62
3 changed files with 4 additions and 3 deletions
|
|
@ -1313,6 +1313,7 @@ class Player{
|
||||||
$this->chunkCount = [];
|
$this->chunkCount = [];
|
||||||
$this->cratingItems = [];
|
$this->cratingItems = [];
|
||||||
$this->received = [];
|
$this->received = [];
|
||||||
|
$this->entity->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1399,7 +1399,7 @@ class Entity extends Position
|
||||||
if($health < $this->health){
|
if($health < $this->health){
|
||||||
$harm = true;
|
$harm = true;
|
||||||
$dmg = $this->health - $health;
|
$dmg = $this->health - $health;
|
||||||
if(($this->class !== ENTITY_PLAYER or (($this->player instanceof Player) and (($this->player->gamemode & 0x01) === 0x00 or $force === true))) and ($this->dmgcounter[0] < microtime(true) or $this->dmgcounter[1] < $dmg) and ! $this->dead){
|
if(($this->class !== ENTITY_PLAYER or (($this->player instanceof Player) and (($this->player->gamemode & 0x01) === 0x00 or $force === true))) and ($this->dmgcounter[0] < microtime(true) or $this->dmgcounter[1] < $dmg) and !$this->dead){
|
||||||
$this->dmgcounter[0] = microtime(true) + 0.5;
|
$this->dmgcounter[0] = microtime(true) + 0.5;
|
||||||
$this->dmgcounter[1] = $dmg;
|
$this->dmgcounter[1] = $dmg;
|
||||||
} else{
|
} else{
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,8 @@ class TaskAttackPlayer extends TaskBase
|
||||||
|
|
||||||
|
|
||||||
public function isTargetValid(EntityAI $ai){
|
public function isTargetValid(EntityAI $ai){
|
||||||
$e = $ai->entity; //TODO sometimes it keeps being valid even after getting invalid (/gm 1 -> /gm 0 switch)
|
$e = $ai->entity;
|
||||||
if($e->target instanceof Entity){
|
if($e->target instanceof Entity && !$e->target->closed){
|
||||||
$t = $e->target;
|
$t = $e->target;
|
||||||
$xDiff = ($t->x - $e->x);
|
$xDiff = ($t->x - $e->x);
|
||||||
$yDiff = ($t->y - $e->y);
|
$yDiff = ($t->y - $e->y);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue