Removed entanglement between chunks and providers. WARNING: BREAKING API CHANGES.

- All entity and tile constructors now require a \pocketmine\level\Level instead of a \pocketmine\level\format\Chunk.
- Chunk->getProvider() and Chunk->setProvider() have been removed.
- Chunk::__construct() has had the $provider parameter removed.
- Chunk->unload() has had the unused $save parameter removed.
- ChunkEvents now take a Level parameter instead of going through the Chunk

API bump to 3.0.0-ALPHA4
This commit is contained in:
Dylan K. Taylor
2017-02-21 17:03:45 +00:00
parent 0a8826b21f
commit c21197ef17
37 changed files with 123 additions and 170 deletions

View File

@ -76,16 +76,16 @@ abstract class Tile extends Position{
/**
* @param string $type
* @param Chunk $chunk
* @param Level $level
* @param CompoundTag $nbt
* @param $args
*
* @return Tile
*/
public static function createTile($type, Chunk $chunk, CompoundTag $nbt, ...$args){
public static function createTile($type, Level $level, CompoundTag $nbt, ...$args){
if(isset(self::$knownTiles[$type])){
$class = self::$knownTiles[$type];
return new $class($chunk, $nbt, ...$args);
return new $class($level, $nbt, ...$args);
}
return null;
@ -116,15 +116,15 @@ abstract class Tile extends Position{
return self::$shortNames[static::class];
}
public function __construct(Chunk $chunk, CompoundTag $nbt){
assert($chunk !== null and $chunk->getProvider() !== null);
public function __construct(Level $level, CompoundTag $nbt){
$this->timings = Timings::getTileEntityTimings($this);
$this->server = $chunk->getProvider()->getLevel()->getServer();
$this->chunk = $chunk;
$this->setLevel($chunk->getProvider()->getLevel());
$this->namedtag = $nbt;
$this->server = $level->getServer();
$this->setLevel($level);
$this->chunk = $level->getChunk($this->namedtag["x"] >> 4, $this->namedtag["z"] >> 4, false);
assert($this->chunk !== null);
$this->name = "";
$this->lastUpdate = microtime(true);
$this->id = Tile::$tileCount++;