mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +00:00
World: never delete entities in setChunk()
entities exist completely independently from chunks now, so there is no need to interact with them whatsoever. As I wrote in #4520, there's no sense in deleting entities here, since a chunk replacement is essentially just a mass block update. On that theme, it might be a good idea to call Entity->onNearbyBlockChange() for all entities in the target and adjacent chunks when replacing a chunk, to ensure that they get the proper movement updates.
This commit is contained in:
parent
d78801b9d5
commit
c66790b6a6
@ -2125,18 +2125,13 @@ class World implements ChunkManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $deleteEntitiesAndTiles Whether to delete entities and tiles on the old chunk, or transfer them to the new one
|
||||
* @param bool $deleteTiles Whether to delete tiles on the old chunk, or transfer them to the new one
|
||||
*/
|
||||
public function setChunk(int $chunkX, int $chunkZ, Chunk $chunk, bool $deleteEntitiesAndTiles = true) : void{
|
||||
public function setChunk(int $chunkX, int $chunkZ, Chunk $chunk, bool $deleteTiles = true) : void{
|
||||
$chunkHash = World::chunkHash($chunkX, $chunkZ);
|
||||
$oldChunk = $this->loadChunk($chunkX, $chunkZ);
|
||||
if($oldChunk !== null and $oldChunk !== $chunk){
|
||||
if($deleteEntitiesAndTiles){
|
||||
foreach($this->getChunkEntities($chunkX, $chunkZ) as $entity){
|
||||
if(!($entity instanceof Player)){
|
||||
$entity->close();
|
||||
}
|
||||
}
|
||||
if($deleteTiles){
|
||||
foreach($oldChunk->getTiles() as $tile){
|
||||
$tile->close();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user