Search in sources :

Example 51 with Text

use of net.minecraft.text.Text in project mineclub-expanded by Blobanium.

the class CommandParser method registerCommand.

public static void registerCommand() {
    ClientCommandManager.DISPATCHER.register(ClientCommandManager.literal("mcex").executes(context -> {
        context.getSource().sendFeedback(Text.Serializer.fromJson("[\"\",{\"text\":\"Mineclub Expanded\\n\"},{\"text\":\"Click here to see the full set of commands\",\"color\":\"light_purple\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://github.com/Blobanium/mineclub-expanded/wiki/List-Of-Commands\"}}]"));
        return 0;
    }));
    ClientCommandManager.DISPATCHER.register(ClientCommandManager.literal("mcex").then(ClientCommandManager.literal("getminingvalue").executes(context -> {
        context.getSource().sendFeedback(new LiteralText(GetMiningValue.miningValueResponseString(false)));
        return 0;
    })));
    ClientCommandManager.DISPATCHER.register(ClientCommandManager.literal("mcex").then(ClientCommandManager.literal("getminingvalue").then(ClientCommandManager.literal("deatiled").executes(context -> {
        context.getSource().sendFeedback(new LiteralText(GetMiningValue.miningValueResponseString(true)));
        return 0;
    }))));
    ClientCommandManager.DISPATCHER.register(ClientCommandManager.literal("mcex").then(ClientCommandManager.literal("yourmom").executes(context -> {
        context.getSource().sendFeedback(new LiteralText("No your mom."));
        return 0;
    })));
}
Also used : LiteralText(net.minecraft.text.LiteralText) Text(net.minecraft.text.Text) GetMiningValue(io.github.blobanium.mineclubexpanded.util.command.commnads.GetMiningValue) ClientCommandManager(net.fabricmc.fabric.api.client.command.v1.ClientCommandManager) LiteralText(net.minecraft.text.LiteralText)

Example 52 with Text

use of net.minecraft.text.Text in project quilt-standard-libraries by QuiltMC.

the class ClientCommandInternals method getErrorMessage.

/**
 * Analogous to {@code CommandSuggestor#formatException}, but returns a {@link Text} rather than an
 * {@link net.minecraft.text.OrderedText OrderedText}.
 *
 * @param e the exception to get the error message from
 *
 * @return the error message as a {@link Text}
 */
private static Text getErrorMessage(CommandSyntaxException e) {
    Text message = Texts.toText(e.getRawMessage());
    String context = e.getContext();
    return context != null ? new TranslatableText("command.context.parse_error", message, context) : message;
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) LiteralText(net.minecraft.text.LiteralText) TranslatableText(net.minecraft.text.TranslatableText) Text(net.minecraft.text.Text)

Example 53 with Text

use of net.minecraft.text.Text in project quilt-standard-libraries by QuiltMC.

the class NetworkingPlayPacketClientTest method receive.

private void receive(ClientPlayNetworkHandler handler, PacketSender sender, MinecraftClient client, PacketByteBuf buf) {
    Text text = buf.readText();
    client.execute(() -> client.inGameHud.setOverlayMessage(text, true));
}
Also used : Text(net.minecraft.text.Text)

Example 54 with Text

use of net.minecraft.text.Text in project AutoResetMod by DuncanRuns.

the class OptionsScreenMixin method addStopRunButtonMixin.

@Inject(method = "init", at = @At("TAIL"))
private void addStopRunButtonMixin(CallbackInfo info) {
    if (AutoReset.isPlaying) {
        // Get menu.stop_resets text or set to default
        Text text;
        if (Language.getInstance().get("menu.stop_resets").equals("menu.stop_resets")) {
            text = new LiteralText("Stop Resets & Quit");
        } else {
            text = new TranslatableText("menu.stop_resets");
        }
        // Add button to disable the auto reset and quit
        this.addButton(new ButtonWidget(0, this.height - 20, 100, 20, text, (buttonWidget) -> {
            AutoReset.isPlaying = false;
            buttonWidget.active = false;
            this.client.world.disconnect();
            this.client.disconnect(new SaveLevelScreen(new TranslatableText("menu.savingLevel")));
            this.client.openScreen(new TitleScreen());
        }));
    }
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) LiteralText(net.minecraft.text.LiteralText) OptionsScreen(net.minecraft.client.gui.screen.options.OptionsScreen) Inject(org.spongepowered.asm.mixin.injection.Inject) TranslatableText(net.minecraft.text.TranslatableText) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) AutoReset(me.duncanruns.autoreset.AutoReset) CallbackInfo(org.spongepowered.asm.mixin.injection.callback.CallbackInfo) TitleScreen(net.minecraft.client.gui.screen.TitleScreen) Screen(net.minecraft.client.gui.screen.Screen) Language(net.minecraft.util.Language) Mixin(org.spongepowered.asm.mixin.Mixin) SaveLevelScreen(net.minecraft.client.gui.screen.SaveLevelScreen) Text(net.minecraft.text.Text) At(org.spongepowered.asm.mixin.injection.At) SaveLevelScreen(net.minecraft.client.gui.screen.SaveLevelScreen) LiteralText(net.minecraft.text.LiteralText) TranslatableText(net.minecraft.text.TranslatableText) Text(net.minecraft.text.Text) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) LiteralText(net.minecraft.text.LiteralText) TitleScreen(net.minecraft.client.gui.screen.TitleScreen) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 55 with Text

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

the class FabricCommandSender method sendMessage.

@Override
public void sendMessage(String msg) {
    if (sender != null) {
        Text ichatcomponent = new LiteralText(msg);
        sender.sendFeedback(ichatcomponent, false);
    }
}
Also used : LiteralText(net.minecraft.text.LiteralText) Text(net.minecraft.text.Text) 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