|
23 | 23 | import com.lambda.event.events.PlayerEvent; |
24 | 24 | import com.lambda.event.events.PlayerPacketEvent; |
25 | 25 | import com.lambda.event.events.TickEvent; |
| 26 | +import com.lambda.interaction.managers.rotating.Rotation; |
26 | 27 | import com.lambda.interaction.managers.rotating.RotationManager; |
27 | 28 | import com.lambda.module.modules.movement.ElytraFly; |
28 | 29 | import com.lambda.module.modules.movement.NoJumpCooldown; |
|
36 | 37 | import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; |
37 | 38 | import com.llamalad7.mixinextras.sugar.Local; |
38 | 39 | import com.mojang.authlib.GameProfile; |
39 | | -import net.minecraft.client.MinecraftClient; |
40 | 40 | import net.minecraft.client.gui.screen.Screen; |
41 | 41 | import net.minecraft.client.input.Input; |
42 | 42 | import net.minecraft.client.network.AbstractClientPlayerEntity; |
|
46 | 46 | import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; |
47 | 47 | import net.minecraft.util.Hand; |
48 | 48 | import net.minecraft.util.math.Vec3d; |
49 | | -import org.spongepowered.asm.mixin.Final; |
50 | 49 | import org.spongepowered.asm.mixin.Mixin; |
51 | 50 | import org.spongepowered.asm.mixin.Shadow; |
52 | 51 | import org.spongepowered.asm.mixin.Unique; |
53 | 52 | import org.spongepowered.asm.mixin.injection.At; |
54 | 53 | import org.spongepowered.asm.mixin.injection.Inject; |
55 | 54 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
56 | 55 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; |
| 56 | +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; |
57 | 57 |
|
58 | 58 | import java.util.Objects; |
59 | 59 |
|
60 | 60 | @Mixin(value = ClientPlayerEntity.class, priority = Integer.MAX_VALUE) |
61 | 61 | public abstract class ClientPlayerEntityMixin extends AbstractClientPlayerEntity { |
62 | 62 | @Shadow |
63 | | - public Input input; |
| 63 | + private float lastYawClient; |
64 | 64 | @Shadow |
65 | | - @Final |
66 | | - protected MinecraftClient client; |
| 65 | + private float lastPitchClient; |
67 | 66 | @Unique |
68 | 67 | private PlayerPacketEvent.Pre moveEvent; |
69 | 68 |
|
@@ -103,6 +102,13 @@ private boolean modifyHasRotated(boolean original) { |
103 | 102 | return !RotationManager.getActiveRotation().equalFloat(RotationManager.getServerRotation()) || original; |
104 | 103 | } |
105 | 104 |
|
| 105 | + @Inject(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/packet/Packet;)V"), locals = LocalCapture.CAPTURE_FAILEXCEPTION) |
| 106 | + private void injectSendPacket(CallbackInfo ci, double d, double e, double f, double g, double h, boolean bl, boolean bl2) { |
| 107 | + if (RotationManager.getRequests().stream().allMatch(Objects::nonNull)) { |
| 108 | + moveEvent.setRotation(new Rotation(g + lastYawClient, h + lastPitchClient)); |
| 109 | + } |
| 110 | + } |
| 111 | + |
106 | 112 | @WrapOperation(method = "sendMovementPackets", at = @At(value = "NEW", target = "net/minecraft/network/packet/c2s/play/PlayerMoveC2SPacket$Full")) |
107 | 113 | private PlayerMoveC2SPacket.Full wrapFullPacket(Vec3d pos, float yaw, float pitch, boolean onGround, boolean horizontalCollision, Operation<PlayerMoveC2SPacket.Full> original) { |
108 | 114 | return original.call(moveEvent.getPosition(), moveEvent.getRotation().getYawF(), moveEvent.getRotation().getPitchF(), moveEvent.getOnGround(), moveEvent.isCollidingHorizontally()); |
|
0 commit comments