优化渲染方法命名
This commit is contained in:
parent
c2a7af8a85
commit
9acd95fa5c
2 changed files with 22 additions and 18 deletions
|
@ -68,13 +68,13 @@ public class KillMessageOverlay {
|
||||||
);
|
);
|
||||||
|
|
||||||
// 第一个图标:爆头/爆炸/近战等图标
|
// 第一个图标:爆头/爆炸/近战等图标
|
||||||
int icon1W = w - targetNameWidth - 28;
|
int damageTypeIconW = w - targetNameWidth - 28;
|
||||||
|
|
||||||
ResourceLocation icon1 = getIcon1(record);
|
ResourceLocation damageTypeIcon = getDamageTypeIcon(record);
|
||||||
|
|
||||||
if (icon1 != null) {
|
if (damageTypeIcon != null) {
|
||||||
event.getGuiGraphics().blit(icon1,
|
event.getGuiGraphics().blit(damageTypeIcon,
|
||||||
icon1W,
|
damageTypeIconW,
|
||||||
h - 2,
|
h - 2,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
@ -85,11 +85,13 @@ public class KillMessageOverlay {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isGun = record.stack.getItem() instanceof GunItem;
|
boolean renderItem = false;
|
||||||
// 如果是枪械击杀,则渲染枪械图标
|
// 如果是枪械击杀,则渲染枪械图标
|
||||||
if (record.stack.getItem() instanceof GunItem gunItem) {
|
if (record.stack.getItem() instanceof GunItem gunItem) {
|
||||||
|
renderItem = true;
|
||||||
|
|
||||||
ResourceLocation resourceLocation = gunItem.getGunIcon();
|
ResourceLocation resourceLocation = gunItem.getGunIcon();
|
||||||
int gunIconW = icon1 != null ? w - targetNameWidth - 64 : w - targetNameWidth - 46;
|
int gunIconW = damageTypeIcon != null ? w - targetNameWidth - 64 : w - targetNameWidth - 46;
|
||||||
event.getGuiGraphics().blit(resourceLocation,
|
event.getGuiGraphics().blit(resourceLocation,
|
||||||
gunIconW,
|
gunIconW,
|
||||||
h,
|
h,
|
||||||
|
@ -102,14 +104,17 @@ public class KillMessageOverlay {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO 如果是特殊武器击杀,则渲染对应图标
|
||||||
|
|
||||||
|
|
||||||
// 渲染击杀者名称
|
// 渲染击杀者名称
|
||||||
String attackerName = record.attacker.getDisplayName().getString();
|
String attackerName = record.attacker.getDisplayName().getString();
|
||||||
int attackerNameWidth = font.width(attackerName);
|
int attackerNameWidth = font.width(attackerName);
|
||||||
int nameW = w - targetNameWidth - 16 - attackerNameWidth;
|
int nameW = w - targetNameWidth - 16 - attackerNameWidth;
|
||||||
if (isGun) {
|
if (renderItem) {
|
||||||
nameW -= 32;
|
nameW -= 32;
|
||||||
}
|
}
|
||||||
if (icon1 != null) {
|
if (damageTypeIcon != null) {
|
||||||
nameW -= 18;
|
nameW -= 18;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,26 +130,26 @@ public class KillMessageOverlay {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static ResourceLocation getIcon1(PlayerKillRecord record) {
|
private static ResourceLocation getDamageTypeIcon(PlayerKillRecord record) {
|
||||||
ResourceLocation icon1;
|
ResourceLocation icon;
|
||||||
// 渲染爆头图标
|
// 渲染爆头图标
|
||||||
if (record.headshot) {
|
if (record.headshot) {
|
||||||
icon1 = HEADSHOT;
|
icon = HEADSHOT;
|
||||||
} else {
|
} else {
|
||||||
if (record.damageType == TargetModDamageTypes.GUN_FIRE || record.damageType == TargetModDamageTypes.GUN_FIRE_HEADSHOT
|
if (record.damageType == TargetModDamageTypes.GUN_FIRE || record.damageType == TargetModDamageTypes.GUN_FIRE_HEADSHOT
|
||||||
|| record.damageType == TargetModDamageTypes.ARROW_IN_KNEE || record.damageType == TargetModDamageTypes.ARROW_IN_BRAIN) {
|
|| record.damageType == TargetModDamageTypes.ARROW_IN_KNEE || record.damageType == TargetModDamageTypes.ARROW_IN_BRAIN) {
|
||||||
icon1 = null;
|
icon = null;
|
||||||
} else {
|
} else {
|
||||||
// 如果是其他伤害,则渲染对应图标
|
// 如果是其他伤害,则渲染对应图标
|
||||||
if (record.damageType == DamageTypes.EXPLOSION || record.damageType == DamageTypes.PLAYER_EXPLOSION) {
|
if (record.damageType == DamageTypes.EXPLOSION || record.damageType == DamageTypes.PLAYER_EXPLOSION) {
|
||||||
icon1 = EXPLOSION;
|
icon = EXPLOSION;
|
||||||
} else if (record.damageType == DamageTypes.PLAYER_ATTACK) {
|
} else if (record.damageType == DamageTypes.PLAYER_ATTACK) {
|
||||||
icon1 = KNIFE;
|
icon = KNIFE;
|
||||||
} else {
|
} else {
|
||||||
icon1 = GENERIC;
|
icon = GENERIC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return icon1;
|
return icon;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,5 +16,4 @@
|
||||||
"burst": 0,
|
"burst": 0,
|
||||||
"auto": 1,
|
"auto": 1,
|
||||||
"burst_size": 1
|
"burst_size": 1
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue