平滑智慧芯片瞄准效果

This commit is contained in:
Light_Quanta 2025-07-09 02:51:40 +08:00
parent 2e4fd79576
commit 5354d8e7de
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959

View file

@ -1484,6 +1484,8 @@ public class ClientEventHandler {
if (stack.getItem() instanceof GunItem) {
if (!event.usedConfiguredFov()) {
lastX = player.getXRot();
lastY = player.getYRot();
return;
}
@ -1531,6 +1533,9 @@ public class ClientEventHandler {
entity = null;
}
}
lastX = player.getXRot();
lastY = player.getYRot();
}
if (stack.is(ModItems.MONITOR.get()) && tag.getBoolean("Using") && tag.getBoolean("Linked")) {
@ -1540,13 +1545,29 @@ public class ClientEventHandler {
}
}
private static float lastX;
private static float lastY;
public static void look(Player player, Vec3 pTarget) {
double d0 = pTarget.x;
double d1 = pTarget.y;
double d2 = pTarget.z;
double d3 = Math.sqrt(d0 * d0 + d2 * d2);
player.setXRot(Mth.wrapDegrees((float) (-(Mth.atan2(d1, d3) * 57.2957763671875))));
player.setYRot(Mth.wrapDegrees((float) (Mth.atan2(d2, d0) * 57.2957763671875) - 90.0F));
float fromX = lastX;
float fromY = lastY;
float toX = (float) Mth.wrapDegrees(-(Mth.atan2(d1, d3) * 57.2957763671875));
float toY = (float) Mth.wrapDegrees((Mth.atan2(d2, d0) * 57.2957763671875) - 90.0F);
if (fromY > 135 && toY < -135) {
toY += 360;
}
if (fromY < -135 && toY > 135) {
fromY += 360;
}
player.setXRot(Mth.wrapDegrees(Mth.lerp(0.2F, fromX, toX)));
player.setYRot(Mth.wrapDegrees(Mth.lerp(0.2F, fromY, toY)));
}
@SubscribeEvent