Merge branch 'stable'

# Conflicts:
#	resources/vanilla
#	src/pocketmine/inventory/ArmorInventory.php
This commit is contained in:
Dylan K. Taylor 2019-06-04 18:19:47 +01:00
commit cda565ba8c
2 changed files with 24 additions and 9 deletions

View File

@ -841,7 +841,11 @@ class NetworkSession{
public function onMobArmorChange(Living $mob) : void{ public function onMobArmorChange(Living $mob) : void{
$pk = new MobArmorEquipmentPacket(); $pk = new MobArmorEquipmentPacket();
$pk->entityRuntimeId = $mob->getId(); $pk->entityRuntimeId = $mob->getId();
$pk->slots = $mob->getArmorInventory()->getContents(true); //beware this order might change in the future $inv = $mob->getArmorInventory();
$pk->head = $inv->getHelmet();
$pk->chest = $inv->getChestplate();
$pk->legs = $inv->getLeggings();
$pk->feet = $inv->getBoots();
$this->sendDataPacket($pk); $this->sendDataPacket($pk);
} }

View File

@ -34,21 +34,32 @@ class MobArmorEquipmentPacket extends DataPacket implements ClientboundPacket, S
/** @var int */ /** @var int */
public $entityRuntimeId; 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() : void{ protected function decodePayload() : void{
$this->entityRuntimeId = $this->getEntityRuntimeId(); $this->entityRuntimeId = $this->getEntityRuntimeId();
for($i = 0; $i < 4; ++$i){ $this->head = $this->getSlot();
$this->slots[$i] = $this->getSlot(); $this->chest = $this->getSlot();
} $this->legs = $this->getSlot();
$this->feet = $this->getSlot();
} }
protected function encodePayload() : void{ protected function encodePayload() : void{
$this->putEntityRuntimeId($this->entityRuntimeId); $this->putEntityRuntimeId($this->entityRuntimeId);
for($i = 0; $i < 4; ++$i){ $this->putSlot($this->head);
$this->putSlot($this->slots[$i]); $this->putSlot($this->chest);
} $this->putSlot($this->legs);
$this->putSlot($this->feet);
} }
public function handle(SessionHandler $handler) : bool{ public function handle(SessionHandler $handler) : bool{