添加武器hud位置配置项

This commit is contained in:
17146 2025-06-05 16:05:19 +08:00 committed by Light_Quanta
parent 94e1bed1e8
commit 64fdd4ec54
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
5 changed files with 57 additions and 20 deletions

View file

@ -66,13 +66,16 @@ public class AmmoBarOverlay implements LayeredDraw.Layer {
ItemStack stack = player.getMainHandItem();
if (stack.getItem() instanceof GunItem gunItem && !(player.getVehicle() instanceof ArmedVehicleEntity vehicle && vehicle.banHand(player))) {
final var tag = NBTTool.getTag(stack);
int x = w + DisplayConfig.WEAPON_HUD_X_OFFSET.get();
int y = h + DisplayConfig.WEAPON_HUD_Y_OFFSET.get();
PoseStack poseStack = guiGraphics.pose();
var data = GunData.from(stack);
// 渲染图标
guiGraphics.blit(gunItem.getGunIcon(),
w - 135,
h - 40,
x - 135,
y - 40,
0,
0,
64,
@ -85,8 +88,8 @@ public class AmmoBarOverlay implements LayeredDraw.Layer {
guiGraphics.drawString(
Minecraft.getInstance().font,
"[" + ModKeyMappings.FIRE_MODE.getKey().getDisplayName().getString() + "]",
w - 111.5f,
h - 20,
x - 111.5f,
y - 20,
0xFFFFFF,
false
);
@ -105,15 +108,15 @@ public class AmmoBarOverlay implements LayeredDraw.Layer {
guiGraphics.drawString(
Minecraft.getInstance().font,
data.rpm() + " RPM",
w - 111f,
h - 20,
x - 111f,
y - 20,
0xFFFFFF,
false
);
guiGraphics.blit(fireMode,
w - 126,
h - 22,
x - 126,
y - 22,
0,
0,
12,
@ -122,8 +125,8 @@ public class AmmoBarOverlay implements LayeredDraw.Layer {
12);
} else {
guiGraphics.blit(fireMode,
w - 95,
h - 21,
x - 95,
y - 21,
0,
0,
8,
@ -134,8 +137,8 @@ public class AmmoBarOverlay implements LayeredDraw.Layer {
if (stack.getItem() != ModItems.MINIGUN.get() && stack.getItem() != ModItems.TRACHELIUM.get()) {
guiGraphics.blit(LINE,
w - 95,
h - 16,
x - 95,
y - 16,
0,
0,
8,
@ -151,8 +154,8 @@ public class AmmoBarOverlay implements LayeredDraw.Layer {
guiGraphics.drawString(
Minecraft.getInstance().font,
getGunAmmoString(data, player),
w / 1.5f - 64 / 1.5f,
h / 1.5f - 48 / 1.5f,
x / 1.5f - 64 / 1.5f,
y / 1.5f - 48 / 1.5f,
0xFFFFFF,
true
);
@ -163,8 +166,8 @@ public class AmmoBarOverlay implements LayeredDraw.Layer {
guiGraphics.drawString(
Minecraft.getInstance().font,
getBackupAmmoString(data, player),
w - 64,
h - 35,
x - 64,
y - 35,
0xCCCCCC,
true
);
@ -177,8 +180,8 @@ public class AmmoBarOverlay implements LayeredDraw.Layer {
guiGraphics.drawString(
Minecraft.getInstance().font,
gunName,
w / 0.9f - (100 + Minecraft.getInstance().font.width(gunName) / 2f) / 0.9f,
h / 0.9f - 60 / 0.9f,
x / 0.9f - (100 + Minecraft.getInstance().font.width(gunName) / 2f) / 0.9f,
y / 0.9f - 60 / 0.9f,
0xFFFFFF,
true
);
@ -188,8 +191,8 @@ public class AmmoBarOverlay implements LayeredDraw.Layer {
guiGraphics.drawString(
Minecraft.getInstance().font,
ammoName,
w / 0.9f - (100 + Minecraft.getInstance().font.width(ammoName) / 2f) / 0.9f,
h / 0.9f - 51 / 0.9f,
x / 0.9f - (100 + Minecraft.getInstance().font.width(ammoName) / 2f) / 0.9f,
y / 0.9f - 51 / 0.9f,
0xC8A679,
true
);

View file

@ -19,6 +19,24 @@ public class DisplayClothConfig {
.build()
);
category.addEntry(entryBuilder
.startIntSlider(Component.translatable("config.superbwarfare.client.display.weapon_hud_x_offset"), DisplayConfig.WEAPON_HUD_X_OFFSET.get(),
-1000, 1000)
.setDefaultValue(0)
.setSaveConsumer(DisplayConfig.WEAPON_HUD_X_OFFSET::set)
.setTooltip(Component.translatable("config.superbwarfare.client.display.weapon_hud_x_offset.des"))
.build()
);
category.addEntry(entryBuilder
.startIntSlider(Component.translatable("config.superbwarfare.client.display.weapon_hud_y_offset"), DisplayConfig.WEAPON_HUD_Y_OFFSET.get(),
-1000, 1000)
.setDefaultValue(0)
.setSaveConsumer(DisplayConfig.WEAPON_HUD_Y_OFFSET::set)
.setTooltip(Component.translatable("config.superbwarfare.client.display.weapon_hud_y_offset.des"))
.build()
);
category.addEntry(entryBuilder
.startBooleanToggle(Component.translatable("config.superbwarfare.client.display.kill_indication"), DisplayConfig.KILL_INDICATION.get())
.setDefaultValue(true)

View file

@ -5,6 +5,8 @@ import net.neoforged.neoforge.common.ModConfigSpec;
public class DisplayConfig {
public static ModConfigSpec.BooleanValue ENABLE_GUN_LOD;
public static ModConfigSpec.IntValue WEAPON_HUD_X_OFFSET;
public static ModConfigSpec.IntValue WEAPON_HUD_Y_OFFSET;
public static ModConfigSpec.BooleanValue KILL_INDICATION;
public static ModConfigSpec.BooleanValue AMMO_HUD;
public static ModConfigSpec.BooleanValue FLOAT_CROSS_HAIR;
@ -23,6 +25,12 @@ public class DisplayConfig {
builder.comment("Set true to enable gun lod");
ENABLE_GUN_LOD = builder.define("enable_gun_lod", false);
builder.comment("The x offset of weapon hud");
WEAPON_HUD_X_OFFSET = builder.defineInRange("weapon_hud_x_offset", 0, -1000, 1000);
builder.comment("The y offset of weapon hud");
WEAPON_HUD_Y_OFFSET = builder.defineInRange("weapon_hud_y_offset", 0, -1000, 1000);
builder.comment("Set true if you want to show kill indication while killing an entity");
KILL_INDICATION = builder.define("kill_indication", true);

View file

@ -611,6 +611,10 @@
"config.superbwarfare.client.display.dog_tag_icon_visible.des": "Whether to display the icon of dog tag in kill messages",
"config.superbwarfare.client.display.enable_gun_lod": "Enable Gun LOD",
"config.superbwarfare.client.display.enable_gun_lod.des": "Whether to enable gun lod in third person view",
"config.superbwarfare.client.display.weapon_hud_x_offset": "Weapon HUD X Offset",
"config.superbwarfare.client.display.weapon_hud_x_offset.des": "The horizontal offset of weapon HUD",
"config.superbwarfare.client.display.weapon_hud_y_offset": "Weapon HUD Y Offset",
"config.superbwarfare.client.display.weapon_hud_y_offset.des": "The vertical offset of weapon HUD",
"config.superbwarfare.client.vehicle": "Control Vehicle",
"config.superbwarfare.client.vehicle.invert_aircraft_control": "Invert Aircraft Control",
"config.superbwarfare.client.vehicle.left_click_reload.des": "Set TRUE to invert aircraft control",

View file

@ -611,6 +611,10 @@
"config.superbwarfare.client.display.dog_tag_icon_visible.des": "是否在击杀提示中显示狗牌的图标",
"config.superbwarfare.client.display.enable_gun_lod": "启用枪械LOD",
"config.superbwarfare.client.display.enable_gun_lod.des": "是否在第三人称视角下显示枪械的低模(节省性能)",
"config.superbwarfare.client.display.weapon_hud_x_offset": "武器HUD水平偏移",
"config.superbwarfare.client.display.weapon_hud_x_offset.des": "武器HUD位置的水平方向偏移量",
"config.superbwarfare.client.display.weapon_hud_y_offset": "武器HUD竖直偏移",
"config.superbwarfare.client.display.weapon_hud_y_offset.des": "武器HUD位置的竖直方向偏移量",
"config.superbwarfare.client.vehicle": "载具控制",
"config.superbwarfare.client.vehicle.invert_aircraft_control": "飞行器鼠标反转",
"config.superbwarfare.client.vehicle.left_click_reload.des": "开启飞行器鼠标反转",