55
66package meteordevelopment .meteorclient .mixin ;
77
8- import com .google . common . base . MoreObjects ;
8+ import com .llamalad7 . mixinextras . injector . ModifyExpressionValue ;
99import com .llamalad7 .mixinextras .injector .ModifyReturnValue ;
1010import meteordevelopment .meteorclient .MeteorClient ;
1111import meteordevelopment .meteorclient .events .render .ArmRenderEvent ;
1818import net .minecraft .client .util .math .MatrixStack ;
1919import net .minecraft .entity .player .PlayerEntity ;
2020import net .minecraft .item .ItemStack ;
21+ import net .minecraft .registry .tag .ItemTags ;
2122import net .minecraft .util .Arm ;
2223import net .minecraft .util .Hand ;
2324import org .spongepowered .asm .mixin .Mixin ;
2425import org .spongepowered .asm .mixin .Shadow ;
2526import org .spongepowered .asm .mixin .injection .At ;
2627import org .spongepowered .asm .mixin .injection .Inject ;
2728import org .spongepowered .asm .mixin .injection .ModifyArg ;
28- import org .spongepowered .asm .mixin .injection .ModifyVariable ;
2929import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
3030
31+ import java .util .Objects ;
32+
3133import static meteordevelopment .meteorclient .MeteorClient .mc ;
3234
3335@ Mixin (HeldItemRenderer .class )
@@ -47,16 +49,19 @@ public abstract class HeldItemRendererMixin {
4749 @ Shadow
4850 protected abstract boolean shouldSkipHandAnimationOnSwap (ItemStack from , ItemStack to );
4951
50- @ ModifyVariable (method = "renderItem(FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/command/OrderedRenderCommandQueue;Lnet/minecraft/client/network/ClientPlayerEntity;I)V" , at = @ At (value = "STORE " , ordinal = 0 ), index = 6 )
52+ @ ModifyExpressionValue (method = "renderItem(FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/command/OrderedRenderCommandQueue;Lnet/minecraft/client/network/ClientPlayerEntity;I)V" , at = @ At (value = "INVOKE " , target = "Lnet/minecraft/client/network/ClientPlayerEntity;getHandSwingProgress(F)F" ) )
5153 private float modifySwing (float swingProgress ) {
5254 HandView module = Modules .get ().get (HandView .class );
53- Hand hand = MoreObjects . firstNonNull (mc .player .preferredHand , Hand .MAIN_HAND );
55+ Hand hand = Objects . requireNonNullElse (mc .player .preferredHand , Hand .MAIN_HAND );
5456
5557 if (module .isActive ()) {
56- if (hand == Hand .OFF_HAND && !mc .player .getOffHandStack ().isEmpty ()) {
58+ if (module .swordSlash () && hand == Hand .MAIN_HAND && mainHand .isIn (ItemTags .SWORDS )) {
59+ return 0f ;
60+ }
61+ if (hand == Hand .OFF_HAND && !offHand .isEmpty ()) {
5762 return swingProgress + module .offSwing .get ().floatValue ();
5863 }
59- if (hand == Hand .MAIN_HAND && !mc . player . getMainHandStack () .isEmpty ()) {
64+ if (hand == Hand .MAIN_HAND && !mainHand .isEmpty ()) {
6065 return swingProgress + module .mainSwing .get ().floatValue ();
6166 }
6267 }
@@ -71,8 +76,11 @@ private boolean modifySkipSwapAnimation(boolean original) {
7176
7277 @ ModifyArg (method = "updateHeldItems" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/util/math/MathHelper;clamp(FFF)F" , ordinal = 2 ), index = 0 )
7378 private float modifyEquipProgressMainhand (float value ) {
79+ HandView handView = Modules .get ().get (HandView .class );
80+ if (handView .swordSlash () && mc .player .getMainHandStack ().isIn (ItemTags .SWORDS )) return value ;
81+
7482 float f = mc .player .getHandEquippingProgress (1f );
75- float modified = Modules . get (). get ( HandView . class ) .oldAnimations () ? 1 : f * f * f ;
83+ float modified = handView .oldAnimations () ? 1 : f * f * f ;
7684
7785 return (shouldSkipHandAnimationOnSwap (mainHand , mc .player .getMainHandStack ()) ? modified : 0 ) - equipProgressMainHand ;
7886 }
0 commit comments