2626import com .lambda .interaction .managers .rotating .RotationManager ;
2727import com .lambda .module .modules .player .PortalGui ;
2828import com .lambda .module .modules .render .ViewModel ;
29+ import com .llamalad7 .mixinextras .injector .ModifyExpressionValue ;
2930import com .llamalad7 .mixinextras .injector .wrapmethod .WrapMethod ;
3031import com .llamalad7 .mixinextras .injector .wrapoperation .Operation ;
32+ import com .llamalad7 .mixinextras .injector .wrapoperation .WrapOperation ;
3133import com .mojang .authlib .GameProfile ;
3234import net .minecraft .client .MinecraftClient ;
3335import net .minecraft .client .gui .screen .Screen ;
4345import org .spongepowered .asm .mixin .Shadow ;
4446import org .spongepowered .asm .mixin .injection .At ;
4547import org .spongepowered .asm .mixin .injection .Inject ;
46- import org .spongepowered .asm .mixin .injection .Redirect ;
4748import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
4849import org .spongepowered .asm .mixin .injection .callback .CallbackInfoReturnable ;
4950
@@ -59,16 +60,16 @@ public ClientPlayerEntityMixin(ClientWorld world, GameProfile profile) {
5960 super (world , profile );
6061 }
6162
62- @ Redirect (method = "move" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;move(Lnet/minecraft/entity/MovementType;Lnet/minecraft/util/math/Vec3d;)V" ))
63- private void emitMovementEvents (AbstractClientPlayerEntity instance , MovementType movementType , Vec3d movement ) {
64- EventFlow .post (new MovementEvent .Player .Pre (movementType , movement ));
65- super . move ( movementType , movement );
66- EventFlow .post (new MovementEvent .Player .Post (movementType , movement ));
63+ @ WrapOperation (method = "move" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;move(Lnet/minecraft/entity/MovementType;Lnet/minecraft/util/math/Vec3d;)V" ))
64+ private void emitMovementEvents (ClientPlayerEntity instance , MovementType movementType , Vec3d vec3d , Operation < Void > original ) {
65+ EventFlow .post (new MovementEvent .Player .Pre (movementType , vec3d ));
66+ original . call ( instance , movementType , vec3d );
67+ EventFlow .post (new MovementEvent .Player .Post (movementType , vec3d ));
6768 }
6869
69- @ Redirect (method = "tickMovement" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/input/Input;tick()V" ))
70- void processMovement (Input input ) {
71- input . tick ( );
70+ @ WrapOperation (method = "tickMovement" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/input/Input;tick()V" ))
71+ void processMovement (Input input , Operation < Void > original ) {
72+ original . call ( input );
7273 RotationManager .processRotations ();
7374 RotationManager .redirectStrafeInputs (input );
7475 EventFlow .post (new MovementEvent .InputUpdate (input ));
@@ -84,14 +85,14 @@ void sendLambdaMovement(CallbackInfo ci) {
8485 autoJumpEnabled = Lambda .getMc ().options .getAutoJump ().getValue ();
8586 }
8687
87- @ Redirect (method = "tick" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/network/ClientPlayerEntity;sendSneakingPacket()V" ))
88- void sendSneakingPacket (ClientPlayerEntity entity ) {
88+ @ WrapOperation (method = "tick" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/network/ClientPlayerEntity;sendSneakingPacket()V" ))
89+ void sendSneakingPacket (ClientPlayerEntity entity , Operation < Void > original ) {
8990 PlayerPacketHandler .sendSneakPackets ();
9091 }
9192
92- @ Redirect (method = "tickMovement" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/network/ClientPlayerEntity;isSprinting()Z" ))
93- boolean isSprinting (ClientPlayerEntity entity ) {
94- return EventFlow .post (new MovementEvent .Sprint (entity . isSprinting () )).getSprint ();
93+ @ ModifyExpressionValue (method = "tickMovement" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/network/ClientPlayerEntity;isSprinting()Z" ))
94+ boolean isSprinting (boolean original ) {
95+ return EventFlow .post (new MovementEvent .Sprint (original )).getSprint ();
9596 }
9697
9798 @ Inject (method = "isSneaking" , at = @ At (value = "HEAD" ), cancellable = true )
@@ -110,27 +111,27 @@ void onTick(Operation<Void> original) {
110111 EventFlow .post (TickEvent .Player .Post .INSTANCE );
111112 }
112113
113- @ Redirect (method = "tick" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/network/ClientPlayerEntity;getYaw()F" ))
114- float fixHeldItemYaw (ClientPlayerEntity instance ) {
115- return Objects .requireNonNullElse (RotationManager .getHandYaw (), instance . getYaw ( ));
114+ @ WrapOperation (method = "tick" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/network/ClientPlayerEntity;getYaw()F" ))
115+ float fixHeldItemYaw (ClientPlayerEntity instance , Operation < Float > original ) {
116+ return Objects .requireNonNullElse (RotationManager .getHandYaw (), original . call ( instance ));
116117 }
117118
118- @ Redirect (method = "tick" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/network/ClientPlayerEntity;getPitch()F" ))
119- float fixHeldItemPitch (ClientPlayerEntity instance ) {
120- return Objects .requireNonNullElse (RotationManager .getHandPitch (), instance . getPitch ( ));
119+ @ WrapOperation (method = "tick" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/network/ClientPlayerEntity;getPitch()F" ))
120+ float fixHeldItemPitch (ClientPlayerEntity instance , Operation < Float > original ) {
121+ return Objects .requireNonNullElse (RotationManager .getHandPitch (), original . call ( instance ));
121122 }
122123
123124 @ Inject (method = "swingHand" , at = @ At ("HEAD" ), cancellable = true )
124125 void onSwing (Hand hand , CallbackInfo ci ) {
125126 if (EventFlow .post (new PlayerEvent .SwingHand (hand )).isCanceled ()) ci .cancel ();
126127 }
127128
128- @ Redirect (method = "swingHand" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;swingHand(Lnet/minecraft/util/Hand;)V" ))
129- private void adjustSwing (AbstractClientPlayerEntity instance , Hand hand ) {
129+ @ WrapOperation (method = "swingHand" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;swingHand(Lnet/minecraft/util/Hand;)V" ))
130+ private void adjustSwing (ClientPlayerEntity instance , Hand hand , Operation < Void > original ) {
130131 ViewModel viewModel = ViewModel .INSTANCE ;
131132
132133 if (!viewModel .isEnabled ()) {
133- instance . swingHand ( hand , false );
134+ original . call ( instance , hand );
134135 return ;
135136 }
136137
@@ -157,9 +158,9 @@ public void damage(float health, CallbackInfo ci) {
157158 * }
158159 * }</pre>
159160 */
160- @ Redirect (method = "tickNausea" , at = @ At (value = "FIELD" , target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;" ))
161- Screen keepScreensInPortal (MinecraftClient instance ) {
161+ @ ModifyExpressionValue (method = "tickNausea" , at = @ At (value = "FIELD" , target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;" ))
162+ Screen keepScreensInPortal (Screen original ) {
162163 if (PortalGui .INSTANCE .isEnabled ()) return null ;
163- else return client . currentScreen ;
164+ else return original ;
164165 }
165166}
0 commit comments