Cancel any entity healing excluding healing by my plugin?

How can I cancel any healing to player (excluding healing by my plugin)?
I founded EntityHealthEvent, but its not got fired…
Is there other ways to cancel healing?
And how to check, is some event implemented?

HealEntityEvent should be the one you’re looking for.

You can check the list of HealthModifiers your custom one - if not, cancel the event. You could also cancel all modifiers but yours if you wanted to go that far.

As for events being implemented, there’s no simple way to check. But if you search the SpongeCommon github repo for the event you want, if it’s implemented then there should be a bunch of code to call it. It may also be implemented in the forge/vanilla side, so check that if you still can’t see it.

For example:

And a forge implementation (which just mirrors the Forge event):

Oh yes, i was meaning HealEntityEvent (not EntityHealtEvent :smiley:), but its not got fired, maybe not implemented yet? :frowning:

[code] @Listener(order = Order.FIRST) //fired
public void setDamage(DamageEntityEvent event) {
System.out.println("DAMAGE EVENT DETECTED!! CAUSE = " + event.getCause().first(DamageSource.class).get().toString());
Entity entity = event.getTargetEntity();
if (!(entity instanceof Living)) return;
Living living = (Living) entity;
Optional optional_damage_source = event.getCause().first(EntityDamageSource.class);
if (!optional_damage_source.isPresent()) return;
EntityDamageSource damage_source = optional_damage_source.get();
Entity source_entity = damage_source.getSource();
if (!(source_entity instanceof Living)) return;
Living living_source = (Living) source_entity;
System.out.println("entity = " + living.getUniqueId() + ", hp = " + living.getHealthData().health().get());
System.out.println("source = " + living_source.getUniqueId() + ", hp = " + living_source.getHealthData().health().get());
System.out.println(“damage set to 5!”);

@Listener(order = Order.FIRST) //not fired
public void cancelHealth(HealEntityEvent event) {
    System.out.println("HEALTH EVENT DETECTED!! CAUSE = " + event.getCause().first(HealingSource.class).get().toString());


What version of Sponge are you using?

Latest (maybe) spongevanilla-1.11-6.0.0-BETA-170.

Is this event still not implemented?
After ~3 month, it still not working…
Using “spongevanilla-1.11.2-6.0.0-BETA-221”…

Unfortunately, yes - but I can work on getting it implemented.

1 Like

It would be great! Thank you :slight_smile:

After 3 more months it still not working…
Sad, very sad…
Can someone finally do it?
Pleeease :frowning:

1 Like