6
6
package meteordevelopment .meteorclient .mixin ;
7
7
8
8
import com .google .common .base .MoreObjects ;
9
+ import com .llamalad7 .mixinextras .injector .ModifyReturnValue ;
9
10
import meteordevelopment .meteorclient .MeteorClient ;
10
11
import meteordevelopment .meteorclient .events .render .ArmRenderEvent ;
11
12
import meteordevelopment .meteorclient .events .render .HeldItemRendererEvent ;
21
22
import net .minecraft .util .Hand ;
22
23
import org .spongepowered .asm .mixin .Mixin ;
23
24
import org .spongepowered .asm .mixin .Shadow ;
24
- import org .spongepowered .asm .mixin .Unique ;
25
- import org .spongepowered .asm .mixin .injection .*;
25
+ import org .spongepowered .asm .mixin .injection .At ;
26
+ import org .spongepowered .asm .mixin .injection .Inject ;
27
+ import org .spongepowered .asm .mixin .injection .ModifyArg ;
28
+ import org .spongepowered .asm .mixin .injection .ModifyVariable ;
26
29
import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
27
30
28
31
import static meteordevelopment .meteorclient .MeteorClient .mc ;
@@ -41,6 +44,9 @@ public abstract class HeldItemRendererMixin {
41
44
@ Shadow
42
45
private ItemStack offHand ;
43
46
47
+ @ Shadow
48
+ protected abstract boolean shouldSkipHandAnimationOnSwap (ItemStack from , ItemStack to );
49
+
44
50
@ ModifyVariable (method = "renderItem(FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;Lnet/minecraft/client/network/ClientPlayerEntity;I)V" , at = @ At (value = "STORE" , ordinal = 0 ), index = 6 )
45
51
private float modifySwing (float swingProgress ) {
46
52
HandView module = Modules .get ().get (HandView .class );
@@ -58,22 +64,22 @@ private float modifySwing(float swingProgress) {
58
64
return swingProgress ;
59
65
}
60
66
61
- @ Redirect (method = "updateHeldItems " , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/render/item/HeldItemRenderer;shouldSkipHandAnimationOnSwap(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemStack;)Z " ))
62
- private boolean redirectSwapping ( HeldItemRenderer instance , ItemStack from , ItemStack to ) {
63
- return skipSwapAnimation ( from , to );
67
+ @ ModifyReturnValue (method = "shouldSkipHandAnimationOnSwap " , at = @ At ("RETURN " ))
68
+ private boolean modifySkipSwapAnimation ( boolean original ) {
69
+ return original || Modules . get (). get ( HandView . class ). skipSwapping ( );
64
70
}
65
71
66
72
@ ModifyArg (method = "updateHeldItems" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/util/math/MathHelper;clamp(FFF)F" , ordinal = 2 ), index = 0 )
67
73
private float modifyEquipProgressMainhand (float value ) {
68
74
float f = mc .player .getAttackCooldownProgress (1f );
69
75
float modified = Modules .get ().get (HandView .class ).oldAnimations () ? 1 : f * f * f ;
70
76
71
- return (skipSwapAnimation (mainHand , mc .player .getMainHandStack ()) ? modified : 0 ) - equipProgressMainHand ;
77
+ return (shouldSkipHandAnimationOnSwap (mainHand , mc .player .getMainHandStack ()) ? modified : 0 ) - equipProgressMainHand ;
72
78
}
73
79
74
80
@ ModifyArg (method = "updateHeldItems" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/util/math/MathHelper;clamp(FFF)F" , ordinal = 3 ), index = 0 )
75
81
private float modifyEquipProgressOffhand (float value ) {
76
- return (skipSwapAnimation (offHand , mc .player .getOffHandStack ()) ? 1 : 0 ) - equipProgressOffHand ;
82
+ return (shouldSkipHandAnimationOnSwap (offHand , mc .player .getOffHandStack ()) ? 1 : 0 ) - equipProgressOffHand ;
77
83
}
78
84
79
85
@ Inject (method = "renderFirstPersonItem" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemDisplayContext;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V" , shift = At .Shift .BEFORE ))
@@ -90,9 +96,4 @@ private void onRenderArm(AbstractClientPlayerEntity player, float tickDelta, flo
90
96
private void cancelTransformations (MatrixStack matrices , float tickDelta , Arm arm , ItemStack stack , PlayerEntity player , CallbackInfo ci ) {
91
97
if (Modules .get ().get (HandView .class ).disableFoodAnimation ()) ci .cancel ();
92
98
}
93
-
94
- @ Unique
95
- private boolean skipSwapAnimation (ItemStack stack1 , ItemStack stack2 ) {
96
- return !Modules .get ().get (HandView .class ).showSwapping () || ItemStack .areEqual (stack1 , stack2 );
97
- }
98
99
}
0 commit comments