mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 06:25:32 +00:00
Fixed server crash when Tile Entities / Entities were loaded and requested the same chunk
This commit is contained in:
parent
ce91f2943a
commit
05a81bebf4
@ -1515,7 +1515,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
return $this->chunks[$index];
|
return $this->chunks[$index];
|
||||||
}elseif(($chunk = $this->provider->getChunk($x, $z, $create)) instanceof FullChunk){
|
}elseif(($chunk = $this->provider->getChunk($x, $z, $create)) instanceof FullChunk){
|
||||||
$this->chunks[$index] = $chunk;
|
$this->chunks[$index] = $chunk;
|
||||||
|
$chunk->initChunk();
|
||||||
return $chunk;
|
return $chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,6 +248,8 @@ interface FullChunk{
|
|||||||
*/
|
*/
|
||||||
public function unload($save = true, $safe = true);
|
public function unload($save = true, $safe = true);
|
||||||
|
|
||||||
|
public function initChunk();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
|
@ -55,6 +55,10 @@ abstract class BaseFullChunk implements FullChunk{
|
|||||||
|
|
||||||
protected $blockLight;
|
protected $blockLight;
|
||||||
|
|
||||||
|
protected $NBTtiles;
|
||||||
|
|
||||||
|
protected $NBTentities;
|
||||||
|
|
||||||
/** @var LevelProvider */
|
/** @var LevelProvider */
|
||||||
protected $provider;
|
protected $provider;
|
||||||
|
|
||||||
@ -98,9 +102,14 @@ abstract class BaseFullChunk implements FullChunk{
|
|||||||
$this->biomeColors = array_fill(0, 256, Binary::readInt("\x00\x85\xb2\x4a"));
|
$this->biomeColors = array_fill(0, 256, Binary::readInt("\x00\x85\xb2\x4a"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->getProvider() instanceof LevelProvider){
|
$this->NBTtiles = $tiles;
|
||||||
|
$this->NBTentities = $entities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function initChunk(){
|
||||||
|
if($this->getProvider() instanceof LevelProvider and $this->NBTentities !== null){
|
||||||
$this->getProvider()->getLevel()->timings->syncChunkLoadEntitiesTimer->startTiming();
|
$this->getProvider()->getLevel()->timings->syncChunkLoadEntitiesTimer->startTiming();
|
||||||
foreach($entities as $nbt){
|
foreach($this->NBTentities as $nbt){
|
||||||
if($nbt instanceof Compound){
|
if($nbt instanceof Compound){
|
||||||
if(!isset($nbt->id)){
|
if(!isset($nbt->id)){
|
||||||
continue;
|
continue;
|
||||||
@ -121,7 +130,7 @@ abstract class BaseFullChunk implements FullChunk{
|
|||||||
$this->getProvider()->getLevel()->timings->syncChunkLoadEntitiesTimer->stopTiming();
|
$this->getProvider()->getLevel()->timings->syncChunkLoadEntitiesTimer->stopTiming();
|
||||||
|
|
||||||
$this->getProvider()->getLevel()->timings->syncChunkLoadTileEntitiesTimer->startTiming();
|
$this->getProvider()->getLevel()->timings->syncChunkLoadTileEntitiesTimer->startTiming();
|
||||||
foreach($tiles as $nbt){
|
foreach($this->NBTtiles as $nbt){
|
||||||
if($nbt instanceof Compound){
|
if($nbt instanceof Compound){
|
||||||
if(!isset($nbt->id)){
|
if(!isset($nbt->id)){
|
||||||
continue;
|
continue;
|
||||||
@ -140,6 +149,8 @@ abstract class BaseFullChunk implements FullChunk{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->getProvider()->getLevel()->timings->syncChunkLoadTileEntitiesTimer->stopTiming();
|
$this->getProvider()->getLevel()->timings->syncChunkLoadTileEntitiesTimer->stopTiming();
|
||||||
|
$this->NBTentities = null;
|
||||||
|
$this->NBTtiles = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user