Use entity IDs in EntityDamageBy*EntityEvents, fixed memory leaks related to PvP/PvE/PvM (#418)

This commit is contained in:
Dylan K. Taylor
2017-03-13 10:30:31 +00:00
committed by GitHub
parent 083d1e9ef8
commit 92193fd27b
8 changed files with 63 additions and 17 deletions

View File

@ -60,7 +60,9 @@ class Squid extends WaterAnimal implements Ageable{
if($source instanceof EntityDamageByEntityEvent){
$this->swimSpeed = mt_rand(150, 350) / 2000;
$e = $source->getDamager();
$this->swimDirection = (new Vector3($this->x - $e->x, $this->y - $e->y, $this->z - $e->z))->normalize();
if($e !== null){
$this->swimDirection = (new Vector3($this->x - $e->x, $this->y - $e->y, $this->z - $e->z))->normalize();
}
$pk = new EntityEventPacket();
$pk->eid = $this->getId();