Fixed error with world teleporting

This commit is contained in:
Shoghi Cervantes Pueyo 2013-05-15 17:40:39 +02:00
parent de5be4168d
commit cef4347a02
4 changed files with 14 additions and 4 deletions

View File

@ -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);

View File

@ -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,

View File

@ -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);

View File

@ -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;