mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Kill BatchPacket, clean up batching related things
DataPacketSendEvent and DataPacketReceiveEvent will no longer capture BatchPackets In most places strings are now used instead of DataPackets, to remove limitations on what data can be sent to a network interface Removed CraftingManager's cyclic dependency on Server There is a lot more work to do aside from this, but this commit is intended to clean up what is necessary to fix the handling of BatchPacket.
This commit is contained in:
@ -25,9 +25,9 @@ namespace pocketmine\inventory;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\network\mcpe\protocol\BatchPacket;
|
||||
use pocketmine\network\mcpe\NetworkCompression;
|
||||
use pocketmine\network\mcpe\PacketStream;
|
||||
use pocketmine\network\mcpe\protocol\CraftingDataPacket;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\timings\Timings;
|
||||
|
||||
class CraftingManager{
|
||||
@ -38,7 +38,7 @@ class CraftingManager{
|
||||
/** @var FurnaceRecipe[] */
|
||||
protected $furnaceRecipes = [];
|
||||
|
||||
/** @var BatchPacket */
|
||||
/** @var string */
|
||||
private $craftingDataCache;
|
||||
|
||||
public function __construct(){
|
||||
@ -102,21 +102,19 @@ class CraftingManager{
|
||||
|
||||
$pk->encode();
|
||||
|
||||
$batch = new BatchPacket();
|
||||
$batch->addPacket($pk);
|
||||
$batch->setCompressionLevel(Server::getInstance()->networkCompressionLevel);
|
||||
$batch->encode();
|
||||
$batch = new PacketStream();
|
||||
$batch->putPacket($pk);
|
||||
|
||||
$this->craftingDataCache = $batch;
|
||||
$this->craftingDataCache = NetworkCompression::compress($batch->buffer);
|
||||
Timings::$craftingDataCacheRebuildTimer->stopTiming();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a pre-compressed CraftingDataPacket for sending to players. Rebuilds the cache if it is not found.
|
||||
*
|
||||
* @return BatchPacket
|
||||
* @return string
|
||||
*/
|
||||
public function getCraftingDataPacket() : BatchPacket{
|
||||
public function getCraftingDataPacket() : string{
|
||||
if($this->craftingDataCache === null){
|
||||
$this->buildCraftingDataCache();
|
||||
}
|
||||
|
Reference in New Issue
Block a user