I'm using pureEntitiesX but how to set health for any mob on EntitySpawnEvent? I have this code but it not working: PHP: public function onEntitySpawn(EntitySpawnEvent $e) { $mobs = $e->getEntity(); if($mobs instanceof \revivalpmmp\pureentities\entity\monster\Monster){ if($mobs->getName() == "Zombie"){ foreach($this->main->getServer()->getOnlinePlayers() as $p) { $name = $mobs->getName(); $level = $this->main->getLevel($p); if($mobs->distance($p) <= 50) { $mobs->setNameTag(TF::GRAY."[".$level."] ".$name); $mobs->setMaxHealth(20+1.5*$level); $mobs->setHealth($mobs->getMaxHealth()); $mobs->setNameTagVisible(true); $mobs->setNameTagAlwaysVisible(true); } } }
PureEntitiesX does not allow you to change the max health of entities simply because the getMaxHealth() function overrides the Entity::getMaxHealth() function and returns the amount of health (eg: return 20) instead of using the entity's attribute map for customizing the max health.
Edit the code of PureEntitiesX. Replace the return value of getMaxHealth() with $this->maxHealth or make a your own plugin where you extend the Monster class of PureEntitiesX, you register the entity and you do what I said above.
It is located in the file of entity itself (like Zombie.php or Pigmen.php) there should be a function called getMaxHealth() (if i remember correctly) just edit the entities that you use its not necessary to edit them all