Search in sources :

Example 41 with Text

use of net.minecraft.text.Text in project JexClient by DustinRepo.

the class Messager method actionBar.

public static void actionBar(String message) {
    MinecraftClient minecraftClient = MinecraftClient.getInstance();
    Text text = new LiteralText(message);
    minecraftClient.inGameHud.setOverlayMessage(text, false);
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) LiteralText(net.minecraft.text.LiteralText) Text(net.minecraft.text.Text) LiteralText(net.minecraft.text.LiteralText)

Example 42 with Text

use of net.minecraft.text.Text in project ViaFabric by ViaVersion.

the class MixinServerEntry method addServerVer.

@Redirect(method = "render", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;setTooltip(Ljava/util/List;)V"))
private void addServerVer(MultiplayerScreen multiplayerScreen, List<Text> tooltipText) {
    ProtocolVersion proto = ProtocolVersion.getProtocol(((ViaServerInfo) this.server).getViaServerVer());
    List<Text> lines = new ArrayList<>(tooltipText);
    lines.add(new TranslatableText("gui.ping_version.translated", proto.getName()));
    multiplayerScreen.setTooltip(lines);
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) ArrayList(java.util.ArrayList) TranslatableText(net.minecraft.text.TranslatableText) Text(net.minecraft.text.Text) ProtocolVersion(com.viaversion.viaversion.api.protocol.version.ProtocolVersion) Redirect(org.spongepowered.asm.mixin.injection.Redirect)

Example 43 with Text

use of net.minecraft.text.Text in project mc-discord-bridge by Selicre.

the class DiscordFormattingConverter method popFormatting.

private void popFormatting(ActiveFormatting entry) {
    formattingStack.remove(formattingStack.size() - 1);
    activeFormatting.remove(entry.formatting);
    LiteralText text = new LiteralText(textBuffer.toString());
    textBuffer.setLength(0);
    text.setStyle(entry.formatting.getStyle(text));
    for (Text child : entry.children) {
        text.append(child);
    }
    addText(text);
}
Also used : LiteralText(net.minecraft.text.LiteralText) Text(net.minecraft.text.Text) LiteralText(net.minecraft.text.LiteralText)

Example 44 with Text

use of net.minecraft.text.Text in project HWG by cybercat-mods.

the class FlareGunItem method appendTooltip.

@Environment(EnvType.CLIENT)
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context) {
    List<ItemStack> list = getProjectiles(stack);
    if (isCharged(stack) && !list.isEmpty()) {
        ItemStack itemStack = (ItemStack) list.get(0);
        tooltip.add((new TranslatableText("Ammo")).append(" ").append(itemStack.toHoverableText()));
        if (context.isAdvanced() && itemStack.getItem() == FLARE) {
            List<Text> list2 = Lists.newArrayList();
            HWGItems.G_EMP.appendTooltip(itemStack, world, list2, context);
            if (!list2.isEmpty()) {
                for (int i = 0; i < list2.size(); ++i) {
                    list2.set(i, (new LiteralText("  ")).append((Text) list2.get(i)).formatted(Formatting.GRAY));
                }
                tooltip.addAll(list2);
            }
        }
    }
    tooltip.add(new TranslatableText("hwg.ammo.reloadflares").formatted(Formatting.ITALIC));
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) LiteralText(net.minecraft.text.LiteralText) TranslatableText(net.minecraft.text.TranslatableText) Text(net.minecraft.text.Text) ItemStack(net.minecraft.item.ItemStack) LiteralText(net.minecraft.text.LiteralText) Environment(net.fabricmc.api.Environment)

Example 45 with Text

use of net.minecraft.text.Text in project Client by MatHax.

the class BetterTab method getPlayerName.

public Text getPlayerName(PlayerListEntry playerListEntry) {
    Text name;
    Color color = null;
    name = playerListEntry.getDisplayName();
    if (name == null) {
        /*if (mc.getSession().getUsername().equals("Matejko06"))
                name = new LiteralText("  " + playerListEntry.getProfile().getName());
            else*/
        name = new LiteralText(playerListEntry.getProfile().getName());
    }
    if (playerListEntry.getProfile().getId().toString().equals(mc.player.getGameProfile().getId().toString()) && self.get()) {
        color = selfColor.get();
    } else if (friends.get() && Friends.get().get(playerListEntry.getProfile().getName()) != null) {
        Friend friend = Friends.get().get(playerListEntry.getProfile().getName());
        if (friend != null)
            color = Friends.get().color;
    } else if (enemies.get() && Enemies.get().get(playerListEntry.getProfile().getName()) != null) {
        Enemy enemy = Enemies.get().get(playerListEntry.getProfile().getName());
        if (enemy != null)
            color = Enemies.get().color;
    }
    if (color != null) {
        String nameString = name.getString();
        for (Formatting format : Formatting.values()) {
            if (format.isColor())
                nameString = nameString.replace(format.toString(), "");
        }
        name = new LiteralText(nameString).setStyle(name.getStyle().withColor(new TextColor(color.getPacked())));
    }
    return name;
}
Also used : Friend(mathax.client.systems.friends.Friend) SettingColor(mathax.client.utils.render.color.SettingColor) TextColor(net.minecraft.text.TextColor) Color(mathax.client.utils.render.color.Color) Enemy(mathax.client.systems.enemies.Enemy) Formatting(net.minecraft.util.Formatting) LiteralText(net.minecraft.text.LiteralText) Text(net.minecraft.text.Text) TextColor(net.minecraft.text.TextColor) LiteralText(net.minecraft.text.LiteralText)

Aggregations

Text (net.minecraft.text.Text)108 LiteralText (net.minecraft.text.LiteralText)70 TranslatableText (net.minecraft.text.TranslatableText)35 Inject (org.spongepowered.asm.mixin.injection.Inject)14 ArrayList (java.util.ArrayList)13 ItemStack (net.minecraft.item.ItemStack)12 MinecraftClient (net.minecraft.client.MinecraftClient)11 MutableText (net.minecraft.text.MutableText)10 Formatting (net.minecraft.util.Formatting)10 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)9 List (java.util.List)7 ServerCommandSource (net.minecraft.server.command.ServerCommandSource)6 HoverEvent (net.minecraft.text.HoverEvent)6 TextColor (net.minecraft.text.TextColor)6 Mixin (org.spongepowered.asm.mixin.Mixin)6 At (org.spongepowered.asm.mixin.injection.At)6 ButtonWidget (net.minecraft.client.gui.widget.ButtonWidget)5 Redirect (org.spongepowered.asm.mixin.injection.Redirect)5 JsonObject (com.google.gson.JsonObject)4 GameProfile (com.mojang.authlib.GameProfile)4