mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
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:
@ -25,7 +25,7 @@ use pocketmine\inventory\ChestInventory;
|
||||
use pocketmine\inventory\DoubleChestInventory;
|
||||
use pocketmine\inventory\InventoryHolder;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\format\Chunk;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
@ -40,8 +40,8 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{
|
||||
/** @var DoubleChestInventory */
|
||||
protected $doubleInventory = null;
|
||||
|
||||
public function __construct(Chunk $chunk, CompoundTag $nbt){
|
||||
parent::__construct($chunk, $nbt);
|
||||
public function __construct(Level $level, CompoundTag $nbt){
|
||||
parent::__construct($level, $nbt);
|
||||
$this->inventory = new ChestInventory($this);
|
||||
|
||||
if(!isset($this->namedtag->Items) or !($this->namedtag->Items instanceof ListTag)){
|
||||
|
@ -22,7 +22,7 @@
|
||||
namespace pocketmine\tile;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\format\Chunk;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\nbt\tag\ShortTag;
|
||||
@ -30,14 +30,14 @@ use pocketmine\nbt\tag\StringTag;
|
||||
|
||||
class FlowerPot extends Spawnable{
|
||||
|
||||
public function __construct(Chunk $chunk, CompoundTag $nbt){
|
||||
public function __construct(Level $level, CompoundTag $nbt){
|
||||
if(!isset($nbt->item)){
|
||||
$nbt->item = new ShortTag("item", 0);
|
||||
}
|
||||
if(!isset($nbt->mData)){
|
||||
$nbt->mData = new IntTag("mData", 0);
|
||||
}
|
||||
parent::__construct($chunk, $nbt);
|
||||
parent::__construct($level, $nbt);
|
||||
}
|
||||
|
||||
public function canAddItem(Item $item): bool{
|
||||
|
@ -28,7 +28,7 @@ use pocketmine\inventory\FurnaceInventory;
|
||||
use pocketmine\inventory\FurnaceRecipe;
|
||||
use pocketmine\inventory\InventoryHolder;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\format\Chunk;
|
||||
use pocketmine\level\Level;
|
||||
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(Chunk $chunk, CompoundTag $nbt){
|
||||
public function __construct(Level $level, CompoundTag $nbt){
|
||||
if(!isset($nbt->BurnTime) or $nbt["BurnTime"] < 0){
|
||||
$nbt->BurnTime = new ShortTag("BurnTime", 0);
|
||||
}
|
||||
@ -53,7 +53,7 @@ class Furnace extends Spawnable implements InventoryHolder, Container, Nameable{
|
||||
$nbt->BurnTicks = new ShortTag("BurnTicks", 0);
|
||||
}
|
||||
|
||||
parent::__construct($chunk, $nbt);
|
||||
parent::__construct($level, $nbt);
|
||||
$this->inventory = new FurnaceInventory($this);
|
||||
|
||||
if(!isset($this->namedtag->Items) or !($this->namedtag->Items instanceof ListTag)){
|
||||
|
@ -22,7 +22,7 @@
|
||||
namespace pocketmine\tile;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\format\Chunk;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\nbt\tag\ByteTag;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\FloatTag;
|
||||
@ -31,7 +31,7 @@ use pocketmine\nbt\tag\StringTag;
|
||||
|
||||
class ItemFrame extends Spawnable{
|
||||
|
||||
public function __construct(Chunk $chunk, CompoundTag $nbt){
|
||||
public function __construct(Level $level, CompoundTag $nbt){
|
||||
if(!isset($nbt->ItemRotation)){
|
||||
$nbt->ItemRotation = new ByteTag("ItemRotation", 0);
|
||||
}
|
||||
@ -40,7 +40,7 @@ class ItemFrame extends Spawnable{
|
||||
$nbt->ItemDropChance = new FloatTag("ItemDropChance", 1.0);
|
||||
}
|
||||
|
||||
parent::__construct($chunk, $nbt);
|
||||
parent::__construct($level, $nbt);
|
||||
}
|
||||
|
||||
public function hasItem() : bool{
|
||||
|
@ -22,7 +22,7 @@
|
||||
namespace pocketmine\tile;
|
||||
|
||||
use pocketmine\event\block\SignChangeEvent;
|
||||
use pocketmine\level\format\Chunk;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
@ -31,7 +31,7 @@ use pocketmine\utils\TextFormat;
|
||||
|
||||
class Sign extends Spawnable{
|
||||
|
||||
public function __construct(Chunk $chunk, CompoundTag $nbt){
|
||||
public function __construct(Level $level, CompoundTag $nbt){
|
||||
if(!isset($nbt->Text1)){
|
||||
$nbt->Text1 = new StringTag("Text1", "");
|
||||
}
|
||||
@ -45,7 +45,7 @@ class Sign extends Spawnable{
|
||||
$nbt->Text4 = new StringTag("Text4", "");
|
||||
}
|
||||
|
||||
parent::__construct($chunk, $nbt);
|
||||
parent::__construct($level, $nbt);
|
||||
}
|
||||
|
||||
public function saveNBT(){
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
namespace pocketmine\tile;
|
||||
|
||||
use pocketmine\level\format\Chunk;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\nbt\tag\ByteTag;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
@ -35,14 +35,14 @@ class Skull extends Spawnable{
|
||||
const TYPE_CREEPER = 4;
|
||||
const TYPE_DRAGON = 5;
|
||||
|
||||
public function __construct(Chunk $chunk, CompoundTag $nbt){
|
||||
public function __construct(Level $level, CompoundTag $nbt){
|
||||
if(!isset($nbt->SkullType)){
|
||||
$nbt->SkullType = new ByteTag("SkullType", 0);
|
||||
}
|
||||
if(!isset($nbt->Rot)){
|
||||
$nbt->Rot = new ByteTag("Rot", 0);
|
||||
}
|
||||
parent::__construct($chunk, $nbt);
|
||||
parent::__construct($level, $nbt);
|
||||
}
|
||||
|
||||
public function setType(int $type){
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
namespace pocketmine\tile;
|
||||
|
||||
use pocketmine\level\format\Chunk;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\network\protocol\BlockEntityDataPacket;
|
||||
@ -46,8 +46,8 @@ abstract class Spawnable extends Tile{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function __construct(Chunk $chunk, CompoundTag $nbt){
|
||||
parent::__construct($chunk, $nbt);
|
||||
public function __construct(Level $level, CompoundTag $nbt){
|
||||
parent::__construct($level, $nbt);
|
||||
$this->spawnToAll();
|
||||
}
|
||||
|
||||
|
@ -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++;
|
||||
|
Reference in New Issue
Block a user