mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 16:24:05 +00:00
Armor: Implement right-click to equip, closes #2641
This commit is contained in:
parent
8b9eeb0b7f
commit
0e1a88f7e5
@ -24,11 +24,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\inventory\ArmorInventory;
|
||||
use pocketmine\item\enchantment\Enchantment;
|
||||
use pocketmine\item\enchantment\ProtectionEnchantment;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\utils\Binary;
|
||||
use pocketmine\utils\Color;
|
||||
use function lcg_value;
|
||||
@ -122,4 +125,13 @@ abstract class Armor extends Durable{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function onActivate(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : ItemUseResult{
|
||||
$existing = $player->getArmorInventory()->getItem($this->getArmorSlot());
|
||||
if(!$existing->isNull()){
|
||||
return ItemUseResult::FAIL();
|
||||
}
|
||||
$player->getArmorInventory()->setItem($this->getArmorSlot(), $this->pop());
|
||||
return ItemUseResult::SUCCESS();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user