Inventory: Split up armor and player inventory (#1957)

* Inventory: Split up PlayerInventory and armour handling
* Fixed other players don't see armour changes. This bug also exists on master.
This commit is contained in:
Dylan K. Taylor
2018-01-23 20:01:26 +00:00
committed by GitHub
parent 0bf5ab76fb
commit 6543d96910
8 changed files with 198 additions and 235 deletions

View File

@ -426,11 +426,7 @@ abstract class BaseInventory implements Inventory{
}
$pk = new InventoryContentPacket();
//Using getSize() here allows PlayerInventory to report that it's 4 slots smaller than it actually is (armor hack)
for($i = 0, $size = $this->getSize(); $i < $size; ++$i){
$pk->items[$i] = $this->getItem($i);
}
$pk->items = $this->getContents(true);
foreach($target as $player){
if(($id = $player->getWindowId($this)) === ContainerIds::NONE){
@ -466,6 +462,6 @@ abstract class BaseInventory implements Inventory{
}
public function slotExists(int $slot) : bool{
return $slot >= 0 and $slot < $this->slots->getSize(); //use actual slots size to allow PlayerInventory to lie
return $slot >= 0 and $slot < $this->slots->getSize();
}
}