diff --git a/src/Player.php b/src/Player.php index 76188788..39c69901 100755 --- a/src/Player.php +++ b/src/Player.php @@ -492,7 +492,7 @@ class Player{ } } - $tiles = $this->server->query("SELECT ID FROM tiles WHERE spawnable = 1 AND level = '" . $this->level->getName() . "' AND x >= " . (($X << 4) - 1) . " AND x < " . (($X << 4) + 17) . " AND z >= " . (($Z << 4) - 1) . " AND z < " . (($Z << 4) + 17) . ";"); + /*$tiles = $this->server->query("SELECT ID FROM tiles WHERE spawnable = 1 AND level = '" . $this->level->getName() . "' AND x >= " . (($X << 4) - 1) . " AND x < " . (($X << 4) + 17) . " AND z >= " . (($Z << 4) - 1) . " AND z < " . (($Z << 4) + 17) . ";"); $this->lastChunk = false; if($tiles !== false and $tiles !== true){ while(($tile = $tiles->fetchArray(SQLITE3_ASSOC)) !== false){ @@ -501,7 +501,7 @@ class Player{ $tile->spawn($this); } } - } + }*/ //$this->stopUsingChunk($X, $Z); //just in case $pk = new FullChunkDataPacket; $pk->chunkX = $X; diff --git a/src/world/Level.php b/src/world/Level.php index 1ff5fa0c..83965d5e 100644 --- a/src/world/Level.php +++ b/src/world/Level.php @@ -186,33 +186,44 @@ class Level{ } $nbt = new NBT_new(NBT_new::LITTLE_ENDIAN); - foreach($chunkTiles as $tile){ //TODO non-hardcoded nbt data + foreach($chunkTiles as $tile){ //TODO rewrite TileEntity system switch($tile->class){ case "Sign": $text = $tile->getText(); - $nbt->setData(new Compound("", array( - new StringTag("Text1", $text[0]), - new StringTag("Text2", $text[1]), - new StringTag("Text3", $text[2]), - new StringTag("Text4", $text[3]), - new StringTag("id", "Sign"), - new IntTag("x", (int) $tile->x), - new IntTag("y", (int) $tile->y), - new IntTag("z", (int) $tile->z) - ))); - $tileEntities .= $nbt->write(); + $nbt->setData(new Compound("", array( + new StringTag("Text1", $text[0]), + new StringTag("Text2", $text[1]), + new StringTag("Text3", $text[2]), + new StringTag("Text4", $text[3]), + new StringTag("id", "Sign"), + new IntTag("x", (int) $tile->x), + new IntTag("y", (int) $tile->y), + new IntTag("z", (int) $tile->z) + ))); + $tileEntities .= $nbt->write(); break; case "Furnace": - //nutting, not spawnable :D + //nutting, not spawnable :D break; case "Chest": + if($tile->isPaired()){ $nbt->setData(new Compound("", array( new StringTag("id", "Chest"), new IntTag("x", (int) $tile->x), new IntTag("y", (int) $tile->y), - new IntTag("z", (int) $tile->z) + new IntTag("z", (int) $tile->z), + new IntTag("pairx", (int) $tile->x), + new IntTag("pairz", (int) $tile->z) ))); - $tileEntities .= $nbt->write(); + }else{ + $nbt->setData(new Compound("", array( + new StringTag("id", "Chest"), + new IntTag("x", (int) $tile->x), + new IntTag("y", (int) $tile->y), + new IntTag("z", (int) $tile->z), + ))); + } + $tileEntities .= $nbt->write(); break; } }