So i want to change the durability of an item and an armor but it dont work can you help me ? I try to recode the armor public function getDefensePoints() : int { return 3; } public function getMaxDurability() : int { return 1300; } this dont work and for the item public function __construct($meta = 0, $count = 1){ parent::__construct(285, 0, "Gold Pickaxe"); } public function getMaxDurability(): int { return 1000; } public function getMaxStackSize(): int{ return 1; } public function onDestroyBlock(Block $block): bool { var_dump($this->getDamage()); $this->applyDamage(mt_rand(1,2)); return true; } This work but the durability bar is bug so have you got any solution to up the durability ? Thanks for help me
PHP: public function onBreak(BlockBreakEvent $event) : void{$item = $event->getPlayer()->getInventory()->getItemInHand();$event->getPlayer()->getInventory()->setItemInHand($item->setDamage(rand(1,2)));}
PHP: public function onDamage(EntityDamageEvent $event) : void{$player = $event->getEntity();if(!$player instanceof Player){return;}$player->getArmorInventory()->setHelmet($player->getArmorInventory()->getHelmet()->setDamage($player->getArmorInventory()->getHelmet()->getDamage()++));$player->getArmorInventory()->setChestplate($player->getArmorInventory()->getChestplate()->setDamage($player->getArmorInventory()->getChestplate()->getDamage()++));$player->getArmorInventory()->setLeggings($player->getArmorInventory()->getLeggings()->setDamage($player->getArmorInventory()->getLeggings()->getDamage()++));$player->getArmorInventory()->setBoots($player->getArmorInventory()->getBoots()->setDamage($player->getArmorInventory()->getBoots()->getDamage()++));}