Im trying to make a plugin that increases an item's desired damage value. Here's my code: public function onHitSent(EntityDamageByEntityEvent $event){ $entity = $event->getEntity(); $damager = $event->getDamager(); $item = $damager->getInventory()->getItemInHand(); if($this->getConfig()->get("use-damage") === true){ if($item->getID() == $this->getConfig()->get("item")) { $entity->setHealth($entity->getHealth() - $this->getConfig()->get("damage") ); } } } And every time I hit an entity it either does not give the damage I want or: [08:06:41] [Server thread/CRITICAL]: RuntimeException: "Recursive event call detected (reached max depth of 50 calls)" (EXCEPTION) in "src/pocketmine/event/Event" at line 87
PHP: public function onDamage(EntityDamageEvent $event){$entity = $event->getEntity();if($event instanceof EntityDamageByEntityEvent) {$damager = $event->getDamager();$item = $damager->getInventory()->getItemInHand();if($this->getConfig()->get("use-damage") === true && $item->getId() === $this->getConfig()->get("item")){$entity->setHealth($entity->getHealth() - $this->getConfig()->get("damage"));
If you want to change amount of damage dealt to player PHP: $event->setBaseDamage($this->getConfig()->get("damage")); If you want to change amount of damage to durability of item PHP: $item->applyDamage($this->getConfig()->get("damage"));