From cef4347a025b0f1dd33c07049b2e5e6ea836e795 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Wed, 15 May 2013 17:40:39 +0200 Subject: [PATCH] Fixed error with world teleporting --- src/API/LevelAPI.php | 4 +++- src/Player.php | 2 ++ src/pmf/Level.php | 4 ++-- src/world/Entity.php | 8 +++++++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/API/LevelAPI.php b/src/API/LevelAPI.php index bf7b8d11c..38aec4c56 100644 --- a/src/API/LevelAPI.php +++ b/src/API/LevelAPI.php @@ -50,7 +50,6 @@ class LevelAPI{ $this->loadLevel($this->default); } $this->server->spawn = $this->getDefault()->getSpawn(); - $this->loadLevel("other"); } public function generateLevel($name, $seed = false){ @@ -69,6 +68,9 @@ class LevelAPI{ } public function loadLevel($name){ + if($this->get($name) !== false){ + return false; + } $path = DATA_PATH."worlds/".$name."/"; if(!file_exists($path."level.pmf")){ $level = new LevelImport($path); diff --git a/src/Player.php b/src/Player.php index 7df038931..d902307a1 100644 --- a/src/Player.php +++ b/src/Player.php @@ -569,6 +569,7 @@ class Player{ public function teleport(Vector3 $pos, $yaw = false, $pitch = false, $terrain = true){ if($this->entity instanceof Entity){ + $this->entity->check = false; if($yaw === false){ $yaw = $this->entity->yaw; } @@ -591,6 +592,7 @@ class Player{ $this->orderChunks(); $this->getNextChunk(); } + $this->entity->check = true; } $this->dataPacket(MC_MOVE_PLAYER, array( "eid" => 0, diff --git a/src/pmf/Level.php b/src/pmf/Level.php index eb7883625..0483eb3e0 100644 --- a/src/pmf/Level.php +++ b/src/pmf/Level.php @@ -250,7 +250,7 @@ class PMFLevel extends PMF{ $X = $x >> 4; $Z = $z >> 4; $Y = $y >> 4; - if($X >= 32 or $Z >= 32){ + if($X >= 32 or $Z >= 32 or $Y >= $this->levelData["height"]){ return array(AIR, 0); } $index = $this->getIndex($X, $Z); @@ -317,7 +317,7 @@ class PMFLevel extends PMF{ $Y = $y >> 4; $block &= 0xFF; $meta &= 0x0F; - if($X >= 32 or $Z >= 32){ + if($X >= 32 or $Z >= 32 or $Y >= $this->levelData["height"]){ return false; } $index = $this->getIndex($X, $Z); diff --git a/src/world/Entity.php b/src/world/Entity.php index 4e7d87d68..0e1d6d7fa 100644 --- a/src/world/Entity.php +++ b/src/world/Entity.php @@ -75,6 +75,8 @@ class Entity extends Position{ private $speedMeasure = array(0, 0, 0, 0, 0); private $server; public $level; + public $check; + function __construct(Level $level, $eid, $class, $type = 0, $data = array()){ $this->level = $level; $this->fallY = false; @@ -298,6 +300,10 @@ class Entity extends Position{ return false; } + if($this->check === false){ + return; + } + if($this->tickCounter === 0){ $this->tickCounter = 1; $this->environmentUpdate(); @@ -305,7 +311,7 @@ class Entity extends Position{ $this->tickCounter = 0; } - if($this->class === ENTITY_ITEM or $this->class === ENTITY_MOB or $this->class === ENTITY_PLAYER){ + if($this->check === true and ($this->class === ENTITY_ITEM or $this->class === ENTITY_MOB or $this->class === ENTITY_PLAYER)){ $startX = ((int) round($this->x - 0.5)) - 1; $y = (int) round($this->y - 1); $startZ = ((int) round($this->z - 0.5)) - 1;