添加武器hud位置配置项
This commit is contained in:
parent
94e1bed1e8
commit
64fdd4ec54
5 changed files with 57 additions and 20 deletions
|
@ -66,13 +66,16 @@ public class AmmoBarOverlay implements LayeredDraw.Layer {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (stack.getItem() instanceof GunItem gunItem && !(player.getVehicle() instanceof ArmedVehicleEntity vehicle && vehicle.banHand(player))) {
|
if (stack.getItem() instanceof GunItem gunItem && !(player.getVehicle() instanceof ArmedVehicleEntity vehicle && vehicle.banHand(player))) {
|
||||||
final var tag = NBTTool.getTag(stack);
|
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();
|
PoseStack poseStack = guiGraphics.pose();
|
||||||
var data = GunData.from(stack);
|
var data = GunData.from(stack);
|
||||||
|
|
||||||
// 渲染图标
|
// 渲染图标
|
||||||
guiGraphics.blit(gunItem.getGunIcon(),
|
guiGraphics.blit(gunItem.getGunIcon(),
|
||||||
w - 135,
|
x - 135,
|
||||||
h - 40,
|
y - 40,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
64,
|
64,
|
||||||
|
@ -85,8 +88,8 @@ public class AmmoBarOverlay implements LayeredDraw.Layer {
|
||||||
guiGraphics.drawString(
|
guiGraphics.drawString(
|
||||||
Minecraft.getInstance().font,
|
Minecraft.getInstance().font,
|
||||||
"[" + ModKeyMappings.FIRE_MODE.getKey().getDisplayName().getString() + "]",
|
"[" + ModKeyMappings.FIRE_MODE.getKey().getDisplayName().getString() + "]",
|
||||||
w - 111.5f,
|
x - 111.5f,
|
||||||
h - 20,
|
y - 20,
|
||||||
0xFFFFFF,
|
0xFFFFFF,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
@ -105,15 +108,15 @@ public class AmmoBarOverlay implements LayeredDraw.Layer {
|
||||||
guiGraphics.drawString(
|
guiGraphics.drawString(
|
||||||
Minecraft.getInstance().font,
|
Minecraft.getInstance().font,
|
||||||
data.rpm() + " RPM",
|
data.rpm() + " RPM",
|
||||||
w - 111f,
|
x - 111f,
|
||||||
h - 20,
|
y - 20,
|
||||||
0xFFFFFF,
|
0xFFFFFF,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
guiGraphics.blit(fireMode,
|
guiGraphics.blit(fireMode,
|
||||||
w - 126,
|
x - 126,
|
||||||
h - 22,
|
y - 22,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
12,
|
12,
|
||||||
|
@ -122,8 +125,8 @@ public class AmmoBarOverlay implements LayeredDraw.Layer {
|
||||||
12);
|
12);
|
||||||
} else {
|
} else {
|
||||||
guiGraphics.blit(fireMode,
|
guiGraphics.blit(fireMode,
|
||||||
w - 95,
|
x - 95,
|
||||||
h - 21,
|
y - 21,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
8,
|
8,
|
||||||
|
@ -134,8 +137,8 @@ public class AmmoBarOverlay implements LayeredDraw.Layer {
|
||||||
|
|
||||||
if (stack.getItem() != ModItems.MINIGUN.get() && stack.getItem() != ModItems.TRACHELIUM.get()) {
|
if (stack.getItem() != ModItems.MINIGUN.get() && stack.getItem() != ModItems.TRACHELIUM.get()) {
|
||||||
guiGraphics.blit(LINE,
|
guiGraphics.blit(LINE,
|
||||||
w - 95,
|
x - 95,
|
||||||
h - 16,
|
y - 16,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
8,
|
8,
|
||||||
|
@ -151,8 +154,8 @@ public class AmmoBarOverlay implements LayeredDraw.Layer {
|
||||||
guiGraphics.drawString(
|
guiGraphics.drawString(
|
||||||
Minecraft.getInstance().font,
|
Minecraft.getInstance().font,
|
||||||
getGunAmmoString(data, player),
|
getGunAmmoString(data, player),
|
||||||
w / 1.5f - 64 / 1.5f,
|
x / 1.5f - 64 / 1.5f,
|
||||||
h / 1.5f - 48 / 1.5f,
|
y / 1.5f - 48 / 1.5f,
|
||||||
0xFFFFFF,
|
0xFFFFFF,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
@ -163,8 +166,8 @@ public class AmmoBarOverlay implements LayeredDraw.Layer {
|
||||||
guiGraphics.drawString(
|
guiGraphics.drawString(
|
||||||
Minecraft.getInstance().font,
|
Minecraft.getInstance().font,
|
||||||
getBackupAmmoString(data, player),
|
getBackupAmmoString(data, player),
|
||||||
w - 64,
|
x - 64,
|
||||||
h - 35,
|
y - 35,
|
||||||
0xCCCCCC,
|
0xCCCCCC,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
@ -177,8 +180,8 @@ public class AmmoBarOverlay implements LayeredDraw.Layer {
|
||||||
guiGraphics.drawString(
|
guiGraphics.drawString(
|
||||||
Minecraft.getInstance().font,
|
Minecraft.getInstance().font,
|
||||||
gunName,
|
gunName,
|
||||||
w / 0.9f - (100 + Minecraft.getInstance().font.width(gunName) / 2f) / 0.9f,
|
x / 0.9f - (100 + Minecraft.getInstance().font.width(gunName) / 2f) / 0.9f,
|
||||||
h / 0.9f - 60 / 0.9f,
|
y / 0.9f - 60 / 0.9f,
|
||||||
0xFFFFFF,
|
0xFFFFFF,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
@ -188,8 +191,8 @@ public class AmmoBarOverlay implements LayeredDraw.Layer {
|
||||||
guiGraphics.drawString(
|
guiGraphics.drawString(
|
||||||
Minecraft.getInstance().font,
|
Minecraft.getInstance().font,
|
||||||
ammoName,
|
ammoName,
|
||||||
w / 0.9f - (100 + Minecraft.getInstance().font.width(ammoName) / 2f) / 0.9f,
|
x / 0.9f - (100 + Minecraft.getInstance().font.width(ammoName) / 2f) / 0.9f,
|
||||||
h / 0.9f - 51 / 0.9f,
|
y / 0.9f - 51 / 0.9f,
|
||||||
0xC8A679,
|
0xC8A679,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
|
@ -19,6 +19,24 @@ public class DisplayClothConfig {
|
||||||
.build()
|
.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
|
category.addEntry(entryBuilder
|
||||||
.startBooleanToggle(Component.translatable("config.superbwarfare.client.display.kill_indication"), DisplayConfig.KILL_INDICATION.get())
|
.startBooleanToggle(Component.translatable("config.superbwarfare.client.display.kill_indication"), DisplayConfig.KILL_INDICATION.get())
|
||||||
.setDefaultValue(true)
|
.setDefaultValue(true)
|
||||||
|
|
|
@ -5,6 +5,8 @@ import net.neoforged.neoforge.common.ModConfigSpec;
|
||||||
public class DisplayConfig {
|
public class DisplayConfig {
|
||||||
|
|
||||||
public static ModConfigSpec.BooleanValue ENABLE_GUN_LOD;
|
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 KILL_INDICATION;
|
||||||
public static ModConfigSpec.BooleanValue AMMO_HUD;
|
public static ModConfigSpec.BooleanValue AMMO_HUD;
|
||||||
public static ModConfigSpec.BooleanValue FLOAT_CROSS_HAIR;
|
public static ModConfigSpec.BooleanValue FLOAT_CROSS_HAIR;
|
||||||
|
@ -23,6 +25,12 @@ public class DisplayConfig {
|
||||||
builder.comment("Set true to enable gun lod");
|
builder.comment("Set true to enable gun lod");
|
||||||
ENABLE_GUN_LOD = builder.define("enable_gun_lod", false);
|
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");
|
builder.comment("Set true if you want to show kill indication while killing an entity");
|
||||||
KILL_INDICATION = builder.define("kill_indication", true);
|
KILL_INDICATION = builder.define("kill_indication", true);
|
||||||
|
|
||||||
|
|
|
@ -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.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": "Enable Gun LOD",
|
||||||
"config.superbwarfare.client.display.enable_gun_lod.des": "Whether to enable gun lod in third person view",
|
"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": "Control Vehicle",
|
||||||
"config.superbwarfare.client.vehicle.invert_aircraft_control": "Invert Aircraft Control",
|
"config.superbwarfare.client.vehicle.invert_aircraft_control": "Invert Aircraft Control",
|
||||||
"config.superbwarfare.client.vehicle.left_click_reload.des": "Set TRUE to invert aircraft control",
|
"config.superbwarfare.client.vehicle.left_click_reload.des": "Set TRUE to invert aircraft control",
|
||||||
|
|
|
@ -611,6 +611,10 @@
|
||||||
"config.superbwarfare.client.display.dog_tag_icon_visible.des": "是否在击杀提示中显示狗牌的图标",
|
"config.superbwarfare.client.display.dog_tag_icon_visible.des": "是否在击杀提示中显示狗牌的图标",
|
||||||
"config.superbwarfare.client.display.enable_gun_lod": "启用枪械LOD",
|
"config.superbwarfare.client.display.enable_gun_lod": "启用枪械LOD",
|
||||||
"config.superbwarfare.client.display.enable_gun_lod.des": "是否在第三人称视角下显示枪械的低模(节省性能)",
|
"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": "载具控制",
|
||||||
"config.superbwarfare.client.vehicle.invert_aircraft_control": "飞行器鼠标反转",
|
"config.superbwarfare.client.vehicle.invert_aircraft_control": "飞行器鼠标反转",
|
||||||
"config.superbwarfare.client.vehicle.left_click_reload.des": "开启飞行器鼠标反转",
|
"config.superbwarfare.client.vehicle.left_click_reload.des": "开启飞行器鼠标反转",
|
||||||
|
|
Loading…
Add table
Reference in a new issue