Search in sources :

Example 31 with MutableText

use of net.minecraft.text.MutableText in project meteor-rejects by AntiCope.

the class SoundLocator method printSound.

private void printSound(SoundInstance sound) {
    WeightedSoundSet soundSet = mc.getSoundManager().get(sound.getId());
    MutableText text = soundSet.getSubtitle().copy();
    text.append(String.format("%s at ", Formatting.RESET));
    Vec3d pos = new Vec3d(sound.getX(), sound.getY(), sound.getZ());
    text.append(ChatUtils.formatCoords(pos));
    text.append(String.format("%s.", Formatting.RESET));
    info(text);
}
Also used : MutableText(net.minecraft.text.MutableText) WeightedSoundSet(net.minecraft.client.sound.WeightedSoundSet) Vec3d(net.minecraft.util.math.Vec3d)

Example 32 with MutableText

use of net.minecraft.text.MutableText in project artifality by PinkGoosik.

the class LunarEnchantment method getName.

@Override
public Text getName(int level) {
    MutableText text = new TranslatableText(this.getTranslationKey());
    text.formatted(Formatting.BLUE);
    if (level != 1 || this.getMaxLevel() != 1) {
        text.append(" ").append(new TranslatableText("enchantment.level." + level));
    }
    return text;
}
Also used : MutableText(net.minecraft.text.MutableText) TranslatableText(net.minecraft.text.TranslatableText)

Example 33 with MutableText

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

the class BindsCommand method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.executes(context -> {
        // Modules
        List<Module> modules = Modules.get().getAll().stream().filter(module -> module.keybind.isSet()).collect(Collectors.toList());
        info("--- Bound Modules ((highlight)%d(default)) ---", modules.size());
        for (Module module : modules) {
            HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, getTooltip(module));
            MutableText text = new LiteralText(module.title).formatted(Formatting.WHITE);
            text.setStyle(text.getStyle().withHoverEvent(hoverEvent));
            MutableText sep = new LiteralText(" - ");
            sep.setStyle(sep.getStyle().withHoverEvent(hoverEvent));
            text.append(sep.formatted(Formatting.GRAY));
            MutableText key = new LiteralText(module.keybind.toString());
            key.setStyle(key.getStyle().withHoverEvent(hoverEvent));
            text.append(key.formatted(Formatting.GRAY));
            ChatUtils.sendMsg(text);
        }
        return SINGLE_SUCCESS;
    });
}
Also used : LiteralText(net.minecraft.text.LiteralText) ChatUtils(mathax.client.utils.misc.ChatUtils) HoverEvent(net.minecraft.text.HoverEvent) Collectors(java.util.stream.Collectors) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) CommandSource(net.minecraft.command.CommandSource) SINGLE_SUCCESS(com.mojang.brigadier.Command.SINGLE_SUCCESS) Formatting(net.minecraft.util.Formatting) List(java.util.List) Modules(mathax.client.systems.modules.Modules) MutableText(net.minecraft.text.MutableText) Command(mathax.client.systems.commands.Command) Module(mathax.client.systems.modules.Module) MutableText(net.minecraft.text.MutableText) HoverEvent(net.minecraft.text.HoverEvent) Module(mathax.client.systems.modules.Module) LiteralText(net.minecraft.text.LiteralText)

Example 34 with MutableText

use of net.minecraft.text.MutableText in project EarthMCEssentials by EarthMC-Stats.

the class ModUtils method getNearbyLongestElement.

public static int getNearbyLongestElement(JsonArray nearbyResidents) {
    if (nearbyResidents.size() == 0)
        return 0;
    int longestElement = 0;
    for (int i = 0; i < nearbyResidents.size(); i++) {
        JsonObject currentObj = nearbyResidents.get(i).getAsJsonObject();
        if (currentObj.get("name") == null || currentObj.get("x") == null || currentObj.get("z") == null)
            continue;
        if (EarthMCEssentials.instance().getClientResident() != null && currentObj.get("name").getAsString().equals(EarthMCEssentials.instance().getClientResident().getName()))
            continue;
        int distance = Math.abs(currentObj.get("x").getAsInt() - Objects.requireNonNull(getInstance().player).getBlockX()) + Math.abs(currentObj.get("z").getAsInt() - getInstance().player.getBlockZ());
        String prefix = "";
        if (EarthMCEssentials.instance().getConfig().nearby.showRank) {
            if (!currentObj.has("town"))
                prefix = "(Townless) ";
            else
                prefix = "(" + currentObj.get("rank").getAsString() + ") ";
        }
        MutableText nearbyText = new TranslatableText(prefix + currentObj.get("name").getAsString() + ": " + distance + "m");
        longestElement = Math.max(getTextWidth(nearbyText), longestElement);
    }
    return longestElement;
}
Also used : MutableText(net.minecraft.text.MutableText) TranslatableText(net.minecraft.text.TranslatableText) JsonObject(com.google.gson.JsonObject)

Example 35 with MutableText

use of net.minecraft.text.MutableText in project Essential-Commands by John-Paul-R.

the class RealNameCommand method run.

@Override
public int run(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
    String nicknameStr = StringArgumentType.getString(context, "player_nickname");
    List<PlayerData> nicknamePlayers = PlayerDataManager.getInstance().getPlayerDataMatchingNickname(nicknameStr);
    MutableText responseText = new LiteralText("");
    // If no players matched the provided nickname
    if (nicknamePlayers.size() == 0) {
        responseText.append(ECText.getInstance().getText("cmd.realname.feedback.none_match").setStyle(CONFIG.FORMATTING_DEFAULT.getValue())).append(new LiteralText(nicknameStr).setStyle(CONFIG.FORMATTING_ACCENT.getValue())).append(ECText.getInstance().getText("generic.quote_fullstop").setStyle(CONFIG.FORMATTING_DEFAULT.getValue()));
    } else {
        responseText.append(ECText.getInstance().getText("cmd.realname.feedback.matching.1").setStyle(CONFIG.FORMATTING_DEFAULT.getValue())).append(new LiteralText(nicknameStr).setStyle(CONFIG.FORMATTING_ACCENT.getValue())).append(ECText.getInstance().getText("cmd.realname.feedback.matching.2").setStyle(CONFIG.FORMATTING_DEFAULT.getValue()));
        for (PlayerData nicknamePlayer : nicknamePlayers) {
            responseText.append("\n  ");
            responseText.append(nicknamePlayer.getPlayer().getGameProfile().getName());
        }
    }
    context.getSource().sendFeedback(responseText, CONFIG.BROADCAST_TO_OPS.getValue());
    return 0;
}
Also used : MutableText(net.minecraft.text.MutableText) PlayerData(com.fibermc.essentialcommands.PlayerData) 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