mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-05 01:16:15 +00:00
Added encode and decode methods for more packets
This commit is contained in:
@ -25,12 +25,14 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\utils\UUID;
|
||||
|
||||
class CraftingEventPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::CRAFTING_EVENT_PACKET;
|
||||
|
||||
public $windowId;
|
||||
public $type;
|
||||
/** @var UUID */
|
||||
public $id;
|
||||
/** @var Item[] */
|
||||
public $input = [];
|
||||
@ -60,7 +62,20 @@ class CraftingEventPacket extends DataPacket{
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putByte($this->windowId);
|
||||
$this->putVarInt($this->type);
|
||||
$this->putUUID($this->id);
|
||||
|
||||
$this->putUnsignedVarInt(count($this->input));
|
||||
foreach($this->input as $item){
|
||||
$this->putSlot($item);
|
||||
}
|
||||
|
||||
$this->putUnsignedVarInt(count($this->output));
|
||||
foreach($this->output as $item){
|
||||
$this->putSlot($item);
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
|
Reference in New Issue
Block a user