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

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