Fixed other invisibility issues

This commit is contained in:
Shoghi Cervantes 2015-06-04 16:51:48 +02:00
parent 05dbf7b47f
commit 71490f60f2
8 changed files with 32 additions and 22 deletions

View File

@ -1670,7 +1670,6 @@ class Server{
])); ]));
$this->logger->info($this->getLanguage()->translateString("pocketmine.server.license", [$this->getName()])); $this->logger->info($this->getLanguage()->translateString("pocketmine.server.license", [$this->getName()]));
PluginManager::$pluginParentTimer = new TimingsHandler("** Plugins");
Timings::init(); Timings::init();
$this->consoleSender = new ConsoleCommandSender(); $this->consoleSender = new ConsoleCommandSender();

View File

@ -512,8 +512,8 @@ abstract class Entity extends Location implements Metadatable{
* @param Player $player * @param Player $player
*/ */
public function spawnTo(Player $player){ public function spawnTo(Player $player){
if(!isset($this->hasSpawned[$player->getId()]) and isset($player->usedChunks[Level::chunkHash($this->chunk->getX(), $this->chunk->getZ())])){ if(!isset($this->hasSpawned[$player->getLoaderId()]) and isset($player->usedChunks[Level::chunkHash($this->chunk->getX(), $this->chunk->getZ())])){
$this->hasSpawned[$player->getId()] = $player; $this->hasSpawned[$player->getLoaderId()] = $player;
} }
} }
@ -557,11 +557,11 @@ abstract class Entity extends Location implements Metadatable{
* @param Player $player * @param Player $player
*/ */
public function despawnFrom(Player $player){ public function despawnFrom(Player $player){
if(isset($this->hasSpawned[$player->getId()])){ if(isset($this->hasSpawned[$player->getLoaderId()])){
$pk = new RemoveEntityPacket(); $pk = new RemoveEntityPacket();
$pk->eid = $this->id; $pk->eid = $this->id;
$player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); $player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING));
unset($this->hasSpawned[$player->getId()]); unset($this->hasSpawned[$player->getLoaderId()]);
} }
} }

View File

@ -189,8 +189,8 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
} }
public function spawnTo(Player $player){ public function spawnTo(Player $player){
if($player !== $this and !isset($this->hasSpawned[$player->getId()])){ if($player !== $this and !isset($this->hasSpawned[$player->getLoaderId()])){
$this->hasSpawned[$player->getId()] = $player; $this->hasSpawned[$player->getLoaderId()] = $player;
if(strlen($this->skin) < 64 * 32 * 4){ if(strlen($this->skin) < 64 * 32 * 4){
throw new \InvalidStateException((new \ReflectionClass($this))->getShortName() . " must have a valid skin set"); throw new \InvalidStateException((new \ReflectionClass($this))->getShortName() . " must have a valid skin set");
@ -221,12 +221,12 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
} }
public function despawnFrom(Player $player){ public function despawnFrom(Player $player){
if(isset($this->hasSpawned[$player->getId()])){ if(isset($this->hasSpawned[$player->getLoaderId()])){
$pk = new RemovePlayerPacket(); $pk = new RemovePlayerPacket();
$pk->eid = $this->getId(); $pk->eid = $this->getId();
$pk->clientID = $this->getId(); $pk->clientID = $this->getId();
$player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); $player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING));
unset($this->hasSpawned[$player->getId()]); unset($this->hasSpawned[$player->getLoaderId()]);
} }
} }

View File

@ -134,6 +134,9 @@ abstract class Timings{
self::$timerEntityAIMove = new TimingsHandler("** livingEntityAIMove"); self::$timerEntityAIMove = new TimingsHandler("** livingEntityAIMove");
self::$timerEntityTickRest = new TimingsHandler("** livingEntityTickRest"); self::$timerEntityTickRest = new TimingsHandler("** livingEntityTickRest");
PluginManager::$pluginParentTimer = new TimingsHandler("** Plugins");
self::$schedulerSyncTimer = new TimingsHandler("** Scheduler - Sync Tasks", PluginManager::$pluginParentTimer); self::$schedulerSyncTimer = new TimingsHandler("** Scheduler - Sync Tasks", PluginManager::$pluginParentTimer);
self::$schedulerAsyncTimer = new TimingsHandler("** Scheduler - Async Tasks"); self::$schedulerAsyncTimer = new TimingsHandler("** Scheduler - Async Tasks");

View File

@ -49,7 +49,7 @@ class TimingsHandler{
*/ */
public function __construct($name, TimingsHandler $parent = null){ public function __construct($name, TimingsHandler $parent = null){
$this->name = $name; $this->name = $name;
if($parent instanceof TimingsHandler){ if($parent !== null){
$this->parent = $parent; $this->parent = $parent;
} }
@ -125,7 +125,7 @@ class TimingsHandler{
public function startTiming(){ public function startTiming(){
if(PluginManager::$useTimings and ++$this->timingDepth === 1){ if(PluginManager::$useTimings and ++$this->timingDepth === 1){
$this->start = microtime(true); $this->start = microtime(true);
if($this->parent instanceof TimingsHandler and ++$this->parent->timingDepth === 1){ if($this->parent !== null and ++$this->parent->timingDepth === 1){
$this->parent->start = $this->start; $this->parent->start = $this->start;
} }
} }
@ -143,7 +143,7 @@ class TimingsHandler{
++$this->curCount; ++$this->curCount;
++$this->count; ++$this->count;
$this->start = 0; $this->start = 0;
if($this->parent instanceof TimingsHandler){ if($this->parent !== null){
$this->parent->stopTiming(); $this->parent->stopTiming();
} }
} }

View File

@ -2191,7 +2191,7 @@ class Level implements ChunkManager, Metadatable{
} }
$this->timings->syncChunkSendPrepareTimer->startTiming(); $this->timings->syncChunkSendPrepareTimer->startTiming();
$task = $this->provider->requestChunkTask($x, $z); $task = $this->provider->requestChunkTask($x, $z);
if($task instanceof AsyncTask){ if($task !== null){
$this->server->getScheduler()->scheduleAsyncTask($task); $this->server->getScheduler()->scheduleAsyncTask($task);
} }
$this->timings->syncChunkSendPrepareTimer->stopTiming(); $this->timings->syncChunkSendPrepareTimer->stopTiming();
@ -2582,9 +2582,9 @@ class Level implements ChunkManager, Metadatable{
return false; return false;
} }
Timings::$populationTimer->startTiming();
$chunk = $this->getChunk($x, $z, true); $chunk = $this->getChunk($x, $z, true);
if(!$chunk->isPopulated()){ if(!$chunk->isPopulated()){
Timings::$populationTimer->startTiming();
$populate = true; $populate = true;
for($xx = -1; $xx <= 1; ++$xx){ for($xx = -1; $xx <= 1; ++$xx){
for($zz = -1; $zz <= 1; ++$zz){ for($zz = -1; $zz <= 1; ++$zz){
@ -2606,14 +2606,12 @@ class Level implements ChunkManager, Metadatable{
$task = new PopulationTask($this, $chunk); $task = new PopulationTask($this, $chunk);
$this->server->getScheduler()->scheduleAsyncTask($task); $this->server->getScheduler()->scheduleAsyncTask($task);
} }
Timings::$populationTimer->stopTiming();
return false;
} }
Timings::$populationTimer->stopTiming(); Timings::$populationTimer->stopTiming();
return false; return false;
} }
Timings::$populationTimer->stopTiming();
return true; return true;
} }

View File

@ -120,14 +120,21 @@ class McRegion extends BaseLevelProvider{
} }
$tiles = ""; $tiles = "";
$nbt = new NBT(NBT::LITTLE_ENDIAN);
foreach($chunk->getTiles() as $tile){ if(count($chunk->getTiles()) > 0){
if($tile instanceof Spawnable){ $nbt = new NBT(NBT::LITTLE_ENDIAN);
$nbt->setData($tile->getSpawnCompound()); $list = [];
$tiles .= $nbt->write(); foreach($chunk->getTiles() as $tile){
if($tile instanceof Spawnable){
$list[] = $tile->getSpawnCompound();
}
} }
$nbt->setData($list);
$tiles = $nbt->write();
} }
$heightmap = pack("C*", ...$chunk->getHeightMapArray()); $heightmap = pack("C*", ...$chunk->getHeightMapArray());
$biomeColors = pack("N*", ...$chunk->getBiomeColorArray()); $biomeColors = pack("N*", ...$chunk->getBiomeColorArray());

View File

@ -47,6 +47,9 @@ abstract class Spawnable extends Tile{
return true; return true;
} }
/**
* @return Compound
*/
public abstract function getSpawnCompound(); public abstract function getSpawnCompound();
public function __construct(FullChunk $chunk, Compound $nbt){ public function __construct(FullChunk $chunk, Compound $nbt){