修改了perk提示

This commit is contained in:
17146 2024-08-08 04:48:03 +08:00
parent 1173022f82
commit b61b82983b

View file

@ -84,43 +84,44 @@ public class TooltipTool {
.append(Component.literal(new DecimalFormat("##.##").format(byPassRate * 100) + "%").withStyle(ChatFormatting.GOLD).withStyle(ChatFormatting.BOLD)));
}
// TODO 实现正确的nbt获取
private static void addPerkTips(List<Component> tooltip, ItemStack stack) {
CompoundTag ammoTag = PerkHelper.getPerkTag(stack, Perk.Type.AMMO);
CompoundTag functionalTag = PerkHelper.getPerkTag(stack, Perk.Type.FUNCTIONAL);
CompoundTag damageTag = PerkHelper.getPerkTag(stack, Perk.Type.DAMAGE);
tooltip.add(Component.literal(damageTag.toString()));
if (!ammoTag.isEmpty() || !functionalTag.isEmpty() || !damageTag.isEmpty()) {
tooltip.add(Component.translatable("perk.superbwarfare.tips").withStyle(ChatFormatting.WHITE));
tooltip.add(Component.literal(""));
tooltip.add(Component.translatable("perk.superbwarfare.tips").withStyle(ChatFormatting.GOLD));
}
if (!ammoTag.isEmpty()) {
String id = ammoTag.getString("id").split(":")[1];
tooltip.add(Component.translatable("perk.superbwarfare.slot_Ammo").withStyle(ChatFormatting.YELLOW)
.append(Component.literal(" >> "))
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.translatable("item.superbwarfare." + ammoTag.getString("id")).withStyle(ChatFormatting.GRAY))
.append(Component.literal("Lvl. " + ammoTag.getInt("level")).withStyle(ChatFormatting.GRAY)));
addHideText(tooltip, Component.translatable("perk.superbwarfare." + ammoTag.getString("id") + ".desc").withStyle(ChatFormatting.GRAY));
.append(Component.translatable("item.superbwarfare." + id).withStyle(ChatFormatting.WHITE))
.append(Component.literal(" Lvl. " + ammoTag.getInt("level")).withStyle(ChatFormatting.WHITE)));
addHideText(tooltip, Component.translatable("perk.superbwarfare." + id + ".desc").withStyle(ChatFormatting.GRAY));
}
if (!functionalTag.isEmpty()) {
String id = functionalTag.getString("id").split(":")[1];
tooltip.add(Component.translatable("perk.superbwarfare.slot_Functional").withStyle(ChatFormatting.GREEN)
.append(Component.literal(" >> "))
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.translatable("item.superbwarfare." + functionalTag.getString("id")).withStyle(ChatFormatting.GRAY))
.append(Component.literal("Lvl. " + functionalTag.getInt("level")).withStyle(ChatFormatting.GRAY)));
addHideText(tooltip, Component.translatable("perk.superbwarfare." + functionalTag.getString("id") + ".desc").withStyle(ChatFormatting.GRAY));
.append(Component.translatable("item.superbwarfare." + id).withStyle(ChatFormatting.WHITE))
.append(Component.literal(" Lvl. " + functionalTag.getInt("level")).withStyle(ChatFormatting.WHITE)));
addHideText(tooltip, Component.translatable("perk.superbwarfare." + id + ".desc").withStyle(ChatFormatting.GRAY));
}
if (!damageTag.isEmpty()) {
String id = damageTag.getString("id").split(":")[1];
tooltip.add(Component.translatable("perk.superbwarfare.slot_Damage").withStyle(ChatFormatting.RED)
.append(Component.literal(" >> "))
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.translatable("item.superbwarfare." + damageTag.getString("id")).withStyle(ChatFormatting.GRAY))
.append(Component.literal("Lvl. " + damageTag.getInt("level")).withStyle(ChatFormatting.GRAY)));
addHideText(tooltip, Component.translatable("perk.superbwarfare." + damageTag.getString("id") + ".desc").withStyle(ChatFormatting.GRAY));
.append(Component.translatable("item.superbwarfare." + id).withStyle(ChatFormatting.WHITE))
.append(Component.literal(" Lvl. " + damageTag.getInt("level")).withStyle(ChatFormatting.WHITE)));
addHideText(tooltip, Component.translatable("perk.superbwarfare." + id + ".desc").withStyle(ChatFormatting.GRAY));
}
}