修改HUD渲染对齐方式

This commit is contained in:
17146 2024-05-18 18:44:36 +08:00
parent 43607e3ef5
commit 626c046aaa
3 changed files with 35 additions and 13 deletions

View file

@ -41,7 +41,7 @@ public class AmmoBarOverlay {
// 渲染图标 // 渲染图标
event.getGuiGraphics().blit(gunItem.getGunIcon(), event.getGuiGraphics().blit(gunItem.getGunIcon(),
w / 2 + 95, w - 135,
h - 40, h - 40,
0, 0,
0, 0,
@ -52,8 +52,8 @@ public class AmmoBarOverlay {
// 渲染开火模式切换按键 // 渲染开火模式切换按键
event.getGuiGraphics().blit(BUTTON, event.getGuiGraphics().blit(BUTTON,
w / 2 + 118, w - 115,
h - 18, h - 20,
0, 0,
0, 0,
10, 10,
@ -64,8 +64,8 @@ public class AmmoBarOverlay {
event.getGuiGraphics().drawString( event.getGuiGraphics().drawString(
Minecraft.getInstance().font, Minecraft.getInstance().font,
TargetModKeyMappings.FIREMODE.getKey().getDisplayName().getString(), TargetModKeyMappings.FIREMODE.getKey().getDisplayName().getString(),
w / 2 + 121, w - 111.5f,
h - 18, h - 20,
0x050505, 0x050505,
false false
); );
@ -74,8 +74,8 @@ public class AmmoBarOverlay {
ResourceLocation fireMode = getFireMode(stack); ResourceLocation fireMode = getFireMode(stack);
event.getGuiGraphics().blit(fireMode, event.getGuiGraphics().blit(fireMode,
w / 2 + 135, w - 100,
h - 17, h - 19,
0, 0,
0, 0,
8, 8,
@ -84,8 +84,8 @@ public class AmmoBarOverlay {
8); 8);
event.getGuiGraphics().blit(LINE, event.getGuiGraphics().blit(LINE,
w / 2 + 135, w - 100,
h - 12, h - 14,
0, 0,
0, 0,
8, 8,
@ -101,7 +101,7 @@ public class AmmoBarOverlay {
event.getGuiGraphics().drawString( event.getGuiGraphics().drawString(
Minecraft.getInstance().font, Minecraft.getInstance().font,
getGunAmmoCount(player) + "", getGunAmmoCount(player) + "",
w / 3f + 112, w / 1.5f - 62 / 1.5f,
h / 1.5f - 31, h / 1.5f - 31,
0xFFFFFF, 0xFFFFFF,
true true
@ -112,7 +112,7 @@ public class AmmoBarOverlay {
event.getGuiGraphics().drawString( event.getGuiGraphics().drawString(
Minecraft.getInstance().font, Minecraft.getInstance().font,
getPlayerAmmoCount(player), getPlayerAmmoCount(player),
w / 2 + 170, w - 60,
h - 35, h - 35,
0xCCCCCC, 0xCCCCCC,
true true
@ -125,7 +125,7 @@ public class AmmoBarOverlay {
event.getGuiGraphics().drawString( event.getGuiGraphics().drawString(
Minecraft.getInstance().font, Minecraft.getInstance().font,
centerString(gunItem.getGunDisplayName(), 20), centerString(gunItem.getGunDisplayName(), 20),
w / 2 + 138, w / 0.9f - 128 / 0.9f,
h - 34, h - 34,
0xFFFFFF, 0xFFFFFF,
true true
@ -135,7 +135,7 @@ public class AmmoBarOverlay {
event.getGuiGraphics().drawString( event.getGuiGraphics().drawString(
Minecraft.getInstance().font, Minecraft.getInstance().font,
centerString(getGunAmmoType(stack), 20), centerString(getGunAmmoType(stack), 20),
w / 2 + 138, w / 0.9f - 128 / 0.9f,
h - 26, h - 26,
0xC8A679, 0xC8A679,
true true

View file

@ -15,6 +15,7 @@ import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -186,4 +187,14 @@ public class Hk416Item extends GunItem implements GeoItem, AnimatedItem {
public void setAnimationProcedure(String procedure) { public void setAnimationProcedure(String procedure) {
this.animationProcedure = procedure; this.animationProcedure = procedure;
} }
@Override
public ResourceLocation getGunIcon() {
return new ResourceLocation(TargetMod.MODID, "textures/gun_icon/hk416_icon.png");
}
@Override
public String getGunDisplayName() {
return "HK416";
}
} }

View file

@ -18,6 +18,7 @@ import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
@ -209,4 +210,14 @@ public class HuntingRifle extends GunItem implements GeoItem, AnimatedItem {
public void setAnimationProcedure(String procedure) { public void setAnimationProcedure(String procedure) {
this.animationProcedure = procedure; this.animationProcedure = procedure;
} }
@Override
public ResourceLocation getGunIcon() {
return new ResourceLocation(TargetMod.MODID, "textures/gun_icon/hunting_rifle_icon.png");
}
@Override
public String getGunDisplayName() {
return "Hunting Rifle";
}
} }