Search in sources :

Example 11 with MutableText

use of net.minecraft.text.MutableText in project BedrockIfy by juancarloscp52.

the class Overlay method renderPositionText.

private void renderPositionText(MatrixStack matrixStack) {
    BedrockifySettings settings = Bedrockify.getInstance().settings;
    int screenBorder = settings.getScreenSafeArea();
    int posY = settings.getPositionHUDHeight();
    if (!settings.isShowPositionHUDEnabled())
        return;
    BlockPos blockPos = Objects.requireNonNull(this.client.getCameraEntity(), "Camera Entity cannot be null.").getBlockPos();
    MutableText position = new TranslatableText("bedrockify.hud.position").append(new LiteralText(" " + blockPos.getX() + ", " + blockPos.getY() + ", " + blockPos.getZ()));
    if (settings.getFPSHUDoption() == 1)
        position.append(" ").append(fps);
    int positionWidth = client.textRenderer.getWidth(position);
    fill(matrixStack, textPosX + screenBorder, posY + screenBorder, textPosX + positionWidth + 6 + screenBorder, posY + 10 + screenBorder, MathHelper.ceil((255.0D * client.options.textBackgroundOpacity)) << 24);
    client.textRenderer.drawWithShadow(matrixStack, position, textPosX + 3 + screenBorder, posY + 1 + screenBorder, 16777215);
}
Also used : MutableText(net.minecraft.text.MutableText) TranslatableText(net.minecraft.text.TranslatableText) BedrockifySettings(me.juancarloscp52.bedrockify.BedrockifySettings) BlockPos(net.minecraft.util.math.BlockPos) LiteralText(net.minecraft.text.LiteralText)

Example 12 with MutableText

use of net.minecraft.text.MutableText in project pingspam by BasiqueEvangelist.

the class NotificationsCommand method showNotifications.

public static int showNotifications(CommandContext<ServerCommandSource> ctx) throws CommandSyntaxException {
    ServerCommandSource src = ctx.getSource();
    List<Text> notifs = PlayerUtils.getUnreadPingsFor(src.getPlayer());
    if (!notifs.isEmpty()) {
        MutableText response = new LiteralText("You have " + notifs.size() + " unread message" + (notifs.size() != 1 ? "s" : "") + ":").formatted(Formatting.GREEN);
        for (Text notif : notifs) {
            response.append(new LiteralText("\n- ").formatted(Formatting.WHITE).append(notif));
        }
        src.sendFeedback(response, false);
        notifs.clear();
        return 1;
    } else {
        src.sendFeedback(new LiteralText("You have no unread messages.").formatted(Formatting.GREEN), false);
        return 0;
    }
}
Also used : MutableText(net.minecraft.text.MutableText) LiteralText(net.minecraft.text.LiteralText) MutableText(net.minecraft.text.MutableText) Text(net.minecraft.text.Text) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) LiteralText(net.minecraft.text.LiteralText)

Example 13 with MutableText

use of net.minecraft.text.MutableText in project LittleMaidReBirth-Fabric by SistrScarlet.

the class LittleMaidScreen method getStateText.

public Text getStateText() {
    MutableText stateText = new TranslatableText("state." + LittleMaidReBirthMod.MODID + "." + openAt.getMovingState().getName());
    openAt.getModeName().ifPresent(modeName -> stateText.append(" : ").append(new TranslatableText("mode." + LittleMaidReBirthMod.MODID + "." + modeName)));
    return stateText;
}
Also used : MutableText(net.minecraft.text.MutableText) TranslatableText(net.minecraft.text.TranslatableText)

Example 14 with MutableText

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

the class DiscordBotImpl method announcePossibleStream.

private void announcePossibleStream(@Nullable GuildVoiceState voice) {
    if (voice != null && voice.getChannel() != null && voice.isStream() && isOnline(voice.getMember().getUser())) {
        MutableText text = new LiteralText("").append(discordUserToMinecraft(voice.getMember().getUser(), getGuild(), false)).append(" is now streaming to ").append(discordChannelToMinecraft(voice.getChannel()));
        broadcastNoMirror(text);
    }
}
Also used : MutableText(net.minecraft.text.MutableText) LiteralText(net.minecraft.text.LiteralText)

Example 15 with MutableText

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

the class DiscordBotImpl method onMessageReceived.

@Override
public void onMessageReceived(MessageReceivedEvent event) {
    if (config.adminChannelId == event.getChannel().getIdLong() && event.getMessage().getContentRaw().startsWith("!") && handleAdminDiscordCommand(event.getMessage())) {
        return;
    }
    if (config.allowsMessagesFrom(event.getChannel(), event.getAuthor())) {
        if (event.getMessage().getContentRaw().startsWith("!") && handleNormalDiscordCommand(event.getMessage())) {
            return;
        }
        Message msg = event.getMessage();
        LiteralText root = new LiteralText("");
        root.append("<");
        root.append(discordUserToMinecraft(msg.getAuthor(), getGuild(), false));
        Message refMsg = msg.getReferencedMessage();
        if (refMsg != null) {
            MutableText arrow = new LiteralText("[->]");
            if (!refMsg.getContentRaw().isBlank()) {
                arrow.setStyle(Style.EMPTY.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, discordMessageToMinecraft(refMsg))));
            }
            root.append(" ").append(arrow).append(" ").append(discordUserToMinecraft(refMsg.getAuthor(), getGuild(), false));
        }
        root.append(">");
        if (!msg.getContentRaw().isEmpty()) {
            root.append(" ");
            root.append(discordMessageToMinecraft(msg));
        }
        if (!msg.getAttachments().isEmpty()) {
            for (Message.Attachment attachment : msg.getAttachments()) {
                root.append(" [");
                LiteralText fileType = null;
                if (attachment.isImage()) {
                    fileType = new LiteralText("image");
                } else if (attachment.isVideo()) {
                    fileType = new LiteralText("video");
                } else {
                    @Nullable String mediaType = attachment.getContentType();
                    if (mediaType != null) {
                        if (mediaType.startsWith("text")) {
                            fileType = new LiteralText("text");
                        } else if (mediaType.startsWith("audio")) {
                            fileType = new LiteralText("audio");
                        }
                    }
                    if (fileType == null) {
                        fileType = new LiteralText("attachment");
                    }
                }
                ClickEvent click = new ClickEvent(ClickEvent.Action.OPEN_URL, attachment.getUrl());
                HoverEvent hover = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("").append(attachment.getFileName()).append("\n").append(new LiteralText(readableFileSize(attachment.getSize()))));
                fileType.setStyle(Style.EMPTY.withClickEvent(click).withHoverEvent(hover));
                root.append(fileType);
                root.append("]");
            }
        }
        this.broadcastNoMirror(root);
    }
}
Also used : MutableText(net.minecraft.text.MutableText) HoverEvent(net.minecraft.text.HoverEvent) GameMessageConverter.convertGameMessage(selic.re.discordbridge.GameMessageConverter.convertGameMessage) Message(net.dv8tion.jda.api.entities.Message) ClickEvent(net.minecraft.text.ClickEvent) LiteralText(net.minecraft.text.LiteralText)

Aggregations

MutableText (net.minecraft.text.MutableText)40 LiteralText (net.minecraft.text.LiteralText)34 HoverEvent (net.minecraft.text.HoverEvent)8 ClickEvent (net.minecraft.text.ClickEvent)7 Text (net.minecraft.text.Text)7 Formatting (net.minecraft.util.Formatting)6 List (java.util.List)5 TranslatableText (net.minecraft.text.TranslatableText)5 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)4 CommandSource (net.minecraft.command.CommandSource)3 JsonObject (com.google.gson.JsonObject)2 JsonPrimitive (com.google.gson.JsonPrimitive)2 SINGLE_SUCCESS (com.mojang.brigadier.Command.SINGLE_SUCCESS)2 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)2 BufferedReader (java.io.BufferedReader)2 FileReader (java.io.FileReader)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Locale (java.util.Locale)2