changed some packets + tried to make client join the server

This commit is contained in:
GameHerobrine 2023-02-21 07:51:21 +03:00
parent 7de564eea9
commit a9be309de9
4 changed files with 41 additions and 13 deletions

View file

@ -236,10 +236,10 @@ class Player{
$this->entity->resetSpeed(); $this->entity->resetSpeed();
$this->entity->updateLast(); $this->entity->updateLast();
$this->entity->calculateVelocity(); $this->entity->calculateVelocity();
if($terrain === true){ /*if($terrain === true){
$this->orderChunks(); $this->orderChunks();
$this->getNextChunk($this->level); $this->getNextChunk($this->level);
} }*/
$this->entity->check = true; $this->entity->check = true;
if($force === true){ if($force === true){
$this->forceMovement = $pos; $this->forceMovement = $pos;
@ -458,7 +458,9 @@ class Player{
} }
} }
$pk = new ChunkDataPacket; $pk = new FullChunkDataPacket;
$pk->putInt($X);
$pk->putInt($Z);
$pk->chunkX = $X; $pk->chunkX = $X;
$pk->chunkZ = $Z; $pk->chunkZ = $Z;
$pk->data = $this->level->getOrderedChunk($X, $Z, $Yndex); $pk->data = $this->level->getOrderedChunk($X, $Z, $Yndex);
@ -1391,13 +1393,16 @@ class Player{
$pk = new LoginStatusPacket; $pk = new LoginStatusPacket;
$pk->status = 0; $pk->status = 0;
$this->dataPacket($pk); $this->dataPacket($pk);
$spawnPos = $this->getSpawn();
$pk = new StartGamePacket; $pk = new StartGamePacket;
$pk->seed = $this->level->getSeed(); $pk->seed = $this->level->getSeed();
$pk->spawnX = (int) $spawnPos->x;
$pk->spawnY = (int) $spawnPos->y;
$pk->spawnZ = (int) $spawnPos->z;
$pk->x = $this->data->get("position")["x"]; $pk->x = $this->data->get("position")["x"];
$pk->y = $this->data->get("position")["y"]; $pk->y = $this->data->get("position")["y"];
$pk->z = $this->data->get("position")["z"]; $pk->z = $this->data->get("position")["z"];
$pk->generator = 0; $pk->generator = 0; //1 - inf, 0 - old, 2 - flat
$pk->gamemode = $this->gamemode & 0x01; $pk->gamemode = $this->gamemode & 0x01;
$pk->eid = 0; $pk->eid = 0;
$this->dataPacket($pk); $this->dataPacket($pk);
@ -1482,7 +1487,8 @@ class Player{
$this->sendInventory(); $this->sendInventory();
$this->sendSettings(); $this->sendSettings();
//$this->server->schedule(50, [$this, "orderChunks"], []); $this->orderChunks();
$this->getNextChunk($this->level);
$this->blocked = false; $this->blocked = false;
$this->server->handle("player.spawn", $this); $this->server->handle("player.spawn", $this);

View file

@ -71,7 +71,7 @@ abstract class ProtocolInfo{
const ADVENTURE_SETTINGS_PACKET = 0xb7; const ADVENTURE_SETTINGS_PACKET = 0xb7;
const ENTITY_DATA_PACKET = 0xb8; const ENTITY_DATA_PACKET = 0xb8;
const PLAYER_INPUT_PACKET = 0xb9; const PLAYER_INPUT_PACKET = 0xb9;
//const FULL_CHUNK_DATA_PACKET = 0xba; const FULL_CHUNK_DATA_PACKET = 0xba;
//const UNLOAD_CHUNK_PACKET = 0xbb; //const UNLOAD_CHUNK_PACKET = 0xbb;
} }
@ -85,4 +85,4 @@ abstract class ProtocolInfo{
/***REM_START***/ /***REM_START***/
require_once(FILE_PATH . "src/network/raknet/RakNetDataPacket.php"); require_once(FILE_PATH . "src/network/raknet/RakNetDataPacket.php");
/***REM_END***/ /***REM_END***/

View file

@ -0,0 +1,21 @@
<?php
class FullChunkDataPacket extends RakNetDataPacket{
public $chunkX;
public $chunkZ;
public $data;
public function pid(){
return ProtocolInfo::FULL_CHUNK_DATA_PACKET;
}
public function decode(){
}
public function encode(){
$this->reset();
$this->put($this->data);
}
}

View file

@ -5,10 +5,8 @@ class StartGamePacket extends RakNetDataPacket{
public $generator; public $generator;
public $gamemode; public $gamemode;
public $eid; public $eid;
public $x; public $x, $y, $z;
public $y; public $spawnX, $spawnY, $spawnZ;
public $z;
public function pid(){ public function pid(){
return ProtocolInfo::START_GAME_PACKET; return ProtocolInfo::START_GAME_PACKET;
} }
@ -23,9 +21,12 @@ class StartGamePacket extends RakNetDataPacket{
$this->putInt($this->generator); $this->putInt($this->generator);
$this->putInt($this->gamemode); $this->putInt($this->gamemode);
$this->putInt($this->eid); $this->putInt($this->eid);
$this->putInt($this->spawnX);
$this->putInt($this->spawnY);
$this->putInt($this->spawnZ);
$this->putFloat($this->x); $this->putFloat($this->x);
$this->putFloat($this->y); $this->putFloat($this->y);
$this->putFloat($this->z); $this->putFloat($this->z);
} }
} }