Damage events

In bukkit we had entitydamagebyentityevent, entitydamageevent etc, but i cant these events anywhere in sponge ( https://github.com/SpongePowered/SpongeAPI/tree/master/src/main/java/org/spongepowered/api/event/entity/living ). i know Forge has livinghurtevent (or smth like that), but i guess using forge events is not a way how to properly work with sponge.

The API is still a work in progress. That said, the naming of LivingChangeHealthEvent seems to suggest it may be similar to Bukkit’s EntityDamageEvent - don’t quote me on that, though (I may be wrong).

You could create an issue on the SpongeAPI repo on GitHub to suggest damage events if there isn’t one already.

1 Like

There is Entity/Living/PlayerChangeHealthEvent. If event cause is other player - the entity/living/player is damaged by other player.

I do not know how the existing Forge/Bukkit event implementations work, but looking forward I would be cautious about equating damage events and player health change events. I would presume damage could occur, but not necessarily trigger a health change. Not to mention the reverse - an entities health could change for reasons other than damage.

According to javadoc, EntityChangeHealthEvent is called when the health of an entity changes.
And according to javadoc Cause represents the reason or initiator of and event. And there is example with sand.
Cause.getCause() javadoc states that it can return Entity, BlockLoc, etc…
I think it’s obvious that if getCause() returns Player - then the health change is caused by the player (so player dameged other player).
And if health changes for other reason - the cause is different.
//I’m not sure if it’s currently implememnted.

Discussion about events on github (Pull Request)

We can always construct a custom event using that and make a EntityDamagedByEntity event on our projects, shouldn’t be too much of a hassle once we get a good idea of how. However, it would be nice to see the return of that event.