平滑智慧芯片瞄准效果
This commit is contained in:
parent
2e4fd79576
commit
5354d8e7de
1 changed files with 23 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue