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:
Dylan K. Taylor
2019-06-04 18:16:56 +01:00
parent 341c480e13
commit 80f8a27094
2 changed files with 28 additions and 15 deletions

View File

@ -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);