mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-11 00:09:39 +00:00
World: drop getChunkEntities(), use getChunk()->getEntities()
everywhere this function is used, it should be assumed/expected that the chunk in question is already present and loaded.
This commit is contained in:
parent
a4042e5d18
commit
452cfe2f59
@ -827,7 +827,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
|||||||
$world = $world ?? $this->world;
|
$world = $world ?? $this->world;
|
||||||
$index = World::chunkHash($x, $z);
|
$index = World::chunkHash($x, $z);
|
||||||
if(isset($this->usedChunks[$index])){
|
if(isset($this->usedChunks[$index])){
|
||||||
foreach($world->getChunkEntities($x, $z) as $entity){
|
foreach($world->getChunk($x, $z)->getEntities() as $entity){
|
||||||
if($entity !== $this){
|
if($entity !== $this){
|
||||||
$entity->despawnFrom($this);
|
$entity->despawnFrom($this);
|
||||||
}
|
}
|
||||||
@ -841,7 +841,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function spawnEntitiesOnChunk(int $chunkX, int $chunkZ) : void{
|
protected function spawnEntitiesOnChunk(int $chunkX, int $chunkZ) : void{
|
||||||
foreach($this->world->getChunkEntities($chunkX, $chunkZ) as $entity){
|
foreach($this->world->getChunk($chunkX, $chunkZ)->getEntities() as $entity){
|
||||||
if($entity !== $this and !$entity->isFlaggedForDespawn()){
|
if($entity !== $this and !$entity->isFlaggedForDespawn()){
|
||||||
$entity->spawnTo($this);
|
$entity->spawnTo($this);
|
||||||
}
|
}
|
||||||
|
@ -1829,7 +1829,7 @@ class World implements ChunkManager{
|
|||||||
if(!$this->isChunkLoaded($x, $z)){
|
if(!$this->isChunkLoaded($x, $z)){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
foreach($this->getChunkEntities($x, $z) as $ent){
|
foreach($this->getChunk($x, $z)->getEntities() as $ent){
|
||||||
/** @var Entity|null $entity */
|
/** @var Entity|null $entity */
|
||||||
if($ent->canBeCollidedWith() and ($entity === null or ($ent !== $entity and $entity->canCollideWith($ent))) and $ent->boundingBox->intersectsWith($bb)){
|
if($ent->canBeCollidedWith() and ($entity === null or ($ent !== $entity and $entity->canCollideWith($ent))) and $ent->boundingBox->intersectsWith($bb)){
|
||||||
$nearby[] = $ent;
|
$nearby[] = $ent;
|
||||||
@ -1863,7 +1863,7 @@ class World implements ChunkManager{
|
|||||||
if(!$this->isChunkLoaded($x, $z)){
|
if(!$this->isChunkLoaded($x, $z)){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
foreach($this->getChunkEntities($x, $z) as $ent){
|
foreach($this->getChunk($x, $z)->getEntities() as $ent){
|
||||||
if($ent !== $entity and $ent->boundingBox->intersectsWith($bb)){
|
if($ent !== $entity and $ent->boundingBox->intersectsWith($bb)){
|
||||||
$nearby[] = $ent;
|
$nearby[] = $ent;
|
||||||
}
|
}
|
||||||
@ -1902,7 +1902,7 @@ class World implements ChunkManager{
|
|||||||
if(!$this->isChunkLoaded($x, $z)){
|
if(!$this->isChunkLoaded($x, $z)){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
foreach($this->getChunkEntities($x, $z) as $entity){
|
foreach($this->getChunk($x, $z)->getEntities() as $entity){
|
||||||
if(!($entity instanceof $entityType) or $entity->isFlaggedForDespawn() or (!$includeDead and !$entity->isAlive())){
|
if(!($entity instanceof $entityType) or $entity->isFlaggedForDespawn() or (!$includeDead and !$entity->isAlive())){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1961,18 +1961,6 @@ class World implements ChunkManager{
|
|||||||
return ($chunk = $this->getChunk($x >> 4, $z >> 4)) !== null ? $chunk->getTile($x & 0x0f, $y, $z & 0x0f) : null;
|
return ($chunk = $this->getChunk($x >> 4, $z >> 4)) !== null ? $chunk->getTile($x & 0x0f, $y, $z & 0x0f) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a list of the entities on a given chunk
|
|
||||||
*
|
|
||||||
* @param int $X
|
|
||||||
* @param int $Z
|
|
||||||
*
|
|
||||||
* @return Entity[]
|
|
||||||
*/
|
|
||||||
public function getChunkEntities(int $X, int $Z) : array{
|
|
||||||
return ($chunk = $this->getChunk($X, $Z)) !== null ? $chunk->getEntities() : [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the raw block skylight level
|
* Gets the raw block skylight level
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user