Hi guys I post this thread for anyone can can help me to add custom damage to an item in the src src of pmmp ?
use EntityDamageEvent PHP: public function onDamage(\pocketmine\event\entity\EntityDamageEvent $event) { /** @var float $customDamage */ $customDamage = 2.6; $entity = $event->getEntity(); if($entity instanceof \pocketmine\Player && $event instanceof \pocketmine\event\entity\EntityDamageByEntityEvent) { $damager = $event->getDamager(); if($damager instanceof \pocketmine\Player) { if($damager->getInventory()->getItemInHand()->getId() == \pocketmine\item\Item::BONE) { $event->setDamage($customDamage); } } } }
This is getting confusing. Are you referring to the item durability (a.k.a. damage), or are you referring to the damage dealt when an entity attacks with the item?