mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
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:
@ -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;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\protocol\DataPacket;
|
||||
use pocketmine\network\mcpe\protocol\Packet;
|
||||
|
||||
abstract class Particle{
|
||||
|
||||
@ -86,7 +86,7 @@ abstract class Particle{
|
||||
/**
|
||||
* @param Vector3 $pos
|
||||
*
|
||||
* @return DataPacket|DataPacket[]
|
||||
* @return Packet|Packet[]
|
||||
*/
|
||||
abstract public function encode(Vector3 $pos);
|
||||
|
||||
|
@ -24,14 +24,14 @@ declare(strict_types=1);
|
||||
namespace pocketmine\level\sound;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\protocol\DataPacket;
|
||||
use pocketmine\network\mcpe\protocol\Packet;
|
||||
|
||||
abstract class Sound{
|
||||
|
||||
/**
|
||||
* @param Vector3 $pos
|
||||
*
|
||||
* @return DataPacket|DataPacket[]
|
||||
* @return Packet|Packet[]
|
||||
*/
|
||||
abstract public function encode(Vector3 $pos);
|
||||
|
||||
|
Reference in New Issue
Block a user