How can i damage an entity with specific damage cause? Like for example i want to damage an entity specifically with damage cause DamageCause.FIRE, or LIGHTNING , or any other type, so the next DamageEntityByEntityEvent, which is fired during method call Entity#damage is going to have set its damage cause to the one i specified earlier.
the best you can do (via API calls) is specifying an entity as the attacker/cause for the damage: https://papermc.io/javadocs/paper/1.14/org/bukkit/entity/Damageable.html
As @jaylawl said, you can indeed call the overloaded method and provide an Entity of your choice. The following would damage your Damageable with a LightiningStrike. Your DamageEntityByEntityEvent would then be fired with cause LIGHTNING. Code (Java): LightningStrike strike = world.spawnEntity(location, EntityType.LIGHTNING); damageable.damage(amount, strike);
I actually deceided to create a pr https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/pull-requests/469/overview If accepted you will be able to call damage(double, damagecause) damage(double. entity, damagecause) and then ofcourse damage events fired from these call will return appropriate damage cause as well
Why not just setting the last damage cause (and call the corresponding event)? You can easily construct an EntityDamageEvent and set it with Entity#setLastDamageCause