mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-14 07:25:31 +00:00
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:
parent
4e91009492
commit
3c6a64f91b
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user