Im using EntityDamageEvent to get the entity damaged, when i do PHP: $entity = $event->getEntity();if($entity instanceof Zombie) var_dump(true);else var_dump(false); and it always says false PHP: bool(false) is there any other way of getting the entity type?
Try this: PHP: public function onDamage(EntityDamageEvent $event){ $entity = $event->getEntity(); $event->setCancelled(true); if ($event instanceof EntityDamageByEntityEvent) { $damager = $event->getDamager(); if ($damager instanceof Player) { if ($entity instanceof Zombie) { $event->setCancelled(true); $damager->sendMessage("Zombie"); } } } }
Have you imported the Zombie class? PHP's instanceof doesnt throw any errors if the class you are comparing the object with doesn't exist. PHP: use pocketmine\entity\Zombie; You can add this to find the entity's class. PHP: var_dump(get_class($entity));
ah... now you say it i realise what i done lol thanks for the help muq! also u never finished explaining the packet thing to me on sylph xD