What im trying to do is when i put on the iron chestplate, people that is in 3 by 3 area with u get the poison effect. Im not sure how to calculate the 3 by 3 area. I only now how to give person that hit u the effect. Thanksssss
I suggest using circular area instead of square. If you have two vector object, then you can use the method "distance" PHP: $r = 3 / 2;if($v1->distance($v2) <= $r) { }
Thank for reaching out to help but can you please provide more detail since I'm new to the area stuff
you can use the event called EntityArmorChangeEvent to check if the player has equipped an iron chestplate, and use PHP: /* @var $this PluginBase */$this->getServer()->getOnlinePlayers(); to get all the instances of all players, then you can do what primus has given you, checking the distance Example: PHP: public function onEntityArmorChange(EntityArmorChangeEvent $ev): void{ $player = $ev->getPlayer(); $onlinePlayers = $this->getServer()->getOnlinePlayers(); unset($onlinePlayers[array_search($player, $onlinePlayers)]); foreach($onlinePlayers as $players){ if($player->distance($players) <= 3 / 2){ //poison effect } }}
He's not interested in the plugin, he's asking for a code, and probably it's for custom enchants, so It has nothing to do with what he's asking rn
This isn't critical, and may be entirely useless to OP, but a slight optimization may be to only pull players in the same Level as the player, just to reduce the number of comparisons needed in some conditions.