Skip to content

Commit 295aea6

Browse files
committed
Add itemstack callbacks to enchantment helper.
1 parent ec71d9f commit 295aea6

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ yarn_mappings=1.20.1+build.10
99
loader_version=0.15.2
1010

1111
# Mod Properties
12-
mod_version=0.5.3
12+
mod_version=0.5.4
1313
maven_group=com.provismet
1414
archives_base_name=combatplus-core
1515

src/main/java/com/provismet/CombatPlusCore/utility/CPCEnchantmentHelper.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,37 +60,79 @@ public static float getAttackDamage (LivingEntity user, LivingEntity target) {
6060
*
6161
* @param user The wielder of the item.
6262
* @param target The entity that was struck.
63+
* @param slot The equipment slot to trigger callbacks for.
6364
*/
6465
public static void postChargedHit (LivingEntity user, LivingEntity target, EquipmentSlot slot) {
6566
CPCEnchantmentHelper.forEachEnchantment((enchantment, level) -> {
6667
if (enchantment instanceof CPCEnchantment cpcEnchant) cpcEnchant.postChargedHit(level, user, target);
6768
}, user, slot);
6869
}
6970

71+
/**
72+
* Calls enchantment callbacks for charged hits.
73+
*
74+
* @param user The wielder of the item.
75+
* @param target The entity that was struck.
76+
* @param itemStack The item stack to trigger callbacks for.
77+
*/
78+
public static void postChargedHit (LivingEntity user, LivingEntity target, ItemStack itemStack) {
79+
CPCEnchantmentHelper.forEachEnchantment((enchantment, level) -> {
80+
if (enchantment instanceof CPCEnchantment cpcEnchant) cpcEnchant.postChargedHit(level, user, target);
81+
}, itemStack);
82+
}
83+
7084
/**
7185
* Calls enchantment callbacks for critical hits.
7286
*
7387
* @param user The wielder of the item.
7488
* @param target The entity that was struck.
89+
* @param slot The equipment slot to trigger callbacks for.
7590
*/
7691
public static void postCriticalHit (LivingEntity user, LivingEntity target, EquipmentSlot slot) {
7792
CPCEnchantmentHelper.forEachEnchantment((enchantment, level) -> {
7893
if (enchantment instanceof CPCEnchantment cpcEnchant) cpcEnchant.postCriticalHit(level, user, target);
7994
}, user, slot);
8095
}
8196

97+
/**
98+
* Calls enchantment callbacks for critical hits.
99+
*
100+
* @param user The wielder of the item.
101+
* @param target The entity that was struck.
102+
* @param itemStack The item stack to trigger callbacks for.
103+
*/
104+
public static void postCriticalHit (LivingEntity user, LivingEntity target, ItemStack itemStack) {
105+
CPCEnchantmentHelper.forEachEnchantment((enchantment, level) -> {
106+
if (enchantment instanceof CPCEnchantment cpcEnchant) cpcEnchant.postCriticalHit(level, user, target);
107+
}, itemStack);
108+
}
109+
82110
/**
83111
* Calls enchantment callbacks for kills.
84112
*
85113
* @param user The wielder of the item.
86114
* @param target The entity that was killed.
115+
* @param slot The equipment slot to trigger callbacks for.
87116
*/
88117
public static void postKill (LivingEntity user, LivingEntity target, EquipmentSlot slot) {
89118
CPCEnchantmentHelper.forEachEnchantment((enchantment, level) -> {
90119
if (enchantment instanceof CPCEnchantment cpcEnchant) cpcEnchant.postKill(level, user, target);
91120
}, user, slot);
92121
}
93122

123+
/**
124+
* Calls enchantment callbacks for kills.
125+
*
126+
* @param user The wielder of the item.
127+
* @param target The entity that was killed.
128+
* @param itemStack The item stack to trigger callbacks for.
129+
*/
130+
public static void postKill (LivingEntity user, LivingEntity target, ItemStack itemStack) {
131+
CPCEnchantmentHelper.forEachEnchantment((enchantment, level) -> {
132+
if (enchantment instanceof CPCEnchantment cpcEnchant) cpcEnchant.postKill(level, user, target);
133+
}, itemStack);
134+
}
135+
94136
/**
95137
* Iterates over all equipment slots on the user, activating a consumer for each enchantment.
96138
*

src/main/resources/fabric.mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"Provismet"
99
],
1010
"contact": {
11-
"homepage": "https://github.com/Provismet/CombatPlus-Core",
11+
"homepage": "https://provismet.github.io/modding?tag=null&series=Combat%2B",
1212
"sources": "https://github.com/Provismet/CombatPlus-Core"
1313
},
1414
"license": "MIT",

0 commit comments

Comments
 (0)