KubeJS

KubeJS

61M Downloads

Cancelable entity.heal event, similar to entity.hurt

floral-qua-floral opened this issue ยท 2 comments

commented

Describe the feature

It would be really nice to have another event similar to entity.hurt for when a living entity recovers health. Ideally it would be cancelable and have an amount field. An additional field or fields to describe the context of what is healing the entity (i.e. regeneration effect, instant health/damage effect, natural regen, other) might be handy for some use cases, but could be left out if it'd be too much work (since as far as I know minecraft doesn't have a "healing sources" system the way it has damage sources?)

Additional info

An example use case could be a simple script like this to reduce all sources of healing for all entities by 50%:

const HEAL_FACTOR = 0.5;
let interceptHealing = true;
onEvent("entity.heal", function(event) {
	if(interceptHealing) {
		interceptHealing = false;
		event.entity.heal(event.amount * HEAL_FACTOR);
		interceptHealing = true;
		event.cancel();
	}
});
commented

There is a Forge heal event that could help here, I am not sure if it is wrapped by architecturey though
net.minecraftforge.event.entity.living.LivingHealEvent

commented

I'm not sure Fabric has an equivalent event, though if it doesn't it should be easy enough to realise with a mixin(?)

Can someone make an issue on the Architectury API tracker so I don't lose track of this?