mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Fixed implicit dependency on MobArmorEquipmentPacket field ordering
the order of the slots is entirely dependent on Mojang whims, so we shouldn't let our internals rely on it.
This commit is contained in:
@ -34,21 +34,32 @@ class MobArmorEquipmentPacket extends DataPacket{
|
||||
|
||||
/** @var int */
|
||||
public $entityRuntimeId;
|
||||
/** @var Item[] */
|
||||
public $slots = [];
|
||||
|
||||
//this intentionally doesn't use an array because we don't want any implicit dependencies on internal order
|
||||
|
||||
/** @var Item */
|
||||
public $head;
|
||||
/** @var Item */
|
||||
public $chest;
|
||||
/** @var Item */
|
||||
public $legs;
|
||||
/** @var Item */
|
||||
public $feet;
|
||||
|
||||
protected function decodePayload(){
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
for($i = 0; $i < 4; ++$i){
|
||||
$this->slots[$i] = $this->getSlot();
|
||||
}
|
||||
$this->head = $this->getSlot();
|
||||
$this->chest = $this->getSlot();
|
||||
$this->legs = $this->getSlot();
|
||||
$this->feet = $this->getSlot();
|
||||
}
|
||||
|
||||
protected function encodePayload(){
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
for($i = 0; $i < 4; ++$i){
|
||||
$this->putSlot($this->slots[$i]);
|
||||
}
|
||||
$this->putSlot($this->head);
|
||||
$this->putSlot($this->chest);
|
||||
$this->putSlot($this->legs);
|
||||
$this->putSlot($this->feet);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
|
Reference in New Issue
Block a user