diff --git a/src/pocketmine/inventory/ArmorInventory.php b/src/pocketmine/inventory/ArmorInventory.php index c646b7246..b8aa855ab 100644 --- a/src/pocketmine/inventory/ArmorInventory.php +++ b/src/pocketmine/inventory/ArmorInventory.php @@ -94,11 +94,12 @@ class ArmorInventory extends BaseInventory{ $target = [$target]; } - $armor = $this->getContents(true); - $pk = new MobArmorEquipmentPacket(); $pk->entityRuntimeId = $this->getHolder()->getId(); - $pk->slots = $armor; + $pk->head = $this->getHelmet(); + $pk->chest = $this->getChestplate(); + $pk->legs = $this->getLeggings(); + $pk->feet = $this->getBoots(); $pk->encode(); foreach($target as $player){ @@ -121,18 +122,19 @@ class ArmorInventory extends BaseInventory{ $target = [$target]; } - $armor = $this->getContents(true); - $pk = new MobArmorEquipmentPacket(); $pk->entityRuntimeId = $this->getHolder()->getId(); - $pk->slots = $armor; + $pk->head = $this->getHelmet(); + $pk->chest = $this->getChestplate(); + $pk->legs = $this->getLeggings(); + $pk->feet = $this->getBoots(); $pk->encode(); foreach($target as $player){ if($player === $this->getHolder()){ $pk2 = new InventoryContentPacket(); $pk2->windowId = $player->getWindowId($this); - $pk2->items = $armor; + $pk2->items = $this->getContents(true); $player->dataPacket($pk2); }else{ $player->dataPacket($pk); diff --git a/src/pocketmine/network/mcpe/protocol/MobArmorEquipmentPacket.php b/src/pocketmine/network/mcpe/protocol/MobArmorEquipmentPacket.php index f0e8335ee..af4a25867 100644 --- a/src/pocketmine/network/mcpe/protocol/MobArmorEquipmentPacket.php +++ b/src/pocketmine/network/mcpe/protocol/MobArmorEquipmentPacket.php @@ -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{