Hi, i tryed to remove cactus damage but that's not working, i don't know why: PHP: public function onDamage(EntityDamageEvent $e) { $level = $e->getEntity()->getLevel()->getFolderName(); $entity = $e->getEntity(); $cause[0] = $e->getCause(); $cause[1] = $entity->getLastDamageCause(); $cause[2] = $entity->getLastDamageCause()->getCause(); if ($entity instanceof Player) { switch ($level) { case 'world': #General damage event switch ($cause[0]) { case array_key_exists($cause, $this->causes): $e->setCancelled(); break; } #Specified block contact switch ($cause[2]) { case EntityDamageEvent::CAUSE_CONTACT: if ($cause[1] instanceof EntityDamageByBlockEvent) { $cause[3] = $cause[1]->getDamager(); switch ($cause[3]->getId()) { case Block::CACTUS: $e->setCancelled(); break; case Block::TNT: $e->setCancelled(); break; } } } } } } My array is: PHP: public $causes = array(EntityDamageEvent::CAUSE_CONTACT, EntityDamageEvent::CAUSE_ENTITY_ATTACK, EntityDamageEvent::CAUSE_PROJECTILE);
Why you use array_key_exists when $this->causes does not contains any keys? PHP: public function onDamage(EntityDamageEvent $e) { $level = $e->getEntity()->getLevel()->getFolderName(); $entity = $e->getEntity(); if ($entity instanceof Player) { switch ($level) { case 'world': if(in_array($e->getCause(), $this->causes)){ $e->setCancelled(); } } } }