I have an entity. Whenever the entity gets damaged, I want to know if the cause was by an arrow. Am I doing this right?
@Listener
public void onPlayerHit(InteractEntityEvent.Primary event, @First Player player) {
if (event.getCause().any(Arrow.class)) {
Projectile arrow = event.getCause().first(Arrow.class).get(); // This is the arrow that caused the damage
}
}