3
3
import org .spongepowered .asm .mixin .Mixin ;
4
4
import org .spongepowered .asm .mixin .injection .At ;
5
5
import org .spongepowered .asm .mixin .injection .Inject ;
6
+ import org .spongepowered .asm .mixin .injection .Redirect ;
6
7
import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
7
8
8
- import com .provismet .CombatPlusCore .mixin . interfaces .IMixinItemStack ;
9
+ import com .provismet .CombatPlusCore .interfaces . mixin .IMixinItemStack ;
9
10
import com .provismet .CombatPlusCore .utility .CPCEnchantmentHelper ;
10
11
12
+ import net .minecraft .enchantment .EnchantmentHelper ;
11
13
import net .minecraft .entity .Entity ;
14
+ import net .minecraft .entity .EntityGroup ;
12
15
import net .minecraft .entity .EntityType ;
13
16
import net .minecraft .entity .LivingEntity ;
14
17
import net .minecraft .entity .player .PlayerEntity ;
18
+ import net .minecraft .item .ItemStack ;
15
19
import net .minecraft .world .World ;
16
20
17
21
@ Mixin (PlayerEntity .class )
@@ -20,7 +24,7 @@ protected PlayerEntityMixin (EntityType<? extends LivingEntity> entityType, Worl
20
24
super (entityType , world );
21
25
}
22
26
23
- @ Inject (method ="attack" , at =@ At (value ="INVOKE" , target ="Lnet/minecraft/entity/player/PlayerEntity;addCritParticles(Lnet/minecraft/entity/Entity;)V" , shift = At .Shift .AFTER ))
27
+ @ Inject (method ="attack" , at =@ At (value ="INVOKE" , target ="Lnet/minecraft/entity/player/PlayerEntity;addCritParticles(Lnet/minecraft/entity/Entity;)V" , shift = At .Shift .AFTER ))
24
28
public void onCriticalHit (Entity entity , CallbackInfo info ) {
25
29
if (entity instanceof LivingEntity target ) {
26
30
((IMixinItemStack )(Object )this .getMainHandStack ()).CPC_postCriticalHit (this , target );
@@ -35,4 +39,12 @@ public void postChargedHit (Entity entity, CallbackInfo info) {
35
39
CPCEnchantmentHelper .postChargedHit (this , target );
36
40
}
37
41
}
42
+
43
+ @ Redirect (method ="attack" , at =@ At (value ="INVOKE" , target ="Lnet/minecraft/enchantment/EnchantmentHelper;getAttackDamage(Lnet/minecraft/item/ItemStack;Lnet/minecraft/entity/EntityGroup;)F" ))
44
+ public float redirectVanillaEnchantments (ItemStack itemStack , EntityGroup entityGroup , Entity target ) {
45
+ if (target instanceof LivingEntity living ) {
46
+ return CPCEnchantmentHelper .getAttackDamage (this , living );
47
+ }
48
+ return EnchantmentHelper .getAttackDamage (itemStack , entityGroup );
49
+ }
38
50
}
0 commit comments