替换Component.literal("")

This commit is contained in:
Light_Quanta 2025-05-24 02:20:33 +08:00
parent 989b7a09a6
commit aba336eb43
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
18 changed files with 36 additions and 36 deletions

View file

@ -203,7 +203,7 @@ public class FuMO25BlockEntity extends BlockEntity implements MenuProvider, GeoB
@Override
public @NotNull Component getDisplayName() {
return Component.literal("");
return Component.empty();
}
@Nullable

View file

@ -133,7 +133,7 @@ public class DroneHudOverlay implements LayeredDraw.Layer {
if (lookAtEntity) {
// 实体距离
var displayName = lookingEntity.getDisplayName();
if (displayName == null) displayName = Component.literal("");
if (displayName == null) displayName = Component.empty();
guiGraphics.drawString(mc.font, Component.translatable("tips.superbwarfare.drone.range")
.append(Component.literal(FormatTool.format1D(entityRange, "m ") + displayName.getString())),

View file

@ -145,7 +145,7 @@ public class DogTagEditorScreen extends AbstractContainerScreen<DogTagEditorMenu
protected void subInit() {
int i = (this.width - this.imageWidth) / 2;
int j = (this.height - this.imageHeight) / 2;
this.name = new EditBox(this.font, i + 9, j + 11, 180, 12, Component.literal(""));
this.name = new EditBox(this.font, i + 9, j + 11, 180, 12, Component.empty());
this.name.setCanLoseFocus(false);
this.name.setTextColor(-1);
this.name.setTextColorUneditable(-1);
@ -189,7 +189,7 @@ public class DogTagEditorScreen extends AbstractContainerScreen<DogTagEditorMenu
short color;
public ColorButton(short color, int pX, int pY, int pWidth, int pHeight) {
super(pX, pY, pWidth, pHeight, Component.literal(""));
super(pX, pY, pWidth, pHeight, Component.empty());
this.color = color;
}
@ -223,7 +223,7 @@ public class DogTagEditorScreen extends AbstractContainerScreen<DogTagEditorMenu
class FinishButton extends AbstractButton {
public FinishButton(int pX, int pY, int pWidth, int pHeight) {
super(pX, pY, pWidth, pHeight, Component.literal(""));
super(pX, pY, pWidth, pHeight, Component.empty());
}
@Override

View file

@ -285,7 +285,7 @@ public class FuMO25Screen extends AbstractContainerScreen<FuMO25Menu> {
class LockButton extends AbstractButton {
public LockButton(int pX, int pY) {
super(pX, pY, 29, 15, Component.literal(""));
super(pX, pY, 29, 15, Component.empty());
}
@Override
@ -318,7 +318,7 @@ public class FuMO25Screen extends AbstractContainerScreen<FuMO25Menu> {
private final int mode;
public ModeButton(int pX, int pY, int mode) {
super(pX, pY, 29, 15, Component.literal(""));
super(pX, pY, 29, 15, Component.empty());
this.mode = mode;
}

View file

@ -110,7 +110,7 @@ public class ReforgingTableScreen extends AbstractContainerScreen<ReforgingTable
}
public ReforgeButton(int pX, int pY) {
super(pX, pY, 40, 16, Component.literal(""));
super(pX, pY, 40, 16, Component.empty());
}
@ -129,7 +129,7 @@ public class ReforgingTableScreen extends AbstractContainerScreen<ReforgingTable
public Perk.Type type;
public UpgradeButton(int pX, int pY, Perk.Type type) {
super(pX, pY, 9, 9, Component.literal(""));
super(pX, pY, 9, 9, Component.empty());
this.type = type;
}
@ -181,7 +181,7 @@ public class ReforgingTableScreen extends AbstractContainerScreen<ReforgingTable
}
public DowngradeButton(int pX, int pY, Perk.Type type) {
super(pX, pY, 12, 12, Component.literal(""));
super(pX, pY, 12, 12, Component.empty());
this.type = type;
}

View file

@ -42,7 +42,7 @@ public class ClientBocekImageTooltip extends ClientGunImageTooltip {
}
return Component.translatable("des.superbwarfare.guns.damage").withStyle(ChatFormatting.GRAY)
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.empty().withStyle(ChatFormatting.RESET))
.append(Component.literal(extraDamage >= 0 ? ("(" + FormatTool.format1D(shotDamage) + " + " + FormatTool.format1D(extraDamage) + ") * 10")
: FormatTool.format1D(shotDamage, " * 10"))
.withStyle(ChatFormatting.GREEN))

View file

@ -49,7 +49,7 @@ public class ClientCellImageTooltip implements ClientTooltipComponent {
int energy = storage.getEnergyStored();
int maxEnergy = storage.getMaxEnergyStored();
float percentage = Mth.clamp((float) energy / maxEnergy, 0, 1);
MutableComponent component = Component.literal("");
MutableComponent component = Component.empty();
ChatFormatting format;
if (percentage <= .2f) {
@ -64,7 +64,7 @@ public class ClientCellImageTooltip implements ClientTooltipComponent {
for (int i = 0; i < count; i++) {
component.append(Component.literal("|").withStyle(format));
}
component.append(Component.literal("").withStyle(ChatFormatting.RESET));
component.append(Component.empty().withStyle(ChatFormatting.RESET));
for (int i = 0; i < 50 - count; i++) {
component.append(Component.literal("|").withStyle(ChatFormatting.GRAY));
}

View file

@ -41,7 +41,7 @@ public class ClientChargingStationImageTooltip implements ClientTooltipComponent
int energy = stack.getOrDefault(ModDataComponents.ENERGY.get(), 0);
int maxEnergy = ChargingStationBlockItem.MAX_ENERGY;
float percentage = Mth.clamp((float) energy / maxEnergy, 0, 1);
MutableComponent component = Component.literal("");
MutableComponent component = Component.empty();
ChatFormatting format;
if (percentage <= .2f) {
@ -56,7 +56,7 @@ public class ClientChargingStationImageTooltip implements ClientTooltipComponent
for (int i = 0; i < count; i++) {
component.append(Component.literal("|").withStyle(format));
}
component.append(Component.literal("").withStyle(ChatFormatting.RESET));
component.append(Component.empty().withStyle(ChatFormatting.RESET));
for (int i = 0; i < 50 - count; i++) {
component.append(Component.literal("|").withStyle(ChatFormatting.GRAY));
}

View file

@ -66,7 +66,7 @@ public class ClientEnergyImageTooltip extends ClientGunImageTooltip {
int energy = storage.getEnergyStored();
int maxEnergy = storage.getMaxEnergyStored();
float percentage = Mth.clamp((float) energy / maxEnergy, 0, 1);
MutableComponent component = Component.literal("");
MutableComponent component = Component.empty();
ChatFormatting format;
if (percentage <= .2f) {
@ -81,7 +81,7 @@ public class ClientEnergyImageTooltip extends ClientGunImageTooltip {
for (int i = 0; i < count; i++) {
component.append(Component.literal("|").withStyle(format));
}
component.append(Component.literal("").withStyle(ChatFormatting.RESET));
component.append(Component.empty().withStyle(ChatFormatting.RESET));
for (int i = 0; i < 50 - count; i++) {
component.append(Component.literal("|").withStyle(ChatFormatting.GRAY));
}

View file

@ -113,7 +113,7 @@ public class ClientGunImageTooltip implements ClientTooltipComponent {
}
return Component.translatable("des.superbwarfare.guns.damage").withStyle(ChatFormatting.GRAY)
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.empty().withStyle(ChatFormatting.RESET))
.append(Component.literal(dmgStr)
.withStyle(ChatFormatting.GREEN));
}
@ -126,11 +126,11 @@ public class ClientGunImageTooltip implements ClientTooltipComponent {
(GunData.from(this.stack).getAvailableFireModes().contains(FireMode.AUTO)
|| GunData.from(this.stack).getAvailableFireModes().contains(FireMode.BURST))) {
return Component.translatable("des.superbwarfare.guns.rpm").withStyle(ChatFormatting.GRAY)
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.empty().withStyle(ChatFormatting.RESET))
.append(Component.literal(FormatTool.format0D(data.rpm()))
.withStyle(ChatFormatting.GREEN));
}
return Component.literal("");
return Component.empty();
}
/**
@ -163,9 +163,9 @@ public class ClientGunImageTooltip implements ClientTooltipComponent {
}
return Component.translatable("des.superbwarfare.guns.level").withStyle(ChatFormatting.GRAY)
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.empty().withStyle(ChatFormatting.RESET))
.append(Component.literal(level + "").withStyle(formatting).withStyle(ChatFormatting.BOLD))
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.empty().withStyle(ChatFormatting.RESET))
.append(Component.literal(" (" + FormatTool.DECIMAL_FORMAT_2ZZZ.format(rate * 100) + "%)").withStyle(ChatFormatting.GRAY));
}
@ -175,7 +175,7 @@ public class ClientGunImageTooltip implements ClientTooltipComponent {
protected Component getUpgradePointComponent() {
int upgradePoint = Mth.floor(data.upgradePoint.get());
return Component.translatable("des.superbwarfare.guns.upgrade_point").withStyle(ChatFormatting.GRAY)
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.empty().withStyle(ChatFormatting.RESET))
.append(Component.literal(String.valueOf(upgradePoint)).withStyle(ChatFormatting.WHITE).withStyle(ChatFormatting.BOLD));
}
@ -203,7 +203,7 @@ public class ClientGunImageTooltip implements ClientTooltipComponent {
double bypassRate = Math.max(data.bypassArmor() + perkBypassArmorRate, 0);
return Component.translatable("des.superbwarfare.guns.bypass").withStyle(ChatFormatting.GRAY)
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.empty().withStyle(ChatFormatting.RESET))
.append(Component.literal(FormatTool.format2D(bypassRate * 100, "%")).withStyle(ChatFormatting.GOLD));
}
@ -213,7 +213,7 @@ public class ClientGunImageTooltip implements ClientTooltipComponent {
protected Component getHeadshotComponent() {
double headshot = data.headshot();
return Component.translatable("des.superbwarfare.guns.headshot").withStyle(ChatFormatting.GRAY)
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.empty().withStyle(ChatFormatting.RESET))
.append(Component.literal(FormatTool.format1D(headshot, "x")).withStyle(ChatFormatting.AQUA));
}

View file

@ -26,9 +26,9 @@ public class ClientLauncherImageTooltip extends ClientGunImageTooltip {
double explosionDamage = data.explosionDamage();
return Component.translatable("des.superbwarfare.guns.damage").withStyle(ChatFormatting.GRAY)
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.empty().withStyle(ChatFormatting.RESET))
.append(Component.literal(FormatTool.format1D(damage)).withStyle(ChatFormatting.GREEN)
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.empty().withStyle(ChatFormatting.RESET))
.append(Component.literal(" + " + FormatTool.format1D(explosionDamage)).withStyle(ChatFormatting.GOLD)));
}
}

View file

@ -26,9 +26,9 @@ public class ClientSecondaryCataclysmImageTooltip extends ClientEnergyImageToolt
double explosionDamage = data.explosionDamage();
return Component.translatable("des.superbwarfare.guns.damage").withStyle(ChatFormatting.GRAY)
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.empty().withStyle(ChatFormatting.RESET))
.append(Component.literal(FormatTool.format1D(damage)).withStyle(ChatFormatting.GREEN)
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.empty().withStyle(ChatFormatting.RESET))
.append(Component.literal(" + " + FormatTool.format1D(explosionDamage)).withStyle(ChatFormatting.GOLD)));
}
}

View file

@ -30,7 +30,7 @@ public class ClientSentinelImageTooltip extends ClientEnergyImageTooltip {
}
}
return Component.translatable("des.superbwarfare.guns.damage").withStyle(ChatFormatting.GRAY)
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.empty().withStyle(ChatFormatting.RESET))
.append(Component.literal(FormatTool.format1D(damage) + (extraDamage >= 0 ? " + " + FormatTool.format1D(extraDamage) : ""))
.withStyle(ChatFormatting.AQUA).withStyle(ChatFormatting.BOLD));
} else {

View file

@ -45,7 +45,7 @@ public class DogTag extends Item implements ICurioItem {
return InteractionResultHolder.success(stack);
} else {
player.openMenu(new SimpleMenuProvider((i, inventory, p) ->
new DogTagEditorMenu(i, ContainerLevelAccess.create(level, p.getOnPos()), stack), Component.literal("")));
new DogTagEditorMenu(i, ContainerLevelAccess.create(level, p.getOnPos()), stack), Component.empty()));
return InteractionResultHolder.consume(stack);
}
}

View file

@ -40,7 +40,7 @@ public class PerkItem<T extends Perk> extends Item {
};
tooltipComponents.add(Component.translatable("des.superbwarfare." + this.getPerk().descriptionId).withStyle(ChatFormatting.GRAY));
tooltipComponents.add(Component.literal(""));
tooltipComponents.add(Component.empty());
tooltipComponents.add(Component.translatable("perk.superbwarfare.slot").withStyle(ChatFormatting.GOLD)
.append(Component.translatable("perk.superbwarfare.slot_" + this.getPerk().type.getName()).withStyle(chatFormatting)));
if (this.getPerk() instanceof AmmoPerk ammoPerk) {

View file

@ -121,7 +121,7 @@ public class AmmoBox extends Item {
for (var ammo : Ammo.values()) {
tooltipComponents.add(Component.translatable("des.superbwarfare.ammo_box." + ammo.name).withStyle(ammo.color)
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.empty().withStyle(ChatFormatting.RESET))
.append(Component.literal(FormatTool.format0D(ammo.get(stack)) + ((type != ammo) ? " " : " ←-")).withStyle(ChatFormatting.BOLD)));
}
}

View file

@ -84,7 +84,7 @@ public class AureliaSceptre extends GunItem implements GeoItem {
tooltipComponents.add(Component.translatable("des.superbwarfare.aurelia_sceptre_1").withStyle(ChatFormatting.GRAY));
tooltipComponents.add(Component.translatable("des.superbwarfare.aurelia_sceptre_2").withStyle(ChatFormatting.GRAY).withStyle(ChatFormatting.ITALIC));
TooltipTool.addHideText(tooltipComponents, Component.literal(""));
TooltipTool.addHideText(tooltipComponents, Component.empty());
TooltipTool.addHideText(tooltipComponents, Component.translatable("des.superbwarfare.trachelium_3").withStyle(ChatFormatting.WHITE));
TooltipTool.addHideText(tooltipComponents, Component.translatable("des.superbwarfare.aurelia_sceptre_3").withStyle(Style.EMPTY.withColor(0xABCDEF)));
}

View file

@ -211,11 +211,11 @@ public class Trachelium extends GunItem implements GeoItem {
@Override
@ParametersAreNonnullByDefault
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> list, TooltipFlag tooltipFlag) {
list.add(Component.literal(""));
list.add(Component.empty());
list.add(Component.translatable("des.superbwarfare.trachelium_1").withStyle(ChatFormatting.GRAY).withStyle(ChatFormatting.ITALIC));
list.add(Component.translatable("des.superbwarfare.trachelium_2").withStyle(ChatFormatting.GRAY));
TooltipTool.addHideText(list, Component.literal(""));
TooltipTool.addHideText(list, Component.empty());
TooltipTool.addHideText(list, Component.translatable("des.superbwarfare.trachelium_3").withStyle(ChatFormatting.WHITE));
TooltipTool.addHideText(list, Component.translatable("des.superbwarfare.trachelium_4").withStyle(Style.EMPTY.withColor(0xF4F0FF)));
}