Fix crash due to attributes not being removed (tryRemove doesn't try hard enough)

This commit is contained in:
Sollace 2023-10-24 01:02:48 +01:00
parent 5f545745be
commit a1f91a591a
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
4 changed files with 4 additions and 4 deletions

View file

@ -143,7 +143,7 @@ public class BubbleSpell extends AbstractSpell implements TimedSpell,
if (source.asEntity() instanceof LivingEntity l) {
MODIFIERS.forEach((attribute, modifier) -> {
if (l.getAttributes().hasAttribute(attribute)) {
l.getAttributeInstance(attribute).tryRemoveModifier(modifier.getId());
l.getAttributeInstance(attribute).removeModifier(modifier.getId());
}
});
}

View file

@ -366,7 +366,7 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
EntityAttributeModifier modifier = instance.getModifier(id);
if (!MathHelper.approximatelyEquals(desiredValue, modifier == null ? 0 : modifier.getValue())) {
instance.tryRemoveModifier(id);
instance.removeModifier(id);
if (desiredValue != 0) {
if (permanent) {

View file

@ -89,7 +89,7 @@ public class PlayerAttributes implements Tickable {
instance.addPersistentModifier(modifier);
}
} else {
instance.tryRemoveModifier(modifier.getId());
instance.removeModifier(modifier.getId());
}
});
}

View file

@ -44,7 +44,7 @@ public class AttributedEnchantment extends SimpleEnchantment {
modifiers.forEach((attr, modifierSupplier) -> {
EntityAttributeInstance instance = user.asEntity().getAttributeInstance(attr);
instance.tryRemoveModifier(modifierSupplier.get(user, 1).getId());
instance.removeModifier(modifierSupplier.get(user, 1).getId());
});
user.getEnchants().remove(this);
}