mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 16:49:53 +00:00
80 lines
2.3 KiB
PHP
80 lines
2.3 KiB
PHP
<?php
|
|
|
|
/*
|
|
*
|
|
* ____ _ _ __ __ _ __ __ ____
|
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* @author PocketMine Team
|
|
* @link http://www.pocketmine.net/
|
|
*
|
|
*
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace pocketmine\network\mcpe\protocol;
|
|
|
|
#include <rules/DataPacket.h>
|
|
|
|
use pocketmine\network\mcpe\handler\PacketHandler;
|
|
use pocketmine\network\mcpe\protocol\types\inventory\ItemStack;
|
|
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
|
|
|
class MobArmorEquipmentPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
|
|
public const NETWORK_ID = ProtocolInfo::MOB_ARMOR_EQUIPMENT_PACKET;
|
|
|
|
/** @var int */
|
|
public $entityRuntimeId;
|
|
|
|
//this intentionally doesn't use an array because we don't want any implicit dependencies on internal order
|
|
|
|
/** @var ItemStack */
|
|
public $head;
|
|
/** @var ItemStack */
|
|
public $chest;
|
|
/** @var ItemStack */
|
|
public $legs;
|
|
/** @var ItemStack */
|
|
public $feet;
|
|
|
|
public static function create(int $entityRuntimeId, ItemStack $head, ItemStack $chest, ItemStack $legs, ItemStack $feet) : self{
|
|
$result = new self;
|
|
$result->entityRuntimeId = $entityRuntimeId;
|
|
$result->head = $head;
|
|
$result->chest = $chest;
|
|
$result->legs = $legs;
|
|
$result->feet = $feet;
|
|
|
|
return $result;
|
|
}
|
|
|
|
protected function decodePayload(NetworkBinaryStream $in) : void{
|
|
$this->entityRuntimeId = $in->getEntityRuntimeId();
|
|
$this->head = $in->getSlot();
|
|
$this->chest = $in->getSlot();
|
|
$this->legs = $in->getSlot();
|
|
$this->feet = $in->getSlot();
|
|
}
|
|
|
|
protected function encodePayload(NetworkBinaryStream $out) : void{
|
|
$out->putEntityRuntimeId($this->entityRuntimeId);
|
|
$out->putSlot($this->head);
|
|
$out->putSlot($this->chest);
|
|
$out->putSlot($this->legs);
|
|
$out->putSlot($this->feet);
|
|
}
|
|
|
|
public function handle(PacketHandler $handler) : bool{
|
|
return $handler->handleMobArmorEquipment($this);
|
|
}
|
|
}
|