Made some changes for 0.12

This commit is contained in:
Shoghi Cervantes
2015-06-26 13:49:38 -07:00
committed by Shoghi Cervantes
parent 0380e9009a
commit 4258e22c02
18 changed files with 227 additions and 108 deletions

View File

@ -89,6 +89,7 @@ use pocketmine\nbt\tag\Short;
use pocketmine\nbt\tag\String;
use pocketmine\network\Network;
use pocketmine\network\protocol\DataPacket;
use pocketmine\network\protocol\FullChunkDataPacket;
use pocketmine\network\protocol\LevelEventPacket;
use pocketmine\network\protocol\MoveEntityPacket;
use pocketmine\network\protocol\SetEntityMotionPacket;
@ -2301,13 +2302,13 @@ class Level implements ChunkManager, Metadatable{
}
}
public function chunkRequestCallback($x, $z, $payload){
public function chunkRequestCallback($x, $z, $payload, $ordering = FullChunkDataPacket::ORDER_COLUMNS){
$this->timings->syncChunkSendTimer->startTiming();
$index = Level::chunkHash($x, $z);
if(!isset($this->chunkCache[$index]) and $this->cacheChunks and $this->server->getMemoryManager()->canUseChunkCache()){
$this->chunkCache[$index] = Player::getChunkCacheFromData($x, $z, $payload);
$this->chunkCache[$index] = Player::getChunkCacheFromData($x, $z, $payload, $ordering);
$this->sendChunkFromCache($x, $z);
$this->timings->syncChunkSendTimer->stopTiming();
return;
@ -2317,7 +2318,7 @@ class Level implements ChunkManager, Metadatable{
foreach($this->chunkSendQueue[$index] as $player){
/** @var Player $player */
if($player->isConnected() and isset($player->usedChunks[$index])){
$player->sendChunk($x, $z, $payload);
$player->sendChunk($x, $z, $payload, $ordering);
}
}
unset($this->chunkSendQueue[$index]);

View File

@ -24,9 +24,12 @@ namespace pocketmine\level\format\anvil;
use pocketmine\level\format\FullChunk;
use pocketmine\level\format\mcregion\McRegion;
use pocketmine\level\Level;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\Byte;
use pocketmine\nbt\tag\ByteArray;
use pocketmine\nbt\tag\Compound;
use pocketmine\network\protocol\FullChunkDataPacket;
use pocketmine\tile\Spawnable;
use pocketmine\utils\ChunkException;
class Anvil extends McRegion{
@ -66,7 +69,36 @@ class Anvil extends McRegion{
}
public function requestChunkTask($x, $z){
return new ChunkRequestTask($this->getLevel(), $this->getChunk($x, $z, true));
$chunk = $this->getChunk($x, $z, false);
if(!($chunk instanceof Chunk)){
throw new ChunkException("Invalid Chunk sent");
}
$tiles = "";
if(count($chunk->getTiles()) > 0){
$nbt = new NBT(NBT::LITTLE_ENDIAN);
$list = [];
foreach($chunk->getTiles() as $tile){
if($tile instanceof Spawnable){
$list[] = $tile->getSpawnCompound();
}
}
$nbt->setData($list);
$tiles = $nbt->write();
}
$ordered = $chunk->getBlockIdArray() .
$chunk->getBlockDataArray() .
$chunk->getBlockSkyLightArray() .
$chunk->getBlockLightArray() .
pack("C*", ...$chunk->getHeightMapArray()) .
pack("N*", ...$chunk->getBiomeColorArray()) .
$tiles;
$this->getLevel()->chunkRequestCallback($x, $z, $ordered, FullChunkDataPacket::ORDER_LAYERED);
return null;
}
/**

View File

@ -133,17 +133,12 @@ class McRegion extends BaseLevelProvider{
$tiles = $nbt->write();
}
$heightmap = pack("C*", ...$chunk->getHeightMapArray());
$biomeColors = pack("N*", ...$chunk->getBiomeColorArray());
$ordered = $chunk->getBlockIdArray() .
$chunk->getBlockDataArray() .
$chunk->getBlockSkyLightArray() .
$chunk->getBlockLightArray() .
$heightmap .
$biomeColors .
pack("C*", ...$chunk->getHeightMapArray()) .
pack("N*", ...$chunk->getBiomeColorArray()) .
$tiles;
$this->getLevel()->chunkRequestCallback($x, $z, $ordered);