Skip to content

Commit d20701e

Browse files
committed
Enchantment logic improvments
1 parent fa8caed commit d20701e

4 files changed

Lines changed: 13 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 1.4.6
2+
3+
- Enchantment that require matching attributes can now be configured to disable this requirement
4+
- Fix unsafe check in enchantment logic
5+
- Update translations
6+
17
# 1.4.5
28

39
- Update translations

common/src/main/java/net/spell_power/SpellPowerMod.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,15 @@ public static void registerAttributes() {
5656
}
5757

5858
EnchantmentEvents.ALLOW_ENCHANTING.register((enchantment, target, enchantingContext) -> {
59-
if (enchantment.isIn(SpellPowerTags.Enchantments.REQUIRES_MATCHING_ATTRIBUTE)) {
59+
if (SpellPowerMod.attributesConfig.value.enchantments_require_matching_attribute &&
60+
enchantment.isIn(SpellPowerTags.Enchantments.REQUIRES_MATCHING_ATTRIBUTE)) {
6061
// System.out.println("Spell Power - School Filtering check: " + enchantment);
6162
var enchantmentAttributes = enchantment.value().effects().get(EnchantmentEffectComponentTypes.ATTRIBUTES);
6263
if (enchantmentAttributes != null && !enchantmentAttributes.isEmpty()) {
6364
var itemAttributes = target.getComponents().get(DataComponentTypes.ATTRIBUTE_MODIFIERS);
65+
if (itemAttributes == null) {
66+
return TriState.FALSE;
67+
}
6468
if (itemAttributes.modifiers().isEmpty()) {
6569
itemAttributes = target.getItem().getAttributeModifiers();
6670
}

common/src/main/java/net/spell_power/config/AttributesConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public enum AttributeScope {
1515
public double base_spell_critical_damage_percentage = 50;
1616
public EffectConfig spell_power_effect = new EffectConfig(0.1F);
1717
public Map<String, EffectConfig> secondary_effects;
18-
18+
public boolean enchantments_require_matching_attribute = true;
1919

2020
public DamageCurve resistance_curve = DamageCurve.HYPERBOLIC;
2121
public float resistance_multiplier = 1F;

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ neoforge_version = 21.1.201
1515
# Mod
1616
maven_group=net.spell_power
1717
archives_name=spell_power
18-
mod_version=1.4.5
18+
mod_version=1.4.6
1919
minecraft_compat_version=1.21
2020

2121
# Dependencies

0 commit comments

Comments
 (0)