New generic in-memory chunk format, fixed 0.17.0.1 chunk loading

Terrible performance, needs profiling. TODO: fix this.
This commit is contained in:
Dylan K. Taylor
2016-11-17 16:15:06 +00:00
parent 60260a294b
commit 4c49db6036
44 changed files with 1895 additions and 2812 deletions

View File

@ -25,7 +25,7 @@ use pocketmine\inventory\ChestInventory;
use pocketmine\inventory\DoubleChestInventory;
use pocketmine\inventory\InventoryHolder;
use pocketmine\item\Item;
use pocketmine\level\format\FullChunk;
use pocketmine\level\format\Chunk;
use pocketmine\math\Vector3;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\CompoundTag;
@ -40,7 +40,7 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{
/** @var DoubleChestInventory */
protected $doubleInventory = null;
public function __construct(FullChunk $chunk, CompoundTag $nbt){
public function __construct(Chunk $chunk, CompoundTag $nbt){
parent::__construct($chunk, $nbt);
$this->inventory = new ChestInventory($this);

View File

@ -22,7 +22,7 @@
namespace pocketmine\tile;
use pocketmine\item\Item;
use pocketmine\level\format\FullChunk;
use pocketmine\level\format\Chunk;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\ShortTag;
@ -30,7 +30,7 @@ use pocketmine\nbt\tag\StringTag;
class FlowerPot extends Spawnable{
public function __construct(FullChunk $chunk, CompoundTag $nbt){
public function __construct(Chunk $chunk, CompoundTag $nbt){
if(!isset($nbt->Item)){
$nbt->item = new ShortTag("item", 0);
}

View File

@ -28,7 +28,7 @@ use pocketmine\inventory\FurnaceInventory;
use pocketmine\inventory\FurnaceRecipe;
use pocketmine\inventory\InventoryHolder;
use pocketmine\item\Item;
use pocketmine\level\format\FullChunk;
use pocketmine\level\format\Chunk;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\IntTag;
@ -41,7 +41,7 @@ class Furnace extends Spawnable implements InventoryHolder, Container, Nameable{
/** @var FurnaceInventory */
protected $inventory;
public function __construct(FullChunk $chunk, CompoundTag $nbt){
public function __construct(Chunk $chunk, CompoundTag $nbt){
if(!isset($nbt->BurnTime) or $nbt["BurnTime"] < 0){
$nbt->BurnTime = new ShortTag("BurnTime", 0);
}

View File

@ -21,14 +21,14 @@
namespace pocketmine\tile;
use pocketmine\level\format\FullChunk;
use pocketmine\level\format\Chunk;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\StringTag;
class Sign extends Spawnable{
public function __construct(FullChunk $chunk, CompoundTag $nbt){
public function __construct(Chunk $chunk, CompoundTag $nbt){
if(!isset($nbt->Text1)){
$nbt->Text1 = new StringTag("Text1", "");
}

View File

@ -21,7 +21,7 @@
namespace pocketmine\tile;
use pocketmine\level\format\FullChunk;
use pocketmine\level\format\Chunk;
use pocketmine\nbt\tag\ByteTag;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\IntTag;
@ -34,7 +34,7 @@ class Skull extends Spawnable{
const TYPE_HUMAN = 3;
const TYPE_CREEPER = 4;
public function __construct(FullChunk $chunk, CompoundTag $nbt){
public function __construct(Chunk $chunk, CompoundTag $nbt){
if(!isset($nbt->SkullType)){
$nbt->SkullType = new ByteTag("SkullType", 0);
}

View File

@ -21,7 +21,7 @@
namespace pocketmine\tile;
use pocketmine\level\format\FullChunk;
use pocketmine\level\format\Chunk;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\network\protocol\BlockEntityDataPacket;
@ -51,7 +51,7 @@ abstract class Spawnable extends Tile{
*/
public abstract function getSpawnCompound();
public function __construct(FullChunk $chunk, CompoundTag $nbt){
public function __construct(Chunk $chunk, CompoundTag $nbt){
parent::__construct($chunk, $nbt);
$this->spawnToAll();
}

View File

@ -26,7 +26,6 @@ namespace pocketmine\tile;
use pocketmine\event\Timings;
use pocketmine\level\format\Chunk;
use pocketmine\level\format\FullChunk;
use pocketmine\level\Level;
use pocketmine\level\Position;
use pocketmine\nbt\tag\CompoundTag;
@ -68,13 +67,13 @@ abstract class Tile extends Position{
/**
* @param string $type
* @param FullChunk $chunk
* @param Chunk $chunk
* @param CompoundTag $nbt
* @param $args
*
* @return Tile
*/
public static function createTile($type, FullChunk $chunk, CompoundTag $nbt, ...$args){
public static function createTile($type, Chunk $chunk, CompoundTag $nbt, ...$args){
if(isset(self::$knownTiles[$type])){
$class = self::$knownTiles[$type];
return new $class($chunk, $nbt, ...$args);
@ -108,7 +107,7 @@ abstract class Tile extends Position{
return self::$shortNames[static::class];
}
public function __construct(FullChunk $chunk, CompoundTag $nbt){
public function __construct(Chunk $chunk, CompoundTag $nbt){
assert($chunk !== null and $chunk->getProvider() !== null);
$this->timings = Timings::getTileEntityTimings($this);
@ -163,7 +162,7 @@ abstract class Tile extends Position{
if(!$this->closed){
$this->closed = true;
unset($this->level->updateTiles[$this->id]);
if($this->chunk instanceof FullChunk){
if($this->chunk instanceof Chunk){
$this->chunk->removeTile($this);
}
if(($level = $this->getLevel()) instanceof Level){