from your question, you ask 'how to make creative mode can't hit player?' My Answer Is By Using A Plugin. If You Already Know How To Make Plugin This Code Should Help Note: Just // a pseudo-code PHP: public function noHit(EntityDamageEvent $event){ $entity = $event->getEntity(); $cause = $this->getDamager(); if($entity instanceof Player){ if($cause instanceof Player){ if($cause->getGamemode(1)){ $event->setCancelled(true); } } } }
WTF No.... https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/event/entity/EntityDamageEvent.php Check here.. why '$this->getDamager()' undefined function getDamager() on null .. try learn new api ... It's '$event->getDamager() ' after the condition if($event instanceof EntityDamageByEntityEvent) if($damager->getDamager() == 1){ instead to if($damager->getGamemode(1)){ ?? No because getGamemode() is a function who return so which gamemode is the player in the form of an int.
PHP: public function onAttack(EntityDamageEvent $event){if ($event instanceof EntityDamageByEntityEvent) { $player = $event->getDamager(); if ($player instanceof Player) { if ($player->getGamemode() == 1){ $event->setCancelled(true);}}}} Try this maybe work