mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Fixed Tiles/Entities not using the correct chunk type
This commit is contained in:
parent
765d4f30c7
commit
1a442b793c
@ -35,6 +35,7 @@ use pocketmine\event\entity\EntitySpawnEvent;
|
||||
use pocketmine\event\entity\EntityTeleportEvent;
|
||||
use pocketmine\event\Timings;
|
||||
use pocketmine\level\format\Chunk;
|
||||
use pocketmine\level\format\FullChunk;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\level\Position;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
@ -146,7 +147,7 @@ abstract class Entity extends Position implements Metadatable{
|
||||
public $closed = false;
|
||||
|
||||
|
||||
public function __construct(Chunk $chunk, Compound $nbt){
|
||||
public function __construct(FullChunk $chunk, Compound $nbt){
|
||||
if($chunk->getLevel() === null){
|
||||
throw new \Exception("Invalid garbage Chunk given to Entity");
|
||||
}
|
||||
@ -932,7 +933,7 @@ abstract class Entity extends Position implements Metadatable{
|
||||
|
||||
|
||||
if($this->chunk === null or ($this->chunk->getX() !== ($this->x >> 4) and $this->chunk->getZ() !== ($this->z >> 4))){
|
||||
if($this->chunk instanceof Chunk){
|
||||
if($this->chunk instanceof FullChunk){
|
||||
$this->chunk->removeEntity($this);
|
||||
}
|
||||
$this->getLevel()->loadChunk($this->x >> 4, $this->z >> 4);
|
||||
@ -1040,7 +1041,7 @@ abstract class Entity extends Position implements Metadatable{
|
||||
if($this->closed === false){
|
||||
$this->closed = true;
|
||||
unset(Entity::$needUpdate[$this->id]);
|
||||
if($this->chunk instanceof Chunk){
|
||||
if($this->chunk instanceof FullChunk){
|
||||
$this->chunk->removeEntity($this);
|
||||
}
|
||||
$this->getLevel()->removeEntity($this);
|
||||
|
@ -37,6 +37,7 @@ use pocketmine\event\LevelTimings;
|
||||
use pocketmine\event\player\PlayerInteractEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\format\Chunk;
|
||||
use pocketmine\level\format\FullChunk;
|
||||
use pocketmine\level\format\generic\EmptyChunkSection;
|
||||
use pocketmine\level\format\LevelProvider;
|
||||
use pocketmine\level\format\SimpleChunk;
|
||||
@ -1309,6 +1310,12 @@ class Level implements ChunkManager, Metadatable{
|
||||
}
|
||||
$blockIds = [];
|
||||
$data = [];
|
||||
|
||||
if(!$this->useSections){
|
||||
//TODO
|
||||
return new SimpleChunk($x, $z, 0);
|
||||
}
|
||||
|
||||
for($Y = 0; $Y < 8; ++$Y){
|
||||
$section = $chunk->getSection($Y);
|
||||
$blockIds[$Y] = $section->getIdArray();
|
||||
@ -1573,13 +1580,13 @@ class Level implements ChunkManager, Metadatable{
|
||||
*/
|
||||
public function loadChunk($x, $z, $generate = true){
|
||||
if($generate === true){
|
||||
return $this->getChunkAt($x, $z, true) instanceof Chunk;
|
||||
return $this->getChunkAt($x, $z, true) instanceof FullChunk;
|
||||
}
|
||||
|
||||
$this->cancelUnloadChunkRequest($x, $z);
|
||||
|
||||
$chunk = $this->provider->getChunk($x, $z, false);
|
||||
if($chunk instanceof Chunk){
|
||||
if($chunk instanceof FullChunk){
|
||||
$this->chunks[Level::chunkHash($x, $z)] = $chunk;
|
||||
return true;
|
||||
}else{
|
||||
@ -1587,7 +1594,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
$this->provider->loadChunk($x, $z);
|
||||
$this->timings->syncChunkLoadTimer->stopTiming();
|
||||
|
||||
if(($chunk = $this->provider->getChunk($x, $z)) instanceof Chunk){
|
||||
if(($chunk = $this->provider->getChunk($x, $z)) instanceof FullChunk){
|
||||
$this->chunks[Level::chunkHash($x, $z)] = $chunk;
|
||||
return true;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ use pocketmine\inventory\DoubleChestInventory;
|
||||
use pocketmine\inventory\InventoryHolder;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\format\Chunk;
|
||||
use pocketmine\level\format\FullChunk;
|
||||
use pocketmine\math\Vector3 as Vector3;
|
||||
use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\tag\Byte;
|
||||
@ -42,7 +43,7 @@ class Chest extends Spawnable implements InventoryHolder, Container{
|
||||
/** @var DoubleChestInventory */
|
||||
protected $doubleInventory = null;
|
||||
|
||||
public function __construct(Chunk $chunk, Compound $nbt){
|
||||
public function __construct(FullChunk $chunk, Compound $nbt){
|
||||
$nbt["id"] = Tile::CHEST;
|
||||
parent::__construct($chunk, $nbt);
|
||||
$this->inventory = new ChestInventory($this);
|
||||
|
@ -27,6 +27,7 @@ use pocketmine\inventory\FurnaceRecipe;
|
||||
use pocketmine\inventory\InventoryHolder;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\format\Chunk;
|
||||
use pocketmine\level\format\FullChunk;
|
||||
use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\tag\Byte;
|
||||
use pocketmine\nbt\tag\Compound;
|
||||
@ -37,7 +38,7 @@ class Furnace extends Tile implements InventoryHolder, Container{
|
||||
/** @var FurnaceInventory */
|
||||
protected $inventory;
|
||||
|
||||
public function __construct(Chunk $chunk, Compound $nbt){
|
||||
public function __construct(FullChunk $chunk, Compound $nbt){
|
||||
$nbt["id"] = Tile::FURNACE;
|
||||
parent::__construct($chunk, $nbt);
|
||||
$this->inventory = new FurnaceInventory($this);
|
||||
|
@ -22,13 +22,14 @@
|
||||
namespace pocketmine\tile;
|
||||
|
||||
use pocketmine\level\format\Chunk;
|
||||
use pocketmine\level\format\FullChunk;
|
||||
use pocketmine\nbt\tag\Compound;
|
||||
use pocketmine\nbt\tag\Int;
|
||||
use pocketmine\nbt\tag\String;
|
||||
|
||||
class Sign extends Spawnable{
|
||||
|
||||
public function __construct(Chunk $chunk, Compound $nbt){
|
||||
public function __construct(FullChunk $chunk, Compound $nbt){
|
||||
$nbt["id"] = Tile::SIGN;
|
||||
if(!isset($nbt->Text1)){
|
||||
$nbt->Text1 = new String("Text1", "");
|
||||
|
@ -22,6 +22,7 @@
|
||||
namespace pocketmine\tile;
|
||||
|
||||
use pocketmine\level\format\Chunk;
|
||||
use pocketmine\level\format\FullChunk;
|
||||
use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\tag\Compound;
|
||||
use pocketmine\network\protocol\EntityDataPacket;
|
||||
@ -48,7 +49,7 @@ abstract class Spawnable extends Tile{
|
||||
|
||||
public abstract function getSpawnCompound();
|
||||
|
||||
public function __construct(Chunk $chunk, Compound $nbt){
|
||||
public function __construct(FullChunk $chunk, Compound $nbt){
|
||||
parent::__construct($chunk, $nbt);
|
||||
$this->spawnToAll();
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\tile;
|
||||
|
||||
use pocketmine\event\Timings;
|
||||
use pocketmine\level\format\Chunk;
|
||||
use pocketmine\level\format\FullChunk;
|
||||
use pocketmine\level\format\LevelProvider;
|
||||
use pocketmine\level\Position;
|
||||
use pocketmine\nbt\tag\Compound;
|
||||
@ -62,7 +63,7 @@ abstract class Tile extends Position{
|
||||
/** @var \pocketmine\event\TimingsHandler */
|
||||
public $tickTimer;
|
||||
|
||||
public function __construct(Chunk $chunk, Compound $nbt){
|
||||
public function __construct(FullChunk $chunk, Compound $nbt){
|
||||
if($chunk->getLevel() === null){
|
||||
throw new \Exception("Invalid garbage Chunk given to Tile");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user