mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-28 14:19:53 +00:00
Merge branch 'api3/network' into api3/network-mcpe-1.1
This commit is contained in:
commit
b7b7a93e4e
@ -2225,18 +2225,20 @@ class Level implements ChunkManager, Metadatable{
|
||||
$oldEntities = $oldChunk !== null ? $oldChunk->getEntities() : [];
|
||||
$oldTiles = $oldChunk !== null ? $oldChunk->getTiles() : [];
|
||||
|
||||
$this->provider->setChunk($chunkX, $chunkZ, $chunk);
|
||||
$this->chunks[$index] = $chunk;
|
||||
|
||||
foreach($oldEntities as $entity){
|
||||
$chunk->addEntity($entity);
|
||||
$oldChunk->removeEntity($entity);
|
||||
$entity->chunk = $chunk;
|
||||
}
|
||||
|
||||
foreach($oldTiles as $tile){
|
||||
$chunk->addTile($tile);
|
||||
$oldChunk->removeTile($tile);
|
||||
$tile->chunk = $chunk;
|
||||
}
|
||||
|
||||
$this->provider->setChunk($chunkX, $chunkZ, $chunk);
|
||||
$this->chunks[$index] = $chunk;
|
||||
}
|
||||
|
||||
unset($this->chunkCache[$index]);
|
||||
|
@ -580,6 +580,9 @@ class Chunk{
|
||||
* @param Entity $entity
|
||||
*/
|
||||
public function addEntity(Entity $entity){
|
||||
if($entity->closed){
|
||||
throw new \InvalidArgumentException("Attempted to add a garbage closed Entity to a chunk");
|
||||
}
|
||||
$this->entities[$entity->getId()] = $entity;
|
||||
if(!($entity instanceof Player) and $this->isInit){
|
||||
$this->hasChanged = true;
|
||||
@ -600,6 +603,9 @@ class Chunk{
|
||||
* @param Tile $tile
|
||||
*/
|
||||
public function addTile(Tile $tile){
|
||||
if($tile->closed){
|
||||
throw new \InvalidArgumentException("Attempted to add a garbage closed Tile to a chunk");
|
||||
}
|
||||
$this->tiles[$tile->getId()] = $tile;
|
||||
if(isset($this->tileList[$index = (($tile->x & 0x0f) << 12) | (($tile->z & 0x0f) << 8) | ($tile->y & 0xff)]) and $this->tileList[$index] !== $tile){
|
||||
$this->tileList[$index]->close();
|
||||
|
Loading…
x
Reference in New Issue
Block a user