2121import com .lambda .event .EventFlow ;
2222import com .lambda .event .events .MovementEvent ;
2323import com .lambda .interaction .request .rotation .RotationManager ;
24+ import com .lambda .module .modules .render .ViewModel ;
2425import net .minecraft .entity .LivingEntity ;
2526import net .minecraft .util .math .MathHelper ;
2627import net .minecraft .util .math .Vec3d ;
2728import org .spongepowered .asm .mixin .Mixin ;
2829import org .spongepowered .asm .mixin .Shadow ;
29- import org .spongepowered .asm .mixin .injection .At ;
30- import org .spongepowered .asm .mixin .injection .Inject ;
31- import org .spongepowered .asm .mixin .injection .Redirect ;
32- import org .spongepowered .asm .mixin .injection .Slice ;
30+ import org .spongepowered .asm .mixin .Unique ;
31+ import org .spongepowered .asm .mixin .injection .*;
3332import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
3433
3534@ Mixin (LivingEntity .class )
@@ -38,6 +37,9 @@ public abstract class LivingEntityMixin extends EntityMixin {
3837 @ Shadow
3938 protected abstract float getJumpVelocity ();
4039
40+ @ Unique
41+ private final LivingEntity lambda$instance = (LivingEntity ) (Object ) this ;
42+
4143 /**
4244 * Overwrites the jump function to use our rotation and movements
4345 * <pre>{@code
@@ -55,7 +57,7 @@ public abstract class LivingEntityMixin extends EntityMixin {
5557 */
5658 @ Inject (method = "jump" , at = @ At ("HEAD" ), cancellable = true )
5759 void onJump (CallbackInfo ci ) {
58- LivingEntity self = ( LivingEntity ) ( Object ) this ;
60+ LivingEntity self = lambda$instance ;
5961 if (self != Lambda .getMc ().player ) return ;
6062 ci .cancel ();
6163
@@ -78,15 +80,14 @@ void onJump(CallbackInfo ci) {
7880
7981 @ Inject (method = "travel" , at = @ At ("HEAD" ), cancellable = true )
8082 void onTravelPre (Vec3d movementInput , CallbackInfo ci ) {
81- LivingEntity entity = (LivingEntity ) (Object ) this ;
82- if (EventFlow .post (new MovementEvent .Entity .Pre (entity , movementInput )).isCanceled ()) {
83+ if (EventFlow .post (new MovementEvent .Entity .Pre (lambda$instance , movementInput )).isCanceled ()) {
8384 ci .cancel ();
8485 }
8586 }
8687
8788 @ Inject (method = "travel" , at = @ At ("TAIL" ))
8889 void onTravelPost (Vec3d movementInput , CallbackInfo ci ) {
89- EventFlow .post (new MovementEvent .Entity .Post (( LivingEntity ) ( Object ) this , movementInput ));
90+ EventFlow .post (new MovementEvent .Entity .Post (lambda$instance , movementInput ));
9091 }
9192
9293 /**
@@ -123,7 +124,7 @@ private float hookModifyFallFlyingPitch(LivingEntity entity) {
123124 */
124125 @ Redirect (method = "tick" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/entity/LivingEntity;getYaw()F" ), slice = @ Slice (to = @ At (value = "INVOKE" , target = "Lnet/minecraft/entity/LivingEntity;getYaw()F" , ordinal = 1 )))
125126 private float rotBody (LivingEntity entity ) {
126- if (( Object ) this != Lambda .getMc ().player ) {
127+ if (lambda$instance != Lambda .getMc ().player ) {
127128 return entity .getYaw ();
128129 }
129130
@@ -154,11 +155,18 @@ private float rotBody(LivingEntity entity) {
154155 */
155156 @ Redirect (method = "turnHead" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/entity/LivingEntity;getYaw()F" ))
156157 private float rotHead (LivingEntity entity ) {
157- if (( Object ) this != Lambda .getMc ().player ) {
158+ if (lambda$instance != Lambda .getMc ().player ) {
158159 return entity .getYaw ();
159160 }
160161
161162 Float yaw = RotationManager .getRenderYaw ();
162163 return (yaw == null ) ? entity .getYaw () : yaw ;
163164 }
165+
166+ @ ModifyConstant (method = "getHandSwingDuration" , constant = @ Constant (intValue = 6 ))
167+ private int getHandSwingDuration (int constant ) {
168+ if (lambda$instance != Lambda .getMc ().player || ViewModel .INSTANCE .isDisabled ()) return constant ;
169+
170+ return ViewModel .INSTANCE .getSwingDuration ();
171+ }
164172}
0 commit comments