Skip to content

Commit 6734137

Browse files
committed
Add grouping system to offhand enchantments.
1 parent 933d243 commit 6734137

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/main/java/com/provismet/CombatPlusCore/enchantments/OffHandEnchantment.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.provismet.CombatPlusCore.enchantments;
22

3+
import org.jetbrains.annotations.Nullable;
4+
35
import com.provismet.CombatPlusCore.interfaces.CPCEnchantment;
46
import com.provismet.CombatPlusCore.utility.CPCEnchantmentHelper;
57
import com.provismet.CombatPlusCore.utility.CPCEnchantmentTargets;
@@ -30,6 +32,24 @@ public boolean canAccept (Enchantment other) {
3032
!(other instanceof SweepingEnchantment) &&
3133
!(other instanceof LuckEnchantment) &&
3234
!CPCEnchantmentHelper.isDamage(other) &&
33-
!CPCEnchantmentHelper.isAdditionalDamage(other);
35+
!CPCEnchantmentHelper.isAdditionalDamage(other) &&
36+
!(other instanceof OffHandEnchantment otherOffhand &&
37+
otherOffhand.getGroup() != null &&
38+
this.getGroup() != null &&
39+
otherOffhand.getGroup() != this.getGroup()
40+
);
3441
}
42+
43+
/**
44+
* Returns the group name of this enchantment. Offhand enchantments that have a group cannot
45+
* be mixed with offhand enchantments that belong to a different group.
46+
*
47+
* <p> This system exists because offhand enchantments may be designed to interact with each other (see the Dual Swords mod).
48+
* The Offhand Enchantment class is intentionally miscellaneous by nature, so this library will offer a rudimentary grouping
49+
* system instead of direct subclasses.
50+
*
51+
* @return A unique string denoting the group name of this enchantment, or null.
52+
*/
53+
@Nullable
54+
protected abstract String getGroup ();
3555
}

0 commit comments

Comments
 (0)