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:
@ -269,10 +269,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
protected $isPlayer = false;
|
||||
|
||||
|
||||
public function __construct(Chunk $chunk, CompoundTag $nbt){
|
||||
|
||||
assert($chunk !== null and $chunk->getProvider() !== null);
|
||||
|
||||
public function __construct(Level $level, CompoundTag $nbt){
|
||||
$this->timings = Timings::getEntityTimings($this);
|
||||
|
||||
$this->isPlayer = $this instanceof Player;
|
||||
@ -287,9 +284,10 @@ abstract class Entity extends Location implements Metadatable{
|
||||
$this->justCreated = true;
|
||||
$this->namedtag = $nbt;
|
||||
|
||||
$this->chunk = $chunk;
|
||||
$this->setLevel($chunk->getProvider()->getLevel());
|
||||
$this->server = $chunk->getProvider()->getLevel()->getServer();
|
||||
$this->chunk = $level->getChunk($this->namedtag["Pos"][0] >> 4, $this->namedtag["Pos"][2] >> 4);
|
||||
assert($this->chunk !== null);
|
||||
$this->setLevel($level);
|
||||
$this->server = $level->getServer();
|
||||
|
||||
$this->boundingBox = new AxisAlignedBB(0, 0, 0, 0, 0, 0);
|
||||
$this->setPositionAndRotation(
|
||||
@ -301,6 +299,8 @@ abstract class Entity extends Location implements Metadatable{
|
||||
$this->namedtag->Rotation[0],
|
||||
$this->namedtag->Rotation[1]
|
||||
);
|
||||
|
||||
|
||||
$this->setMotion($this->temporalVector->setComponents($this->namedtag["Motion"][0], $this->namedtag["Motion"][1], $this->namedtag["Motion"][2]));
|
||||
|
||||
assert(!is_nan($this->x) and !is_infinite($this->x) and !is_nan($this->y) and !is_infinite($this->y) and !is_nan($this->z) and !is_infinite($this->z));
|
||||
@ -515,16 +515,16 @@ abstract class Entity extends Location implements Metadatable{
|
||||
|
||||
/**
|
||||
* @param int|string $type
|
||||
* @param Chunk $chunk
|
||||
* @param Level $level
|
||||
* @param CompoundTag $nbt
|
||||
* @param $args
|
||||
*
|
||||
* @return Entity
|
||||
*/
|
||||
public static function createEntity($type, Chunk $chunk, CompoundTag $nbt, ...$args){
|
||||
public static function createEntity($type, Level $level, CompoundTag $nbt, ...$args){
|
||||
if(isset(self::$knownEntities[$type])){
|
||||
$class = self::$knownEntities[$type];
|
||||
return new $class($chunk, $nbt, ...$args);
|
||||
return new $class($level, $nbt, ...$args);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user