How i can remove arrow when it on the ground? I tried PHP: if($event->getEntity()->onGround()){$event->getEntity()->close(); But it doesn't work.
ProjectileHitBlockEvent::getEntity()->flagForDespawn(); Spoiler: Entity->close() NOTICE Avoid calling Entity->close() through plugins unless you understand what you're doing. You may end up with console errors because you're closing the entity before PocketMine has completed ticking the entity. Code: //Calling Entity->close() during an event class Entity { *PocketMine calls an Event* *You call Entity->close() in the event* *PocketMine tries to update entity's position* *"Failed to update entity's position because entity is closed" error spews in console* } //Calling Entity->flagForDespawn() during an event class Entity { *PocketMine calls an Event* *You call Entity->flagForDespawn() in the event* *PocketMine tries to update entity's position* *PocketMine checks if entity is flagged for despawn and despawns the entity* }
PHP: public function removeArrow(ProjectileHitBlockEvent $event){if($this->inReachMoon($event->getEntity()->getOwningEntity())){ if($event->getEntity() instanceof Arrow){ $event->getEntity()->flagForDespawn(); } } } it doesn't work!
What's the inReachMoon function? Alternatively, test @Muqsit's code snippet without any extra checks, so you can be sure that it is his code that doesn't work, rather than your own. Not much help can be given without knowing that everything else can be eliminated as the cause of the problem.