添加视角摇晃的配置项
This commit is contained in:
parent
d890a05b77
commit
11729e259a
5 changed files with 33 additions and 16 deletions
|
@ -42,5 +42,13 @@ public class DisplayClothConfig {
|
|||
.setTooltip(Component.translatable("config.superbwarfare.client.display.float_cross_hair.des"))
|
||||
.build()
|
||||
);
|
||||
|
||||
category.addEntry(entryBuilder
|
||||
.startBooleanToggle(Component.translatable("config.superbwarfare.client.display.camera_rotate"), DisplayConfig.CAMERA_ROTATE.get())
|
||||
.setDefaultValue(true)
|
||||
.setSaveConsumer(DisplayConfig.CAMERA_ROTATE::set)
|
||||
.setTooltip(Component.translatable("config.superbwarfare.client.display.camera_rotate.des"))
|
||||
.build()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ public class DisplayConfig {
|
|||
public static ForgeConfigSpec.BooleanValue GLOBAL_INDICATION;
|
||||
public static ForgeConfigSpec.BooleanValue AMMO_HUD;
|
||||
public static ForgeConfigSpec.BooleanValue FLOAT_CROSS_HAIR;
|
||||
public static ForgeConfigSpec.BooleanValue CAMERA_ROTATE;
|
||||
|
||||
public static void init(ForgeConfigSpec.Builder builder) {
|
||||
builder.push("display");
|
||||
|
@ -24,6 +25,9 @@ public class DisplayConfig {
|
|||
builder.comment("Set TRUE to enable float cross hair");
|
||||
FLOAT_CROSS_HAIR = builder.define("float_cross_hair", true);
|
||||
|
||||
builder.comment("Set TRUE to enable camera rotate when holding a gun");
|
||||
CAMERA_ROTATE = builder.define("camera_rotate", true);
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.mcreator.superbwarfare.event;
|
||||
|
||||
import net.mcreator.superbwarfare.ModUtils;
|
||||
import net.mcreator.superbwarfare.config.client.DisplayConfig;
|
||||
import net.mcreator.superbwarfare.entity.DroneEntity;
|
||||
import net.mcreator.superbwarfare.entity.ICannonEntity;
|
||||
import net.mcreator.superbwarfare.init.ModItems;
|
||||
|
@ -172,9 +173,9 @@ public class ClientEventHandler {
|
|||
// 开火部分
|
||||
|
||||
if (player.getPersistentData().getDouble("noRun") == 0 && player.isSprinting() && GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) != GLFW.GLFW_PRESS) {
|
||||
cantFireTime = Mth.clamp(cantFireTime + 3 * times,0,30);
|
||||
cantFireTime = Mth.clamp(cantFireTime + 3 * times, 0, 30);
|
||||
} else {
|
||||
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);
|
||||
|
@ -193,7 +194,7 @@ public class ClientEventHandler {
|
|||
}
|
||||
|
||||
if (stack.getItem() == ModItems.MINIGUN.get() && player.isInWater()) {
|
||||
customRpm = - 0.25 * stack.getOrCreateTag().getDouble("rpm");
|
||||
customRpm = -0.25 * stack.getOrCreateTag().getDouble("rpm");
|
||||
}
|
||||
|
||||
double rpm = stack.getOrCreateTag().getDouble("rpm") + customRpm;
|
||||
|
@ -525,9 +526,9 @@ public class ClientEventHandler {
|
|||
}
|
||||
|
||||
if (lookDistance < range) {
|
||||
lookDistance = Mth.clamp(lookDistance + 0.002 * Math.pow(range - lookDistance, 2) * Minecraft.getInstance().getDeltaFrameTime(),0.01, 520);
|
||||
lookDistance = Mth.clamp(lookDistance + 0.002 * Math.pow(range - lookDistance, 2) * Minecraft.getInstance().getDeltaFrameTime(), 0.01, 520);
|
||||
} else {
|
||||
lookDistance = Mth.clamp(lookDistance - 0.002 * Math.pow(range - lookDistance, 2) * Minecraft.getInstance().getDeltaFrameTime(),0.01, 520);
|
||||
lookDistance = Mth.clamp(lookDistance - 0.002 * Math.pow(range - lookDistance, 2) * Minecraft.getInstance().getDeltaFrameTime(), 0.01, 520);
|
||||
}
|
||||
|
||||
double angle = 0;
|
||||
|
@ -536,17 +537,17 @@ public class ClientEventHandler {
|
|||
angle = Math.atan(0.6 / (lookDistance + 2.9)) * Mth.RAD_TO_DEG;
|
||||
}
|
||||
|
||||
// player.displayClientMessage(Component.nullToEmpty(Component.literal(new DecimalFormat("##").format(lookDistance)) + " " + new DecimalFormat("##.#").format(angle)), true);
|
||||
if (DisplayConfig.CAMERA_ROTATE.get()) {
|
||||
if (player.getMainHandItem().is(ModTags.Items.GUN) || (player.getVehicle() != null && (player.getVehicle() instanceof ICannonEntity))) {
|
||||
event.setPitch((float) (pitch + cameraRot[0] + 0.2 * turnRot[0] + 3 * velocityY));
|
||||
if (Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_BACK) {
|
||||
event.setYaw((float) (yaw + cameraRot[1] + 0.8 * turnRot[1] - angle * zoomPos));
|
||||
} else {
|
||||
event.setYaw((float) (yaw + cameraRot[1] + 0.8 * turnRot[1]));
|
||||
}
|
||||
|
||||
if (player.getMainHandItem().is(ModTags.Items.GUN) || (player.getVehicle() != null && (player.getVehicle() instanceof ICannonEntity))) {
|
||||
event.setPitch((float) (pitch + cameraRot[0] + 0.2 * turnRot[0] + 3 * velocityY));
|
||||
if (Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_BACK) {
|
||||
event.setYaw((float) (yaw + cameraRot[1] + 0.8 * turnRot[1] - angle * zoomPos));
|
||||
} else {
|
||||
event.setYaw((float) (yaw + cameraRot[1] + 0.8 * turnRot[1]));
|
||||
event.setRoll((float) (roll + cameraRot[2] + 0.35 * turnRot[2]));
|
||||
}
|
||||
|
||||
event.setRoll((float) (roll + cameraRot[2] + 0.35 * turnRot[2]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -361,5 +361,7 @@
|
|||
"config.superbwarfare.client.display.ammo_hud": "枪械信息",
|
||||
"config.superbwarfare.client.display.ammo_hud.des": "开启时,在屏幕右下角显示枪械和弹药信息",
|
||||
"config.superbwarfare.client.display.float_cross_hair": "浮动准星",
|
||||
"config.superbwarfare.client.display.float_cross_hair.des": "开启时,准星会跟随视角进行一定程度的移动"
|
||||
"config.superbwarfare.client.display.float_cross_hair.des": "开启时,准星会跟随视角进行一定程度的移动",
|
||||
"config.superbwarfare.client.display.camera_rotate": "视角摇晃",
|
||||
"config.superbwarfare.client.display.camera_rotate.des": "手持枪械时,视角会出现轻微的摇晃"
|
||||
}
|
|
@ -360,5 +360,7 @@
|
|||
"config.superbwarfare.client.display.ammo_hud": "枪械信息",
|
||||
"config.superbwarfare.client.display.ammo_hud.des": "开启时,在屏幕右下角显示枪械和弹药信息",
|
||||
"config.superbwarfare.client.display.float_cross_hair": "浮动准星",
|
||||
"config.superbwarfare.client.display.float_cross_hair.des": "开启时,准星会跟随视角进行一定程度的移动"
|
||||
"config.superbwarfare.client.display.float_cross_hair.des": "开启时,准星会跟随视角进行一定程度的移动",
|
||||
"config.superbwarfare.client.display.camera_rotate": "视角摇晃",
|
||||
"config.superbwarfare.client.display.camera_rotate.des": "手持枪械时,视角会出现轻微的摇晃"
|
||||
}
|
Loading…
Add table
Reference in a new issue