Search in sources :

Example 61 with Text

use of net.minecraft.text.Text in project dynmap by webbukkit.

the class FabricPlayer method sendMessage.

@Override
public void sendMessage(String msg) {
    Text ichatcomponent = new LiteralText(msg);
    player.sendSystemMessage(ichatcomponent, Util.NIL_UUID);
}
Also used : LiteralText(net.minecraft.text.LiteralText) Text(net.minecraft.text.Text) LiteralText(net.minecraft.text.LiteralText)

Example 62 with Text

use of net.minecraft.text.Text in project dynmap by webbukkit.

the class FabricServer method broadcastMessage.

@Override
public void broadcastMessage(String msg) {
    Text component = new LiteralText(msg);
    server.getPlayerManager().broadcastChatMessage(component, MessageType.SYSTEM, Util.NIL_UUID);
    Log.info(stripChatColor(msg));
}
Also used : LiteralText(net.minecraft.text.LiteralText) Text(net.minecraft.text.Text) LiteralText(net.minecraft.text.LiteralText)

Example 63 with Text

use of net.minecraft.text.Text in project dynmap by webbukkit.

the class FabricPlayer method sendMessage.

@Override
public void sendMessage(String msg) {
    Text ichatcomponent = new LiteralText(msg);
    player.sendSystemMessage(ichatcomponent, Util.NIL_UUID);
}
Also used : LiteralText(net.minecraft.text.LiteralText) Text(net.minecraft.text.Text) LiteralText(net.minecraft.text.LiteralText)

Example 64 with Text

use of net.minecraft.text.Text in project dynmap by webbukkit.

the class FabricServer method broadcastMessage.

@Override
public void broadcastMessage(String msg) {
    Text component = new LiteralText(msg);
    server.getPlayerManager().broadcastChatMessage(component, MessageType.SYSTEM, Util.NIL_UUID);
    Log.info(stripChatColor(msg));
}
Also used : LiteralText(net.minecraft.text.LiteralText) Text(net.minecraft.text.Text) LiteralText(net.minecraft.text.LiteralText)

Example 65 with Text

use of net.minecraft.text.Text in project meteor-client by MeteorDevelopment.

the class TextUtils method preOrderTraverse.

/**
 * Performs a pre-order text traversal of {@link Text} components and ref-returns a sequential list
 * of {@link ColoredText}, such that one could know the text and its color by iterating over the list.
 *
 * @param text         The text to flatten
 * @param stack        An empty stack. This is used by the recursive algorithm to keep track of the parents of the current iteration
 * @param coloredTexts The list of colored text to return
 */
private static void preOrderTraverse(Text text, Stack<ColoredText> stack, List<ColoredText> coloredTexts) {
    if (text == null)
        return;
    // Do actions here
    String textString = text.asString();
    TextColor mcTextColor = text.getStyle().getColor();
    // If mcTextColor is null, the color should be inherited from its parent. In this case, the path of the recursion is stored on the stack,
    // with the current element's parent at the top, so simply peek it if possible. If not, there is no parent element,
    // and with no color, use the default of white.
    Color textColor;
    if (mcTextColor == null) {
        if (stack.empty())
            // No color defined, use default white
            textColor = new Color(255, 255, 255);
        else
            // Use parent color
            textColor = stack.peek().getColor();
    } else {
        // Has a color defined, so use that
        // Sets alpha to max. Some damn reason Color's packed ctor is in ARGB format, not RGBA
        textColor = new Color((text.getStyle().getColor().getRgb()) | 0xFF000000);
    }
    ColoredText coloredText = new ColoredText(textString, textColor);
    coloredTexts.add(coloredText);
    // For the recursion algorithm's child, the current coloredText is its parent, so add to stack
    stack.push(coloredText);
    // Recursively traverse
    for (Text child : text.getSiblings()) preOrderTraverse(child, stack, coloredTexts);
    stack.pop();
}
Also used : Color(meteordevelopment.meteorclient.utils.render.color.Color) TextColor(net.minecraft.text.TextColor) Text(net.minecraft.text.Text) TextColor(net.minecraft.text.TextColor)

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