mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-18 09:24:05 +00:00
Fixed wasteful throwaway objects used for spawn positions
This commit is contained in:
parent
d30a6b60b7
commit
9a956692de
@ -1102,8 +1102,9 @@ class Server{
|
|||||||
|
|
||||||
$this->getLogger()->notice($this->getLanguage()->translateString("pocketmine.level.backgroundGeneration", [$name]));
|
$this->getLogger()->notice($this->getLanguage()->translateString("pocketmine.level.backgroundGeneration", [$name]));
|
||||||
|
|
||||||
$centerX = $level->getSpawnLocation()->getX() >> 4;
|
$spawnLocation = $level->getSpawnLocation();
|
||||||
$centerZ = $level->getSpawnLocation()->getZ() >> 4;
|
$centerX = $spawnLocation->x >> 4;
|
||||||
|
$centerZ = $spawnLocation->z >> 4;
|
||||||
|
|
||||||
$order = [];
|
$order = [];
|
||||||
|
|
||||||
|
@ -1711,7 +1711,9 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
public function checkSpawnProtection(Player $player, Vector3 $vector) : bool{
|
public function checkSpawnProtection(Player $player, Vector3 $vector) : bool{
|
||||||
if(!$player->hasPermission("pocketmine.spawnprotect.bypass") and ($distance = $this->server->getSpawnRadius()) > -1){
|
if(!$player->hasPermission("pocketmine.spawnprotect.bypass") and ($distance = $this->server->getSpawnRadius()) > -1){
|
||||||
$t = new Vector2($vector->x, $vector->z);
|
$t = new Vector2($vector->x, $vector->z);
|
||||||
$s = new Vector2($this->getSpawnLocation()->x, $this->getSpawnLocation()->z);
|
|
||||||
|
$spawnLocation = $this->getSpawnLocation();
|
||||||
|
$s = new Vector2($spawnLocation->x, $spawnLocation->z);
|
||||||
if(count($this->server->getOps()->getAll()) > 0 and $t->distance($s) <= $distance){
|
if(count($this->server->getOps()->getAll()) > 0 and $t->distance($s) <= $distance){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2811,8 +2813,9 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isSpawnChunk(int $X, int $Z) : bool{
|
public function isSpawnChunk(int $X, int $Z) : bool{
|
||||||
$spawnX = $this->provider->getSpawn()->getX() >> 4;
|
$spawn = $this->provider->getSpawn();
|
||||||
$spawnZ = $this->provider->getSpawn()->getZ() >> 4;
|
$spawnX = $spawn->x >> 4;
|
||||||
|
$spawnZ = $spawn->z >> 4;
|
||||||
|
|
||||||
return abs($X - $spawnX) <= 1 and abs($Z - $spawnZ) <= 1;
|
return abs($X - $spawnX) <= 1 and abs($Z - $spawnZ) <= 1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user