Skip to content

Commit be182ca

Browse files
committed
use local yaw and pitch to further compatibility potential
1 parent 09cd68e commit be182ca

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/main/java/com/lambda/mixin/entity/ClientPlayerEntityMixin.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.lambda.event.events.PlayerEvent;
2424
import com.lambda.event.events.PlayerPacketEvent;
2525
import com.lambda.event.events.TickEvent;
26+
import com.lambda.interaction.managers.rotating.Rotation;
2627
import com.lambda.interaction.managers.rotating.RotationManager;
2728
import com.lambda.module.modules.movement.ElytraFly;
2829
import com.lambda.module.modules.movement.NoJumpCooldown;
@@ -36,7 +37,6 @@
3637
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
3738
import com.llamalad7.mixinextras.sugar.Local;
3839
import com.mojang.authlib.GameProfile;
39-
import net.minecraft.client.MinecraftClient;
4040
import net.minecraft.client.gui.screen.Screen;
4141
import net.minecraft.client.input.Input;
4242
import net.minecraft.client.network.AbstractClientPlayerEntity;
@@ -46,24 +46,23 @@
4646
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
4747
import net.minecraft.util.Hand;
4848
import net.minecraft.util.math.Vec3d;
49-
import org.spongepowered.asm.mixin.Final;
5049
import org.spongepowered.asm.mixin.Mixin;
5150
import org.spongepowered.asm.mixin.Shadow;
5251
import org.spongepowered.asm.mixin.Unique;
5352
import org.spongepowered.asm.mixin.injection.At;
5453
import org.spongepowered.asm.mixin.injection.Inject;
5554
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
5655
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
56+
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
5757

5858
import java.util.Objects;
5959

6060
@Mixin(value = ClientPlayerEntity.class, priority = Integer.MAX_VALUE)
6161
public abstract class ClientPlayerEntityMixin extends AbstractClientPlayerEntity {
6262
@Shadow
63-
public Input input;
63+
private float lastYawClient;
6464
@Shadow
65-
@Final
66-
protected MinecraftClient client;
65+
private float lastPitchClient;
6766
@Unique
6867
private PlayerPacketEvent.Pre moveEvent;
6968

@@ -103,6 +102,13 @@ private boolean modifyHasRotated(boolean original) {
103102
return !RotationManager.getActiveRotation().equalFloat(RotationManager.getServerRotation()) || original;
104103
}
105104

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+
106112
@WrapOperation(method = "sendMovementPackets", at = @At(value = "NEW", target = "net/minecraft/network/packet/c2s/play/PlayerMoveC2SPacket$Full"))
107113
private PlayerMoveC2SPacket.Full wrapFullPacket(Vec3d pos, float yaw, float pitch, boolean onGround, boolean horizontalCollision, Operation<PlayerMoveC2SPacket.Full> original) {
108114
return original.call(moveEvent.getPosition(), moveEvent.getRotation().getYawF(), moveEvent.getRotation().getPitchF(), moveEvent.getOnGround(), moveEvent.isCollidingHorizontally());

src/main/kotlin/com/lambda/interaction/managers/rotating/RotationManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ object RotationManager : Manager<RotationRequest>(
6565
var yawRequest
6666
get() = requests[1] as? IRotationRequest.YawRot
6767
set(value) { requests[1] = value }
68-
val requests = mutableListOf<IRotationRequest?>(null, null)
68+
@JvmStatic val requests = mutableListOf<IRotationRequest?>(null, null)
6969

7070
private var usingBaritoneRotation = false
7171
@JvmStatic var activeRotation = Rotation.ZERO

0 commit comments

Comments
 (0)