World: ignore entities calling onEntityMoved() who aren't members of the world

this can happen if movement or teleportation occurs during the creation of an entity.
This commit is contained in:
Dylan K. Taylor 2020-12-05 17:49:34 +00:00
parent b2bab6c2fb
commit 1f330c0f50

View File

@ -2180,6 +2180,10 @@ class World implements ChunkManager{
* @internal
*/
public function onEntityMoved(Entity $entity, Position $oldPosition) : void{
if(!array_key_exists($entity->getId(), $this->entities)){
//this can happen if the entity was teleported before addEntity() was called
return;
}
$newPosition = $entity->getPosition();
$oldChunkX = $oldPosition->getFloorX() >> 4;