Skip to content

Commit 1f6e108

Browse files
committed
Rotation Smoothness (LOCK Mode)
1 parent cd856dd commit 1f6e108

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

common/src/main/java/com/lambda/mixin/render/CameraMixin.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
package com.lambda.mixin.render;
22

3+
import com.lambda.interaction.RotationManager;
34
import com.lambda.module.modules.player.Freecam;
45
import net.minecraft.client.render.Camera;
56
import net.minecraft.entity.Entity;
67
import net.minecraft.world.BlockView;
78
import org.spongepowered.asm.mixin.Mixin;
9+
import org.spongepowered.asm.mixin.Shadow;
810
import org.spongepowered.asm.mixin.injection.At;
911
import org.spongepowered.asm.mixin.injection.Inject;
1012
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1113

1214
@Mixin(Camera.class)
13-
public class CameraMixin {
15+
public abstract class CameraMixin {
16+
@Shadow
17+
public abstract void setRotation(float yaw, float pitch);
18+
1419
@Inject(method = "update", at = @At("TAIL"))
1520
private void onUpdate(
1621
BlockView area,
@@ -24,4 +29,11 @@ private void onUpdate(
2429

2530
Freecam.updateCam();
2631
}
32+
33+
@Inject(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;setPos(DDD)V", shift = At.Shift.AFTER))
34+
private void injectQuickPerspectiveSwap(BlockView area, Entity focusedEntity, boolean thirdPerson, boolean inverseView, float tickDelta, CallbackInfo ci) {
35+
var rot = RotationManager.getLockRotation();
36+
if (rot == null) return;
37+
setRotation(rot.getYawF(), rot.getPitchF());
38+
}
2739
}

0 commit comments

Comments
 (0)