Fixed not being able to wear armour

This commit is contained in:
Dylan K. Taylor 2017-11-29 19:51:38 +00:00
parent 2cb81b5f8d
commit e94db980d7
3 changed files with 13 additions and 1 deletions

View File

@ -461,4 +461,8 @@ abstract class BaseInventory implements Inventory{
$player->dataPacket($pk);
}
}
public function slotExists(int $slot) : bool{
return $slot >= 0 and $slot < $this->slots->getSize(); //use actual slots size to allow PlayerInventory to lie
}
}

View File

@ -231,4 +231,12 @@ interface Inventory{
* @param bool $send
*/
public function onSlotChange(int $index, Item $before, bool $send) : void;
/**
* Returns whether the specified slot exists in the inventory.
*
* @param int $slot
* @return bool
*/
public function slotExists(int $slot) : bool;
}

View File

@ -77,7 +77,7 @@ class SlotChangeAction extends InventoryAction{
public function isValid(Player $source) : bool{
return (
$this->inventorySlot >= 0 and
$this->inventorySlot < $this->inventory->getSize() and
$this->inventory->slotExists($this->inventorySlot) and
$this->inventory->getItem($this->inventorySlot)->equalsExact($this->sourceItem)
);
}