修改提示渲染类

This commit is contained in:
17146 2024-05-19 19:09:14 +08:00
parent 739e622465
commit bd385e7fae

View file

@ -50,10 +50,12 @@ public class KillMessageOverlay {
int attackerNameWidth = font.width(attackerName); int attackerNameWidth = font.width(attackerName);
int targetNameWidth = font.width(targetName); int targetNameWidth = font.width(targetName);
int nameW = record.headshot ? w - targetNameWidth - 68 - attackerNameWidth : w - targetNameWidth - 50 - attackerNameWidth;
event.getGuiGraphics().drawString( event.getGuiGraphics().drawString(
Minecraft.getInstance().font, Minecraft.getInstance().font,
attackerName, attackerName,
w - targetNameWidth - 50 - attackerNameWidth, nameW,
h, h,
record.attacker.getTeamColor(), record.attacker.getTeamColor(),
false false
@ -62,8 +64,10 @@ public class KillMessageOverlay {
if (record.stack.getItem() instanceof GunItem gunItem) { if (record.stack.getItem() instanceof GunItem gunItem) {
ResourceLocation resourceLocation = gunItem.getGunIcon(); ResourceLocation resourceLocation = gunItem.getGunIcon();
int gunIconW = record.headshot ? w - targetNameWidth - 64 : w - targetNameWidth - 46;
event.getGuiGraphics().blit(resourceLocation, event.getGuiGraphics().blit(resourceLocation,
w - targetNameWidth - 46, gunIconW,
h, h,
0, 0,
0, 0,
@ -74,6 +78,19 @@ public class KillMessageOverlay {
); );
} }
if (record.headshot) {
event.getGuiGraphics().blit(HEADSHOT,
w - targetNameWidth - 28,
h - 2,
0,
0,
12,
12,
12,
12
);
}
event.getGuiGraphics().drawString( event.getGuiGraphics().drawString(
Minecraft.getInstance().font, Minecraft.getInstance().font,
targetName, targetName,
@ -82,18 +99,5 @@ public class KillMessageOverlay {
record.target.getTeamColor(), record.target.getTeamColor(),
false false
); );
if (record.headshot) {
event.getGuiGraphics().blit(HEADSHOT,
w - targetNameWidth - 65 - attackerNameWidth,
h - 2,
0,
0,
12,
12,
12,
12
);
}
} }
} }