Search in sources :

Example 71 with Text

use of net.minecraft.text.Text in project SpeedRunIGT by RedLime.

the class SpeedRunOptionScreen method getToolTip.

public ArrayList<Text> getToolTip(int mouseX, int mouseY) {
    ArrayList<Text> tooltipList = new ArrayList<>();
    Optional<Element> e = buttonListWidget.hoveredElement(mouseX, mouseY);
    if (e.isPresent()) {
        Element element = e.get();
        if (element instanceof ButtonScrollListWidget.Entry) {
            ButtonScrollListWidget.Entry entry = (ButtonScrollListWidget.Entry) element;
            AbstractButtonWidget buttonWidget = entry.getButtonWidget();
            if (tooltips.containsKey(buttonWidget)) {
                String text = tooltips.get(buttonWidget).get();
                for (String s : text.split("\n")) {
                    tooltipList.add(new LiteralText(s));
                }
                return tooltipList;
            }
        }
    }
    if (SpeedRunIGTInfoScreen.UPDATE_STATUS == SpeedRunIGTInfoScreen.UpdateStatus.OUTDATED) {
        tooltipList.add(new TranslatableText("speedrunigt.message.update_found"));
    }
    return tooltipList;
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) Element(net.minecraft.client.gui.Element) LiteralText(net.minecraft.text.LiteralText) TranslatableText(net.minecraft.text.TranslatableText) Text(net.minecraft.text.Text) AbstractButtonWidget(net.minecraft.client.gui.widget.AbstractButtonWidget) LiteralText(net.minecraft.text.LiteralText)

Example 72 with Text

use of net.minecraft.text.Text in project Rug by RubixDev.

the class SudoCommand method register.

public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
    LiteralArgumentBuilder<ServerCommandSource> command = literal("sudo").requires((player) -> SettingsManager.canUseCommand(player, RugSettings.commandSudo)).then(argument("player", StringArgumentType.word()).suggests(((context, builder) -> suggestMatching(getPlayers(context.getSource()), builder))).then(literal("chat").then(argument("message", StringArgumentType.greedyString()).executes(context -> {
        String targetPlayerName = StringArgumentType.getString(context, "player");
        MinecraftServer server = context.getSource().getServer();
        PlayerManager playerManager = server.getPlayerManager();
        ServerPlayerEntity targetPlayer = playerManager.getPlayer(targetPlayerName);
        if (targetPlayer == null) {
            context.getSource().sendError(new LiteralText("Targeted Player could not be found"));
            return 0;
        }
        Text text = new TranslatableText("chat.type.text", targetPlayerName, StringArgumentType.getString(context, "message"));
        playerManager.broadcast(text, MessageType.CHAT, targetPlayer.getUuid());
        return 1;
    }))).then(literal("command").redirect(dispatcher.getRoot(), context -> {
        String targetPlayerName = StringArgumentType.getString(context, "player");
        MinecraftServer server = context.getSource().getServer();
        ServerPlayerEntity player = server.getPlayerManager().getPlayer(targetPlayerName);
        if (player == null) {
            Message errorMessage = new LiteralText("Targeted player could not be found");
            throw new CommandSyntaxException(new SimpleCommandExceptionType(errorMessage), errorMessage);
        }
        return player.getCommandSource();
    })));
    dispatcher.register(command);
}
Also used : LiteralText(net.minecraft.text.LiteralText) CommandDispatcher(com.mojang.brigadier.CommandDispatcher) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) Collection(java.util.Collection) SettingsManager(carpet.settings.SettingsManager) MessageType(net.minecraft.network.MessageType) PlayerManager(net.minecraft.server.PlayerManager) TranslatableText(net.minecraft.text.TranslatableText) RugSettings(de.rubixdev.rug.RugSettings) CommandManager.literal(net.minecraft.server.command.CommandManager.literal) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) SimpleCommandExceptionType(com.mojang.brigadier.exceptions.SimpleCommandExceptionType) CommandManager.argument(net.minecraft.server.command.CommandManager.argument) StringArgumentType(com.mojang.brigadier.arguments.StringArgumentType) MinecraftServer(net.minecraft.server.MinecraftServer) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) CommandSource.suggestMatching(net.minecraft.command.CommandSource.suggestMatching) Message(com.mojang.brigadier.Message) Text(net.minecraft.text.Text) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) TranslatableText(net.minecraft.text.TranslatableText) Message(com.mojang.brigadier.Message) PlayerManager(net.minecraft.server.PlayerManager) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) LiteralText(net.minecraft.text.LiteralText) TranslatableText(net.minecraft.text.TranslatableText) Text(net.minecraft.text.Text) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) MinecraftServer(net.minecraft.server.MinecraftServer) SimpleCommandExceptionType(com.mojang.brigadier.exceptions.SimpleCommandExceptionType) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) LiteralText(net.minecraft.text.LiteralText)

Example 73 with Text

use of net.minecraft.text.Text in project Skyblocker by LifeIsAParadox.

the class ItemUtils method getTooltipStrings.

public static List<String> getTooltipStrings(ItemStack item) {
    List<Text> lines = getTooltip(item);
    List<String> list = new ArrayList<>();
    for (Text line : lines) {
        String string = line.getString();
        if (!WHITESPACES.matcher(string).matches())
            list.add(string);
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) Text(net.minecraft.text.Text)

Example 74 with Text

use of net.minecraft.text.Text in project Skyblocker by LifeIsAParadox.

the class ItemListWidget method render.

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
    if (this.isOpen()) {
        matrices.push();
        matrices.translate(0.0D, 0.0D, 100.0D);
        RenderSystem.setShader(GameRenderer::getPositionTexShader);
        RenderSystem.setShaderTexture(0, TEXTURE);
        RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
        this.searchField = ((RecipeBookWidgetAccessor) this).getSearchField();
        int i = (this.parentWidth - 147) / 2 - this.leftOffset;
        int j = (this.parentHeight - 166) / 2;
        this.drawTexture(matrices, i, j, 1, 1, 147, 166);
        this.searchField = ((RecipeBookWidgetAccessor) this).getSearchField();
        if (!this.searchField.isFocused() && this.searchField.getText().isEmpty()) {
            Text hintText = (new TranslatableText("gui.recipebook.search_hint")).formatted(Formatting.ITALIC).formatted(Formatting.GRAY);
            drawTextWithShadow(matrices, this.client.textRenderer, hintText, i + 25, j + 14, -1);
        } else {
            this.searchField.render(matrices, mouseX, mouseY, delta);
        }
        this.updateSearchResult();
        this.results.render(matrices, mouseX, mouseY, delta);
        matrices.pop();
    }
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) GameRenderer(net.minecraft.client.render.GameRenderer) TranslatableText(net.minecraft.text.TranslatableText) Text(net.minecraft.text.Text)

Example 75 with Text

use of net.minecraft.text.Text in project Skyblocker by LifeIsAParadox.

the class SearchResultsWidget method render.

public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
    RenderSystem.disableDepthTest();
    if (this.displayRecipes) {
        String craftText = this.recipeResults.get(this.currentPage).text;
        this.client.textRenderer.drawWithShadow(matrices, craftText, this.parentX + 11, this.parentY + 31, 0xffffffff);
        Text resultText = this.recipeResults.get(this.currentPage).result.getName();
        this.client.textRenderer.drawWithShadow(matrices, resultText, this.parentX + 11, this.parentY + 43, 0xffffffff);
        this.client.textRenderer.drawWithShadow(matrices, "▶", this.parentX + 96, this.parentY + 90, 0xaaffffff);
    }
    for (ResultButtonWidget button : resultButtons) button.render(matrices, mouseX, mouseY, delta);
    if (this.pageCount > 1) {
        String string = (this.currentPage + 1) + "/" + this.pageCount;
        int dx = this.client.textRenderer.getWidth(string) / 2;
        this.client.textRenderer.draw(matrices, string, this.parentX - dx + 73, this.parentY + 141, -1);
    }
    if (this.prevPageButton.active)
        this.prevPageButton.render(matrices, mouseX, mouseY, delta);
    if (this.nextPageButton.active)
        this.nextPageButton.render(matrices, mouseX, mouseY, delta);
    RenderSystem.enableDepthTest();
}
Also used : Text(net.minecraft.text.Text)

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