Keep in mind that the second parameter of setModifier defines the type of modifier. Depending on the situation, you may want to use one from this list.
this is my code PHP: public function onDamage(EntityDamageEvent $event) { $damager = $event->getDamager(); $target = $event->getEntity(); if($damager instanceof Player && $target instanceof Player){ $item = $damager->getInventory()->getItemInHand(); if($item->getId() == 352){ $event->setModifier(6); $target->getLevel()->addParticle(new ExplodeParticle(new Vector3($target->x, $target->y + 2, $target->z))); $target->getLevel()->addParticle(new ExplodeParticle(new Vector3($target->x, $target->y + 2, $target->z)));
Oh, okay. Assuming the item extends Durable, you can use $item->applyDamage(6). If you want to change the meta value, $item->setDamage(6) would work.
0.5 D 0.34 kB/s | TPS 20 | Load 1.5%[36m[15:40:25] [m[31m[Server thread/CRITICAL]: Could not pass event 'pocketmine\event\entity\EntityDamageByEntityEvent' to 'HyparionCore v1': Call to undefined method pocketmine\Player::applyDamage() on HyparionCore\Main[m [36m[15:40:25] [m[31m[Server thread/CRITICAL]: Error: "Call to undefined method pocketmine\Player::applyDamage()" (EXCEPTION) in "HyparionCore/src/HyparionCore/Main" at line 177[m
Take the $item variable you already defined and use PHP: $item->applyDamage(6); Only if the item has durability, like a tool or armor. Otherwise, use PHP: $item->setDamage(6);
PHP: public function onDamage(EntityDamageEvent $event) { $damager = $event->getDamager(); $target = $event->getEntity(); if($damager instanceof Player && $target instanceof Player){ $item = $damager->getInventory()->getItemInHand(); if($item->getId() == 352){ $item->applyDamage(6); $target->getLevel()->addParticle(new ExplodeParticle(new Vector3($target->x, $target->y + 2, $target->z))); $target->getLevel()->addParticle(new ExplodeParticle(new Vector3($target->x, $target->y + 2, $target->z))); this is right ?