From a1f91a591a8bcf7917b81da7f507c8551ba3e9ae Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 24 Oct 2023 01:02:48 +0100 Subject: [PATCH] Fix crash due to attributes not being removed (tryRemove doesn't try hard enough) --- .../unicopia/ability/magic/spell/effect/BubbleSpell.java | 2 +- src/main/java/com/minelittlepony/unicopia/entity/Living.java | 2 +- .../minelittlepony/unicopia/entity/player/PlayerAttributes.java | 2 +- .../unicopia/item/enchantment/AttributedEnchantment.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/BubbleSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/BubbleSpell.java index 0834a67b..c2b837b0 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/BubbleSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/BubbleSpell.java @@ -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()); } }); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/Living.java b/src/main/java/com/minelittlepony/unicopia/entity/Living.java index d8cb87b9..7fcc1011 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/Living.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/Living.java @@ -366,7 +366,7 @@ public abstract class Living implements Equine, 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) { diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerAttributes.java b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerAttributes.java index 1b396f98..0a3d1da3 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerAttributes.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerAttributes.java @@ -89,7 +89,7 @@ public class PlayerAttributes implements Tickable { instance.addPersistentModifier(modifier); } } else { - instance.tryRemoveModifier(modifier.getId()); + instance.removeModifier(modifier.getId()); } }); } diff --git a/src/main/java/com/minelittlepony/unicopia/item/enchantment/AttributedEnchantment.java b/src/main/java/com/minelittlepony/unicopia/item/enchantment/AttributedEnchantment.java index 4436222a..4738165d 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/enchantment/AttributedEnchantment.java +++ b/src/main/java/com/minelittlepony/unicopia/item/enchantment/AttributedEnchantment.java @@ -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); }