添加准星的配置项

This commit is contained in:
17146 2024-09-29 12:19:31 +08:00
parent 256d05f9d7
commit 161cc52fb5
5 changed files with 32 additions and 13 deletions

View file

@ -51,8 +51,13 @@ public class CrossHairOverlay {
ItemStack stack = player.getMainHandItem();
double spread = ClientEventHandler.gunSpread + 3 * ClientEventHandler.firePos;
float deltaFrame = Minecraft.getInstance().getDeltaFrameTime();
float moveX = (float) (-6 * ClientEventHandler.turnRot[1] - (player.isSprinting() ? 10 : 6) * ClientEventHandler.movePosX);
float moveY = (float) (-6 * ClientEventHandler.turnRot[0] + 6 * (float) ClientEventHandler.velocityY - (player.isSprinting() ? 10 : 6) * ClientEventHandler.movePosY - 2 * ClientEventHandler.firePos);
float moveX = 0;
float moveY = 0;
if (DisplayConfig.FLOAT_CROSS_HAIR.get()) {
moveX = (float) (-6 * ClientEventHandler.turnRot[1] - (player.isSprinting() ? 10 : 6) * ClientEventHandler.movePosX);
moveY = (float) (-6 * ClientEventHandler.turnRot[0] + 6 * (float) ClientEventHandler.velocityY - (player.isSprinting() ? 10 : 6) * ClientEventHandler.movePosY - 2 * ClientEventHandler.firePos);
}
RenderSystem.disableDepthTest();
RenderSystem.depthMask(false);
@ -62,18 +67,17 @@ public class CrossHairOverlay {
RenderSystem.setShaderColor(1, 1, 1, 1);
scopeScale = (float) Mth.lerp(0.5F * deltaFrame, scopeScale, 1 + 1.5f * spread);
float f = (float) Math.min(w, h);
float f1 = Math.min((float) w / f, (float) h / f) * 0.012f * scopeScale;
float i = Mth.floor(f * f1);
float j = Mth.floor(f * f1);
float k = ((w - i) / 2) + moveX;
float l = ((h - j) / 2) + moveY;
float minLength = (float) Math.min(w, h);
float scaledMinLength = Math.min((float) w / minLength, (float) h / minLength) * 0.012f * scopeScale;
float finLength = Mth.floor(minLength * scaledMinLength);
float finPosX = ((w - finLength) / 2) + moveX;
float finPosY = ((h - finLength) / 2) + moveY;
if (shouldRenderCrossHair(player) || stack.is(ModItems.MINIGUN.get())) {
preciseBlit(guiGraphics, new ResourceLocation(ModUtils.MODID, "textures/screens/point.png"), w / 2f - 7.5f + moveX, h / 2f - 7.5f + moveY, 0, 0, 16, 16, 16, 16);
if (!player.isSprinting() || player.getPersistentData().getDouble("noRun") > 0) {
if (stack.is(ModTags.Items.SHOTGUN)) {
preciseBlit(guiGraphics, new ResourceLocation(ModUtils.MODID, "textures/screens/shotgun_hud.png"), k, l, 0, 0.0F, i, j, i, j);
preciseBlit(guiGraphics, new ResourceLocation(ModUtils.MODID, "textures/screens/shotgun_hud.png"), finPosX, finPosY, 0, 0.0F, finLength, finLength, finLength, finLength);
} else {
preciseBlit(guiGraphics, REX_HORIZONTAL, (float) (w / 2f - 13.5f - 2.8f * spread) + moveX, h / 2f - 7.5f + moveY, 0, 0, 16, 16, 16, 16);
preciseBlit(guiGraphics, REX_HORIZONTAL, (float) (w / 2f - 2.5f + 2.8f * spread) + moveX, h / 2f - 7.5f + moveY, 0, 0, 16, 16, 16, 16);
@ -88,7 +92,7 @@ public class CrossHairOverlay {
preciseBlit(guiGraphics, new ResourceLocation(ModUtils.MODID, "textures/screens/point.png"), w / 2f - 7.5f + moveX, h / 2f - 7.5f + moveY, 0, 0, 16, 16, 16, 16);
if (!player.isSprinting() || player.getPersistentData().getDouble("noRun") > 0 || ClientEventHandler.pullPos > 0) {
if (ClientEventHandler.zoomTime < 0.1) {
preciseBlit(guiGraphics, new ResourceLocation(ModUtils.MODID, "textures/screens/shotgun_hud.png"), k, l, 0, 0.0F, i, j, i, j);
preciseBlit(guiGraphics, new ResourceLocation(ModUtils.MODID, "textures/screens/shotgun_hud.png"), finPosX, finPosY, 0, 0.0F, finLength, finLength, finLength, finLength);
} else {
preciseBlit(guiGraphics, REX_HORIZONTAL, (float) (w / 2f - 13.5f - 2.8f * spread) + moveX, h / 2f - 7.5f + moveY, 0, 0, 16, 16, 16, 16);
preciseBlit(guiGraphics, REX_HORIZONTAL, (float) (w / 2f - 2.5f + 2.8f * spread) + moveX, h / 2f - 7.5f + moveY, 0, 0, 16, 16, 16, 16);

View file

@ -4,7 +4,6 @@ import me.shedaniel.clothconfig2.api.ConfigBuilder;
import me.shedaniel.clothconfig2.api.ConfigCategory;
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder;
import net.mcreator.superbwarfare.config.client.DisplayConfig;
import net.mcreator.superbwarfare.config.client.KillMessageConfig;
import net.minecraft.network.chat.Component;
public class DisplayClothConfig {
@ -35,5 +34,13 @@ public class DisplayClothConfig {
.setTooltip(Component.translatable("config.superbwarfare.client.display.ammo_hud.des"))
.build()
);
category.addEntry(entryBuilder
.startBooleanToggle(Component.translatable("config.superbwarfare.client.display.float_cross_hair"), DisplayConfig.FLOAT_CROSS_HAIR.get())
.setDefaultValue(true)
.setSaveConsumer(DisplayConfig.FLOAT_CROSS_HAIR::set)
.setTooltip(Component.translatable("config.superbwarfare.client.display.float_cross_hair.des"))
.build()
);
}
}

View file

@ -7,6 +7,7 @@ public class DisplayConfig {
public static ForgeConfigSpec.BooleanValue KILL_INDICATION;
public static ForgeConfigSpec.BooleanValue GLOBAL_INDICATION;
public static ForgeConfigSpec.BooleanValue AMMO_HUD;
public static ForgeConfigSpec.BooleanValue FLOAT_CROSS_HAIR;
public static void init(ForgeConfigSpec.Builder builder) {
builder.push("display");
@ -20,6 +21,9 @@ public class DisplayConfig {
builder.comment("Set TRUE to show ammo and gun info on HUD");
AMMO_HUD = builder.define("ammo_hud", true);
builder.comment("Set TRUE to enable float cross hair");
FLOAT_CROSS_HAIR = builder.define("float_cross_hair", true);
builder.pop();
}
}

View file

@ -359,5 +359,7 @@
"config.superbwarfare.client.display.global_indication": "全局伤害提示",
"config.superbwarfare.client.display.global_indication.des": "是否在仅使用本模组的伤害类型击杀生物时,在准星周围显示击杀提示",
"config.superbwarfare.client.display.ammo_hud": "枪械信息",
"config.superbwarfare.client.display.ammo_hud.des": "开启时,在屏幕右下角显示枪械和弹药信息"
"config.superbwarfare.client.display.ammo_hud.des": "开启时,在屏幕右下角显示枪械和弹药信息",
"config.superbwarfare.client.display.float_cross_hair": "浮动准星",
"config.superbwarfare.client.display.float_cross_hair.des": "开启时,准星会跟随视角进行一定程度的移动"
}

View file

@ -358,5 +358,7 @@
"config.superbwarfare.client.display.global_indication": "全局伤害提示",
"config.superbwarfare.client.display.global_indication.des": "是否在仅使用本模组的伤害类型击杀生物时,在准星周围显示击杀提示",
"config.superbwarfare.client.display.ammo_hud": "枪械信息",
"config.superbwarfare.client.display.ammo_hud.des": "开启时,在屏幕右下角显示枪械和弹药信息"
"config.superbwarfare.client.display.ammo_hud.des": "开启时,在屏幕右下角显示枪械和弹药信息",
"config.superbwarfare.client.display.float_cross_hair": "浮动准星",
"config.superbwarfare.client.display.float_cross_hair.des": "开启时,准星会跟随视角进行一定程度的移动"
}