Open Phoupraw opened 2 months ago
All entities share one RestorationEffect instance so regenMax covers each other.
RestorationEffect
regenMax
Here is the mixin I use to fix the bug.
AttachmentType<Float> INSTA_HEALTH = AttachmentRegistry.createPersistent(id, Codec.FLOAT);
@Mixin(RestorationEffect.class) abstract class MRestorationEffect extends StatusEffect { protected MRestorationEffect(StatusEffectCategory category, int color) { super(category, color); } @Overwrite @Override public void applyUpdateEffect(LivingEntity entity, int amplifier) { super.applyUpdateEffect(entity, amplifier); float health = entity.getHealth(); float maxHealth = entity.getMaxHealth(); if (health < maxHealth && health < entity.getAttachedOrSet(INSTA_HEALTH, health)) { entity.heal(Math.min(maxHealth - health, 0.1f * (amplifier + 1))); } } @Overwrite @Override public void onRemoved(LivingEntity entity, AttributeContainer attributes, int amplifier) { super.onRemoved(entity, attributes, amplifier); entity.removeAttached(INSTA_HEALTH); } @Overwrite @Override public void onApplied(LivingEntity entity, AttributeContainer attributes, int amplifier) { super.onApplied(entity, attributes, amplifier); entity.setAttached(INSTA_HEALTH, entity.getHealth()); } }
All entities share one
RestorationEffect
instance soregenMax
covers each other.Here is the mixin I use to fix the bug.