fixes from npe 0.9 test

This commit is contained in:
root 2023-08-31 04:09:08 +03:00
parent 083ace7eb1
commit 385c8a1bc0
3 changed files with 14 additions and 7 deletions

View file

@ -470,7 +470,7 @@ class Player{
} }
} }
} }
$this->stopUsingChunk($X, $Z); //just in case //$this->stopUsingChunk($X, $Z); //just in case
$pk = new FullChunkDataPacket; $pk = new FullChunkDataPacket;
$pk->chunkX = $X; $pk->chunkX = $X;
$pk->chunkZ = $Z; $pk->chunkZ = $Z;
@ -480,13 +480,16 @@ class Player{
return false; return false;
} }
} }
public $chunkTicker = 0;
public function entityTick(){ public function entityTick(){
//ConsoleAPI::debug("{$this->username}, cl: ".count($this->chunksLoaded).", oc: ".count($this->chunksOrder)); //ConsoleAPI::debug("{$this->username}, cl: ".count($this->chunksLoaded).", oc: ".count($this->chunksOrder));
if(count($this->chunksOrder) <= 0 && $this->level->generatorType != 0){ if(count($this->chunksOrder) <= 0 && $this->level->generatorType != 0){
$this->orderChunks(); $this->orderChunks();
} }
$this->getNextChunk($this->level); if($this->chunkTicker++ > 5){
$this->getNextChunk($this->level);
$this->chunkTicker = 0;
}
} }
public function getNextChunk($world){ public function getNextChunk($world){
@ -1533,6 +1536,7 @@ class Player{
$this->spawned = true; $this->spawned = true;
$this->server->handle("player.spawn", $this); $this->server->handle("player.spawn", $this);
$this->server->api->chat->broadcast($this->username." joined the game"); $this->server->api->chat->broadcast($this->username." joined the game");
//console("Current position: {$this->entity}");
$this->server->api->player->spawnAllPlayers($this); $this->server->api->player->spawnAllPlayers($this);
$this->server->api->player->spawnToAllPlayers($this); $this->server->api->player->spawnToAllPlayers($this);
} }
@ -1543,15 +1547,18 @@ class Player{
if($this->forceMovement->distance($newPos) <= 0.7){ if($this->forceMovement->distance($newPos) <= 0.7){
$this->forceMovement = false; $this->forceMovement = false;
}else{ }else{
//console("force");
$this->teleport($this->forceMovement, $this->entity->yaw, $this->entity->pitch, false); $this->teleport($this->forceMovement, $this->entity->yaw, $this->entity->pitch, false);
} }
} }
$speed = $this->entity->getSpeedMeasure(); $speed = $this->entity->getSpeedMeasure();
if($this->blocked === true or ($this->server->api->getProperty("allow-flight") !== true and (($speed > 9 and ($this->gamemode & 0x01) === 0x00) or $speed > 20 or $this->entity->distance($newPos) > 7)) or $this->server->api->handle("player.move", $this->entity) === false){ if($this->blocked === true or ($this->server->api->getProperty("allow-flight") !== true and (($speed > 9 and ($this->gamemode & 0x01) === 0x00) or $speed > 20 or $this->entity->distance($newPos) > 7)) or $this->server->api->handle("player.move", $this->entity) === false){
if($this->lastCorrect instanceof Vector3){ if($this->lastCorrect instanceof Vector3){
//console("last");
$this->teleport($this->lastCorrect, $this->entity->yaw, $this->entity->pitch, false); $this->teleport($this->lastCorrect, $this->entity->yaw, $this->entity->pitch, false);
} }
}else{ }else{
//console("New Pos: $newPos");
$this->entity->setPosition($newPos, $packet->yaw, $packet->pitch); $this->entity->setPosition($newPos, $packet->yaw, $packet->pitch);
} }
$this->entity->updateAABB(); $this->entity->updateAABB();

View file

@ -766,12 +766,12 @@ class Entity extends Position
$this->updateLast(); $this->updateLast();
$players = $this->server->api->player->getAll($this->level); $players = $this->server->api->player->getAll($this->level);
if($this->player instanceof Player){ if($this->player instanceof Player){
console("gujnbguib"); //console("gujnbguib");
unset($players[$this->player->CID]); unset($players[$this->player->CID]);
$pk = new MovePlayerPacket(); $pk = new MovePlayerPacket();
$pk->eid = $this->eid; $pk->eid = $this->eid;
$pk->x = $this->x; $pk->x = $this->x;
$pk->y = $this->y + $this->getEyeHeight(); $pk->y = $this->y;
$pk->z = $this->z; $pk->z = $this->z;
$pk->yaw = $this->yaw; $pk->yaw = $this->yaw;
$pk->pitch = $this->pitch; $pk->pitch = $this->pitch;

View file

@ -19,8 +19,8 @@ class MovePlayerPacket extends RakNetDataPacket{
$this->y = $this->getFloat(); $this->y = $this->getFloat();
$this->z = $this->getFloat(); $this->z = $this->getFloat();
$this->yaw = $this->getFloat(); $this->yaw = $this->getFloat();
$this->bodyYaw = $this->getFloat();
$this->pitch = $this->getFloat(); $this->pitch = $this->getFloat();
$this->bodyYaw = $this->getFloat();
$this->teleport = ($this->getByte() & 0x80) > 0; $this->teleport = ($this->getByte() & 0x80) > 0;
} }
@ -36,4 +36,4 @@ class MovePlayerPacket extends RakNetDataPacket{
$this->putByte($this->teleport ? 0x80 : 0x00); $this->putByte($this->teleport ? 0x80 : 0x00);
} }
} }