mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-08-26 13:09:05 +00:00
World: trigger readStateFromWorld on tile blocks immediately on load
this ensures that the state IDs reflect the actual PM block type, which would probably be important for a bunch of different async things.
This commit is contained in:
parent
17ecf11a1b
commit
be90c6c399
@ -2978,7 +2978,7 @@ class World implements ChunkManager{
|
|||||||
unset($this->blockCache[$chunkHash]);
|
unset($this->blockCache[$chunkHash]);
|
||||||
unset($this->blockCollisionBoxCache[$chunkHash]);
|
unset($this->blockCollisionBoxCache[$chunkHash]);
|
||||||
|
|
||||||
$this->initChunk($x, $z, $chunkData);
|
$this->initChunk($x, $z, $chunkData, $chunk);
|
||||||
|
|
||||||
if(ChunkLoadEvent::hasHandlers()){
|
if(ChunkLoadEvent::hasHandlers()){
|
||||||
(new ChunkLoadEvent($this, $x, $z, $this->chunks[$chunkHash], false))->call();
|
(new ChunkLoadEvent($this, $x, $z, $this->chunks[$chunkHash], false))->call();
|
||||||
@ -2998,7 +2998,7 @@ class World implements ChunkManager{
|
|||||||
return $this->chunks[$chunkHash];
|
return $this->chunks[$chunkHash];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function initChunk(int $chunkX, int $chunkZ, ChunkData $chunkData) : void{
|
private function initChunk(int $chunkX, int $chunkZ, ChunkData $chunkData, Chunk $chunk) : void{
|
||||||
$logger = new \PrefixedLogger($this->logger, "Loading chunk $chunkX $chunkZ");
|
$logger = new \PrefixedLogger($this->logger, "Loading chunk $chunkX $chunkZ");
|
||||||
|
|
||||||
if(count($chunkData->getEntityNBT()) !== 0){
|
if(count($chunkData->getEntityNBT()) !== 0){
|
||||||
@ -3063,6 +3063,16 @@ class World implements ChunkManager{
|
|||||||
}else{
|
}else{
|
||||||
$this->addTile($tile);
|
$this->addTile($tile);
|
||||||
}
|
}
|
||||||
|
$expectedStateId = $chunk->getBlockStateId($tilePosition->getFloorX() & Chunk::COORD_MASK, $tilePosition->getFloorY(), $tilePosition->getFloorZ() & Chunk::COORD_MASK);
|
||||||
|
$actualStateId = $this->getBlock($tilePosition)->getStateId();
|
||||||
|
if($expectedStateId !== $actualStateId){
|
||||||
|
//state ID was updated by readStateFromWorld - typically because the block pulled some data from the tile
|
||||||
|
//make sure this is synced to the chunk
|
||||||
|
//TODO: in the future we should pull tile reading logic out of readStateFromWorld() and do it only
|
||||||
|
//when the tile is loaded - this would be cleaner and faster
|
||||||
|
$chunk->setBlockStateId($tilePosition->getFloorX() & Chunk::COORD_MASK, $tilePosition->getFloorY(), $tilePosition->getFloorZ() & Chunk::COORD_MASK, $actualStateId);
|
||||||
|
$this->logger->debug("Tile " . $tile::class . " at x=$tilePosition->x,y=$tilePosition->y,z=$tilePosition->z updated block state ID from $expectedStateId to $actualStateId");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(Utils::promoteKeys($deletedTiles) as $saveId => $count){
|
foreach(Utils::promoteKeys($deletedTiles) as $saveId => $count){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user