Fixed armour equipment logic, close #3896

this isn't perfect because the client expects to be the boss here and is also inconsistent.
This commit is contained in:
Dylan K. Taylor 2020-11-09 13:32:12 +00:00
parent 4e91009492
commit 3c6a64f91b

View File

@ -123,10 +123,13 @@ class Armor extends Durable{
public function onClickAir(Player $player, Vector3 $directionVector) : ItemUseResult{
$existing = $player->getArmorInventory()->getItem($this->getArmorSlot());
if(!$existing->isNull()){
return ItemUseResult::FAIL();
}
$player->getArmorInventory()->setItem($this->getArmorSlot(), $this->pop());
if($this->getCount() === 0){
$player->getInventory()->setItemInHand($existing);
}else{ //if the stack size was bigger than 1 (usually won't happen, but might be caused by plugins
$player->getInventory()->setItemInHand($this);
$player->getInventory()->addItem($existing);
}
return ItemUseResult::SUCCESS();
}