Skip to content

Commit 0d4fdc0

Browse files
authored
Merge pull request #4 from Norus6/master
Fix: Prevent duplicate attribute modifiers (thank you norus6)
2 parents 98b2020 + c4ced14 commit 0d4fdc0

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/main/java/dev/shadowsoffire/placebo/json/RandomAttributeModifier.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ public void apply(RandomSource rand, LivingEntity entity) {
5656
EntityType.getKey(entity.getType()), BuiltInRegistries.ATTRIBUTE.getKey(this.attribute)));
5757
return;
5858
}
59-
inst.addPermanentModifier(modif);
59+
// Check if the modifier already exists before adding it
60+
if (inst.getModifier(modif.getId()) == null) {
61+
inst.addPermanentModifier(modif);
62+
} else {
63+
Placebo.LOGGER.warn(String.format("Duplicate attribute modifier detected! Entity: %s, Attribute: %s, Modifier: %s",
64+
EntityType.getKey(entity.getType()), BuiltInRegistries.ATTRIBUTE.getKey(this.attribute), modif.getId()));
65+
}
6066
}
6167

6268
public AttributeModifier create(RandomSource rand) {

0 commit comments

Comments
 (0)