添加越肩视角调整位置功能
This commit is contained in:
parent
d7493c0fde
commit
72ca233504
3 changed files with 16 additions and 8 deletions
|
@ -85,6 +85,7 @@ public class ClientEventHandler {
|
||||||
public static double fireSpread = 0;
|
public static double fireSpread = 0;
|
||||||
public static double cantFireTime = 0;
|
public static double cantFireTime = 0;
|
||||||
public static double lookDistance = 0;
|
public static double lookDistance = 0;
|
||||||
|
public static double cameraLocation = 0.6;
|
||||||
|
|
||||||
public static MillisTimer clientTimer = new MillisTimer();
|
public static MillisTimer clientTimer = new MillisTimer();
|
||||||
|
|
||||||
|
@ -178,7 +179,6 @@ public class ClientEventHandler {
|
||||||
cantFireTime = Mth.clamp(cantFireTime - 6 * times, 0, 30);
|
cantFireTime = Mth.clamp(cantFireTime - 6 * times, 0, 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
// player.displayClientMessage(Component.literal(new java.text.DecimalFormat("##").format(cantFireTime)), true);
|
|
||||||
|
|
||||||
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_LEFT) == GLFW.GLFW_PRESS
|
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_LEFT) == GLFW.GLFW_PRESS
|
||||||
&& (player.getMainHandItem().is(ModTags.Items.NORMAL_GUN)
|
&& (player.getMainHandItem().is(ModTags.Items.NORMAL_GUN)
|
||||||
|
@ -227,7 +227,7 @@ public class ClientEventHandler {
|
||||||
public static void computeCameraAngles(ViewportEvent.ComputeCameraAngles event) {
|
public static void computeCameraAngles(ViewportEvent.ComputeCameraAngles event) {
|
||||||
ClientLevel level = Minecraft.getInstance().level;
|
ClientLevel level = Minecraft.getInstance().level;
|
||||||
Entity entity = event.getCamera().getEntity();
|
Entity entity = event.getCamera().getEntity();
|
||||||
handlePlayerCameraShake(event);
|
handlePlayerCamera(event);
|
||||||
if (level != null && entity instanceof LivingEntity living
|
if (level != null && entity instanceof LivingEntity living
|
||||||
&& living.getMainHandItem().is(ModItems.MONITOR.get())
|
&& living.getMainHandItem().is(ModItems.MONITOR.get())
|
||||||
&& living.getMainHandItem().getOrCreateTag().getBoolean("Using")
|
&& living.getMainHandItem().getOrCreateTag().getBoolean("Using")
|
||||||
|
@ -506,12 +506,20 @@ public class ClientEventHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handlePlayerCameraShake(ViewportEvent.ComputeCameraAngles event) {
|
private static void handlePlayerCamera(ViewportEvent.ComputeCameraAngles event) {
|
||||||
double yaw = event.getYaw();
|
double yaw = event.getYaw();
|
||||||
double pitch = event.getPitch();
|
double pitch = event.getPitch();
|
||||||
double roll = event.getRoll();
|
double roll = event.getRoll();
|
||||||
LocalPlayer player = Minecraft.getInstance().player;
|
LocalPlayer player = Minecraft.getInstance().player;
|
||||||
|
|
||||||
|
if (GLFW.glfwGetKey(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_KEY_RIGHT) == GLFW.GLFW_PRESS) {
|
||||||
|
cameraLocation = Mth.clamp(cameraLocation - 0.05 * Minecraft.getInstance().getDeltaFrameTime(), -0.6, 0.6);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GLFW.glfwGetKey(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_KEY_LEFT) == GLFW.GLFW_PRESS) {
|
||||||
|
cameraLocation = Mth.clamp(cameraLocation + 0.05 * Minecraft.getInstance().getDeltaFrameTime(), -0.6, 0.6);
|
||||||
|
}
|
||||||
|
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
|
|
||||||
double range;
|
double range;
|
||||||
|
@ -533,14 +541,14 @@ public class ClientEventHandler {
|
||||||
|
|
||||||
double angle = 0;
|
double angle = 0;
|
||||||
|
|
||||||
if (lookDistance != 0) {
|
if (lookDistance != 0 && cameraLocation != 0) {
|
||||||
angle = Math.atan(0.6 / (lookDistance + 2.9)) * Mth.RAD_TO_DEG;
|
angle = Math.atan(Mth.abs((float) cameraLocation) / (lookDistance + 2.9)) * Mth.RAD_TO_DEG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.getMainHandItem().is(ModTags.Items.GUN) || (player.getVehicle() != null && (player.getVehicle() instanceof ICannonEntity))) {
|
if (player.getMainHandItem().is(ModTags.Items.GUN) || (player.getVehicle() != null && (player.getVehicle() instanceof ICannonEntity))) {
|
||||||
event.setPitch((float) (pitch + cameraRot[0] + (DisplayConfig.CAMERA_ROTATE.get() ? 0.2 : 0) * turnRot[0] + 3 * velocityY));
|
event.setPitch((float) (pitch + cameraRot[0] + (DisplayConfig.CAMERA_ROTATE.get() ? 0.2 : 0) * turnRot[0] + 3 * velocityY));
|
||||||
if (Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_BACK) {
|
if (Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_BACK) {
|
||||||
event.setYaw((float) (yaw + cameraRot[1] + (DisplayConfig.CAMERA_ROTATE.get() ? 0.8 : 0) * turnRot[1] - angle * zoomPos));
|
event.setYaw((float) (yaw + cameraRot[1] + (DisplayConfig.CAMERA_ROTATE.get() ? 0.8 : 0) * turnRot[1] - (cameraLocation > 0 ? 1 : -1) * angle * zoomPos));
|
||||||
} else {
|
} else {
|
||||||
event.setYaw((float) (yaw + cameraRot[1] + (DisplayConfig.CAMERA_ROTATE.get() ? 0.8 : 0) * turnRot[1]));
|
event.setYaw((float) (yaw + cameraRot[1] + (DisplayConfig.CAMERA_ROTATE.get() ? 0.8 : 0) * turnRot[1]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ public abstract class CameraMixin {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_BACK && entity instanceof Player player && player.getMainHandItem().is(ModTags.Items.GUN)) {
|
if (Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_BACK && entity instanceof Player player && player.getMainHandItem().is(ModTags.Items.GUN)) {
|
||||||
move(-getMaxZoom(-2.9 * Math.max(ClientEventHandler.pullPos, ClientEventHandler.zoomPos)), 0, -0.6 * Math.max(ClientEventHandler.pullPos, ClientEventHandler.zoomPos));
|
move(-getMaxZoom(-2.9 * Math.max(ClientEventHandler.pullPos, ClientEventHandler.zoomPos)), 0, -ClientEventHandler.cameraLocation * Math.max(ClientEventHandler.pullPos, ClientEventHandler.zoomPos));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -345,7 +345,7 @@
|
||||||
|
|
||||||
"config.superbwarfare.title": "卓越前线",
|
"config.superbwarfare.title": "卓越前线",
|
||||||
"config.superbwarfare.client.reload": "换弹配置",
|
"config.superbwarfare.client.reload": "换弹配置",
|
||||||
"config.superbwarfare.client.reload.left_click_reload": "开火换弹",
|
"config.superbwarfare.client.reload.left_click_reload": "快捷换弹",
|
||||||
"config.superbwarfare.client.reload.left_click_reload.des": "在当前弹匣为空时,点击开火键以进行换弹",
|
"config.superbwarfare.client.reload.left_click_reload.des": "在当前弹匣为空时,点击开火键以进行换弹",
|
||||||
"config.superbwarfare.client.kill_message": "击杀信息配置",
|
"config.superbwarfare.client.kill_message": "击杀信息配置",
|
||||||
"config.superbwarfare.client.kill_message.show_kill_message": "显示击杀信息",
|
"config.superbwarfare.client.kill_message.show_kill_message": "显示击杀信息",
|
||||||
|
|
Loading…
Add table
Reference in a new issue