Extract a Packet interface from DataPacket

this is in preparation for clientbound/serverbound packet separation. I did this already on another branch, but the changeset was dependent on a massive refactor to split apart packets and binarystream which i'm still not fully happy with.
This commit is contained in:
Dylan K. Taylor
2019-01-17 12:21:56 +00:00
parent 9c0ebb6350
commit b82e00ffdf
15 changed files with 167 additions and 79 deletions

View File

@ -73,9 +73,9 @@ use pocketmine\nbt\tag\StringTag;
use pocketmine\network\mcpe\ChunkRequestTask;
use pocketmine\network\mcpe\CompressBatchPromise;
use pocketmine\network\mcpe\protocol\AddEntityPacket;
use pocketmine\network\mcpe\protocol\DataPacket;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
use pocketmine\network\mcpe\protocol\Packet;
use pocketmine\network\mcpe\protocol\SetDifficultyPacket;
use pocketmine\network\mcpe\protocol\SetTimePacket;
use pocketmine\network\mcpe\protocol\UpdateBlockPacket;
@ -180,9 +180,9 @@ class Level implements ChunkManager, Metadatable{
/** @var Player[][] */
private $playerLoaders = [];
/** @var DataPacket[][] */
/** @var Packet[][] */
private $chunkPackets = [];
/** @var DataPacket[] */
/** @var Packet[] */
private $globalPackets = [];
/** @var float[] */
@ -595,14 +595,14 @@ class Level implements ChunkManager, Metadatable{
}
/**
* Queues a DataPacket to be sent to all players using the chunk at the specified X/Z coordinates at the end of the
* Queues a packet to be sent to all players using the chunk at the specified X/Z coordinates at the end of the
* current tick.
*
* @param int $chunkX
* @param int $chunkZ
* @param DataPacket $packet
* @param int $chunkX
* @param int $chunkZ
* @param Packet $packet
*/
public function addChunkPacket(int $chunkX, int $chunkZ, DataPacket $packet){
public function addChunkPacket(int $chunkX, int $chunkZ, Packet $packet){
if(!isset($this->chunkPackets[$index = Level::chunkHash($chunkX, $chunkZ)])){
$this->chunkPackets[$index] = [$packet];
}else{
@ -613,19 +613,19 @@ class Level implements ChunkManager, Metadatable{
/**
* Broadcasts a packet to every player who has the target position within their view distance.
*
* @param Vector3 $pos
* @param DataPacket $packet
* @param Vector3 $pos
* @param Packet $packet
*/
public function broadcastPacketToViewers(Vector3 $pos, DataPacket $packet) : void{
public function broadcastPacketToViewers(Vector3 $pos, Packet $packet) : void{
$this->addChunkPacket($pos->getFloorX() >> 4, $pos->getFloorZ() >> 4, $packet);
}
/**
* Broadcasts a packet to every player in the level.
*
* @param DataPacket $packet
* @param Packet $packet
*/
public function broadcastGlobalPacket(DataPacket $packet) : void{
public function broadcastGlobalPacket(Packet $packet) : void{
$this->globalPackets[] = $packet;
}