diff --git a/src/pocketmine/network/mcpe/RakLibInterface.php b/src/pocketmine/network/mcpe/RakLibInterface.php index b723c8acb..8045f36b1 100644 --- a/src/pocketmine/network/mcpe/RakLibInterface.php +++ b/src/pocketmine/network/mcpe/RakLibInterface.php @@ -211,7 +211,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ $pk = $packet->__encapsulatedPacket; } - if(!$immediate and !$needACK and $packet::NETWORK_ID !== ProtocolInfo::BATCH_PACKET + if(!$immediate and !$needACK and $packet->canBeBatched() and Network::$BATCH_THRESHOLD >= 0 and strlen($packet->buffer) >= Network::$BATCH_THRESHOLD){ $this->server->batchPackets([$player], [$packet], true); diff --git a/src/pocketmine/network/mcpe/protocol/BatchPacket.php b/src/pocketmine/network/mcpe/protocol/BatchPacket.php index 6eb101479..4f952548e 100644 --- a/src/pocketmine/network/mcpe/protocol/BatchPacket.php +++ b/src/pocketmine/network/mcpe/protocol/BatchPacket.php @@ -31,6 +31,10 @@ class BatchPacket extends DataPacket{ public $payload; + public function canBeBatched() : bool{ + return false; + } + public function decode(){ $this->payload = $this->getString(); } diff --git a/src/pocketmine/network/mcpe/protocol/DataPacket.php b/src/pocketmine/network/mcpe/protocol/DataPacket.php index 7404f3a76..f06fc6ff7 100644 --- a/src/pocketmine/network/mcpe/protocol/DataPacket.php +++ b/src/pocketmine/network/mcpe/protocol/DataPacket.php @@ -40,6 +40,10 @@ abstract class DataPacket extends BinaryStream{ return $this::NETWORK_ID; } + public function canBeBatched() : bool{ + return true; + } + abstract public function encode(); abstract public function decode(); diff --git a/src/pocketmine/network/mcpe/protocol/LoginPacket.php b/src/pocketmine/network/mcpe/protocol/LoginPacket.php index 462388d4a..e1f732e1a 100644 --- a/src/pocketmine/network/mcpe/protocol/LoginPacket.php +++ b/src/pocketmine/network/mcpe/protocol/LoginPacket.php @@ -44,6 +44,10 @@ class LoginPacket extends DataPacket{ public $clientData = []; + public function canBeBatched() : bool{ + return false; + } + public function decode(){ $this->protocol = $this->getInt();