Magic Damage Entity Event
timderspieler opened this issue ยท 4 comments
Hello!
I am looking for a "Magic Damage Entity Event" similar to the EntityDamageByEntity event.
I simply couldnt find anything in the MagicAPI what covers my needs.
I need this event to combat tag players once they got hit by any type of magic.
thank you very much!
greetings
Tim
For the most part, you should not need a custom event. The damage will show up via the normal EDbE event with a ThrownPotion source, this can be treated like an other Projectile for resolving the damage source.
So basically I think if you just look for any instanceof Projectile
in your damage event handler it should detect the player casting a spell. I use this helper method in my own code, if that's useful to you:
public static Entity getSource(Entity entity) {
if (entity instanceof Projectile) {
ProjectileSource source = ((Projectile)entity).getShooter();
if (source instanceof Entity) {
entity = (Entity)source;
}
}
return entity;
Let me know if you have any trouble!
Hey NathanWolf,
thank you for that blazing fast support! I will try that out.
I think my problem is that i cast the damager to an Arrow or other Projectile Types.
I will tell you if i get it to work :)
greetings
Hello NathanWolf,
it works like a charm now. My problem was that I checked for the damage cause Projectile instead of Magic. Which totally makes sense since your plugin is called "Magic" :D
Thank you very much. DeluxeCombat does now support Magic! :)
greetings