Merge branch 'release/3.2'

This commit is contained in:
Dylan K. Taylor 2018-08-25 18:37:27 +01:00
commit 3b62926721
5 changed files with 7 additions and 12 deletions

View File

@ -1141,17 +1141,12 @@ class Server{
* Useful for tracking entities across multiple worlds without needing strong references. * Useful for tracking entities across multiple worlds without needing strong references.
* *
* @param int $entityId * @param int $entityId
* @param Level|null $expectedLevel Level to look in first for the target * @param Level|null $expectedLevel @deprecated Level to look in first for the target
* *
* @return Entity|null * @return Entity|null
*/ */
public function findEntity(int $entityId, Level $expectedLevel = null){ public function findEntity(int $entityId, Level $expectedLevel = null){
$levels = $this->levels; foreach($this->levels as $level){
if($expectedLevel !== null){
array_unshift($levels, $expectedLevel);
}
foreach($levels as $level){
assert(!$level->isClosed()); assert(!$level->isClosed());
if(($entity = $level->getEntity($entityId)) instanceof Entity){ if(($entity = $level->getEntity($entityId)) instanceof Entity){
return $entity; return $entity;

View File

@ -731,7 +731,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
public function getOwningEntity() : ?Entity{ public function getOwningEntity() : ?Entity{
$eid = $this->getOwningEntityId(); $eid = $this->getOwningEntityId();
if($eid !== null){ if($eid !== null){
return $this->server->findEntity($eid, $this->level); return $this->server->findEntity($eid);
} }
return null; return null;
@ -771,7 +771,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
public function getTargetEntity() : ?Entity{ public function getTargetEntity() : ?Entity{
$eid = $this->getTargetEntityId(); $eid = $this->getTargetEntityId();
if($eid !== null){ if($eid !== null){
return $this->server->findEntity($eid, $this->level); return $this->server->findEntity($eid);
} }
return null; return null;

View File

@ -147,7 +147,7 @@ class ExperienceOrb extends Entity{
return null; return null;
} }
$entity = $this->server->findEntity($this->targetPlayerRuntimeId, $this->level); $entity = $this->server->findEntity($this->targetPlayerRuntimeId);
if($entity instanceof Human){ if($entity instanceof Human){
return $entity; return $entity;
} }

View File

@ -51,6 +51,6 @@ class EntityDamageByChildEntityEvent extends EntityDamageByEntityEvent{
* @return Entity|null * @return Entity|null
*/ */
public function getChild() : ?Entity{ public function getChild() : ?Entity{
return $this->getEntity()->getLevel()->getServer()->findEntity($this->childEntityEid, $this->getEntity()->getLevel()); return $this->getEntity()->getLevel()->getServer()->findEntity($this->childEntityEid);
} }
} }

View File

@ -69,7 +69,7 @@ class EntityDamageByEntityEvent extends EntityDamageEvent{
* @return Entity|null * @return Entity|null
*/ */
public function getDamager() : ?Entity{ public function getDamager() : ?Entity{
return $this->getEntity()->getLevel()->getServer()->findEntity($this->damagerEntityId, $this->getEntity()->getLevel()); return $this->getEntity()->getLevel()->getServer()->findEntity($this->damagerEntityId);
} }
/** /**