mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 03:59:43 +00:00
fixed multiworld
This commit is contained in:
parent
eda78f9e17
commit
6ba62666c3
3 changed files with 22 additions and 5 deletions
|
|
@ -205,8 +205,11 @@ class Player{
|
|||
|
||||
$this->level->freeAllChunks($this);
|
||||
unset($this->level->players[$this->CID]);
|
||||
unset($this->level->entityListPositioned["{$this->entity->chunkX} {$this->entity->chunkZ}"][$this->eid]);
|
||||
unset($this->level->entityList[$this->eid]);
|
||||
$this->level = $pos->level;
|
||||
|
||||
$this->entity->level = $this->level;
|
||||
$this->level->entityList[$this->entity->eid] = $this->entity;
|
||||
$this->level->players[$this->CID] = $this;
|
||||
$this->chunksLoaded = [];
|
||||
$this->server->api->entity->spawnToAll($this->entity);
|
||||
|
|
@ -1369,7 +1372,6 @@ class Player{
|
|||
}
|
||||
public function entityTick(){
|
||||
if($this->isSleeping) ++$this->sleepingTime;
|
||||
$this->handlePacketQueues();
|
||||
}
|
||||
public function handleDataPacket(RakNetDataPacket $packet){
|
||||
if($this->connected === false){
|
||||
|
|
@ -1572,7 +1574,7 @@ class Player{
|
|||
|
||||
|
||||
console("[INFO] " . FORMAT_AQUA . $this->username . FORMAT_RESET . "[/" . $this->ip . ":" . $this->port . "] logged in with entity id " . $this->eid . " at (" . $this->entity->level->getName() . ", " . round($this->entity->x, 2) . ", " . round($this->entity->y, 2) . ", " . round($this->entity->z, 2) . ")");
|
||||
return false; //return false so it will not be updated by tickerFunction
|
||||
break;
|
||||
case ProtocolInfo::READY_PACKET:
|
||||
if($this->loggedIn === false){
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -86,6 +86,10 @@ class Entity extends Position
|
|||
public $enableAutojump = false;
|
||||
public $yOffset = 0.0;
|
||||
public $noClip = false;
|
||||
|
||||
public $chunkX = 0;
|
||||
public $chunkZ = 0;
|
||||
|
||||
function __construct(Level $level, $eid, $class, $type = 0, $data = array())
|
||||
{
|
||||
$this->random = new Random();
|
||||
|
|
|
|||
|
|
@ -355,6 +355,8 @@ class Level{
|
|||
}
|
||||
|
||||
public function onTick(PocketMinecraftServer $server, $currentTime){
|
||||
safe_var_dump($this->players);
|
||||
console($this->getName());
|
||||
if(!$this->stopTime) ++$this->time;
|
||||
for($cX = 0; $cX < 16; ++$cX){
|
||||
for($cZ = 0; $cZ < 16; ++$cZ){
|
||||
|
|
@ -385,7 +387,6 @@ class Level{
|
|||
}
|
||||
$curChunkX = (int)$e->x >> 4;
|
||||
$curChunkZ = (int)$e->z >> 4;
|
||||
|
||||
if($e->class === ENTITY_MOB && !$e->isPlayer()){
|
||||
++$this->totalMobsAmount;
|
||||
}
|
||||
|
|
@ -397,7 +398,17 @@ class Level{
|
|||
if($e instanceof Entity){
|
||||
$newChunkX = (int)$e->x >> 4;
|
||||
$newChunkZ = (int)$e->z >> 4;
|
||||
|
||||
if($e->chunkX != $newChunkX || $e->chunkZ != $newChunkZ){
|
||||
$oldIndex = "{$e->chunkX} {$e->chunkZ}";
|
||||
unset($this->entityListPositioned[$oldIndex][$e->eid]);
|
||||
|
||||
if($e->level == $this){
|
||||
$e->chunkX = $newChunkX;
|
||||
$e->chunkZ = $newChunkZ;
|
||||
$newIndex = "$newChunkX $newChunkZ";
|
||||
$this->entityListPositioned[$newIndex][$e->eid] = $e->eid;
|
||||
}
|
||||
}
|
||||
if($e->level != $this && isset($this->entityListPositioned["$curChunkX $curChunkZ"])){
|
||||
unset($this->entityListPositioned["$curChunkX $curChunkZ"][$e->eid]);
|
||||
}else if($curChunkX != $newChunkX || $curChunkZ != $newChunkZ){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue