mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Reduce BatchPacket hacks
we can't get rid of these hacks entirely because BAcKWARdS ComPaTIbilitY, but this at least ensures that things over PID 127 won't burn the house down when 1.12 gets here. This also reduces conflicts with 4.0 line.
This commit is contained in:
parent
74b9922a28
commit
4a35516441
@ -27,7 +27,6 @@ use pocketmine\event\player\PlayerCreationEvent;
|
||||
use pocketmine\network\AdvancedSourceInterface;
|
||||
use pocketmine\network\mcpe\protocol\BatchPacket;
|
||||
use pocketmine\network\mcpe\protocol\DataPacket;
|
||||
use pocketmine\network\mcpe\protocol\PacketPool;
|
||||
use pocketmine\network\mcpe\protocol\ProtocolInfo;
|
||||
use pocketmine\network\Network;
|
||||
use pocketmine\Player;
|
||||
@ -166,7 +165,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
||||
$address = $player->getAddress();
|
||||
try{
|
||||
if($packet->buffer !== ""){
|
||||
$pk = PacketPool::getPacket($packet->buffer);
|
||||
$pk = new BatchPacket($packet->buffer);
|
||||
$player->handleDataPacket($pk);
|
||||
}
|
||||
}catch(\Throwable $e){
|
||||
|
@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use function ord;
|
||||
use pocketmine\utils\Binary;
|
||||
|
||||
class PacketPool{
|
||||
/** @var \SplFixedArray<DataPacket> */
|
||||
@ -32,7 +32,6 @@ class PacketPool{
|
||||
public static function init(){
|
||||
static::$pool = new \SplFixedArray(256);
|
||||
|
||||
//Normal packets
|
||||
static::registerPacket(new LoginPacket());
|
||||
static::registerPacket(new PlayStatusPacket());
|
||||
static::registerPacket(new ServerToClientHandshakePacket());
|
||||
@ -158,8 +157,6 @@ class PacketPool{
|
||||
static::registerPacket(new VideoStreamConnectPacket());
|
||||
static::registerPacket(new MapCreateLockedCopyPacket());
|
||||
static::registerPacket(new OnScreenTextureAnimationPacket());
|
||||
|
||||
static::registerPacket(new BatchPacket());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -184,10 +181,10 @@ class PacketPool{
|
||||
* @return DataPacket
|
||||
*/
|
||||
public static function getPacket(string $buffer) : DataPacket{
|
||||
$pk = static::getPacketById(ord($buffer{0}));
|
||||
$pk->setBuffer($buffer);
|
||||
$offset = 0;
|
||||
$pk = static::getPacketById(Binary::readUnsignedVarInt($buffer, $offset));
|
||||
$pk->setBuffer($buffer, $offset);
|
||||
|
||||
return $pk;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user