From 3c6a64f91b8e5c8d8c727fc57953c39365532128 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 9 Nov 2020 13:32:12 +0000 Subject: [PATCH] Fixed armour equipment logic, close #3896 this isn't perfect because the client expects to be the boss here and is also inconsistent. --- src/item/Armor.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/item/Armor.php b/src/item/Armor.php index 804763e656..2838982722 100644 --- a/src/item/Armor.php +++ b/src/item/Armor.php @@ -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(); }