Hi. It is possible to give of an item that has changed the name but his real name is not affected? for instance a player has a diamond blade that is not renamed and a second diamond sword that has changed the name . I need to use this by using code instead of / give
Ok thanks for help. I have one question: It is possible and how to stop damage of item when player attack e.q zombie.
You can rewrite the item name Renamed, Enchanted Item (with API) And you can stop or change the damage
I agree with @korado531m7, try this: PHP: public function onEntityDamageEvent(EntityDamageEvent $event){ if($event instanceof EntityDamageByEntityEvent){ $customName = "YourCustomName"; if($event->getDamager()->getItemInHand()->getCustomName() == $customName){ $event->setCancelled(); } }} I'm not sure if this will work, but it's worth a try
If you are using my naming API plugin, you can use this (not tested) API : http://forums.pocketmine.net/threads/renamed-enchanted-item-with-api.16682/ PHP: //if you add item that name is "test sword" (Diamond Sword)function onEntityDamageEvent(EntityDamageEvent $ev){ if($ev instanceof EntityDamageByEntityEvent){ $damager = $ev->getDamager(); if($damager instanceof Player){ if($damager->getInventory()->getItemInHand()->getName() == "test sword"){ $ev->setCancelled(true); } } }}