Search in sources :

Example 61 with TranslatableText

use of net.minecraft.text.TranslatableText in project Moonfix by Kingdom-of-Moon.

the class BooleanEntry method render.

@Override
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
    // text
    TextRenderer textRenderer = client.textRenderer;
    int posY = y + entryHeight / 2;
    textRenderer.draw(matrices, this.title, (float) x, (float) (posY - 9 / 2), 0xFFFFFF);
    // reset button
    this.reset.x = x + 260;
    this.reset.y = y;
    this.reset.active = this.config.configValue != this.config.defaultValue;
    this.reset.render(matrices, mouseX, mouseY, tickDelta);
    // toggle button
    this.toggle.x = x + 175;
    this.toggle.y = y;
    this.toggle.setMessage(new TranslatableText("gui." + ((boolean) this.config.configValue ? "yes" : "no")));
    // if setting is changed
    if ((boolean) this.config.configValue != this.initValue)
        this.toggle.setMessage(new LiteralText("").styled(ConfigManager.ACCENT_COLOR).append(this.toggle.getMessage()));
    this.toggle.render(matrices, mouseX, mouseY, tickDelta);
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) TextRenderer(net.minecraft.client.font.TextRenderer) LiteralText(net.minecraft.text.LiteralText)

Example 62 with TranslatableText

use of net.minecraft.text.TranslatableText in project Architects-Palette-Fabric by Slomaxonical-907.

the class APPlugin method addInfo.

private DefaultInformationDisplay addInfo(Item item, String key) {
    EntryStack entryStack = EntryStack.create(item);
    DefaultInformationDisplay stackInfo = DefaultInformationDisplay.createFromEntry(entryStack, new TranslatableText(item.getTranslationKey()));
    stackInfo.line(new TranslatableText("architects_palette.rei." + key));
    return stackInfo;
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) EntryStack(me.shedaniel.rei.api.EntryStack) DefaultInformationDisplay(me.shedaniel.rei.plugin.information.DefaultInformationDisplay)

Example 63 with TranslatableText

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

the class NearbyCommand method register.

public static void register() {
    ClientCommandManager.DISPATCHER.register(ClientCommandManager.literal("nearby").executes(c -> {
        MinecraftClient client = MinecraftClient.getInstance();
        if (client.player == null)
            return -1;
        Formatting headingFormatting = Formatting.byName(instance().getConfig().nearby.headingTextColour.name());
        Formatting textFormatting = Formatting.byName(instance().getConfig().nearby.playerTextColour.name());
        MsgUtils.sendPlayer("text_nearby_header", false, headingFormatting, false);
        for (int i = 0; i < instance().getNearbyPlayers().size(); i++) {
            JsonObject currentPlayer = instance().getNearbyPlayers().get(i).getAsJsonObject();
            JsonElement xElement = currentPlayer.get("x");
            JsonElement zElement = currentPlayer.get("z");
            if (xElement == null || zElement == null)
                continue;
            int distance = Math.abs(xElement.getAsInt() - (int) client.player.getX()) + Math.abs(zElement.getAsInt() - (int) client.player.getZ());
            String prefix = "";
            if (instance().getConfig().nearby.showRank) {
                if (!currentPlayer.has("town"))
                    prefix = new TranslatableText("text_nearby_rank_townless").toString();
                else
                    prefix = "(" + currentPlayer.get("rank").getAsString() + ") ";
            }
            MsgUtils.sendPlayer(prefix + currentPlayer.get("name").getAsString() + ": " + distance + "m", false, textFormatting, false);
        }
        return 1;
    }).then(ClientCommandManager.literal("refresh").executes(c -> {
        instance().scheduler().stop();
        instance().scheduler().start();
        MsgUtils.sendPlayer("msg_nearby_refresh", false, Formatting.AQUA, true);
        return 1;
    })).then(ClientCommandManager.literal("clear").executes(c -> {
        instance().setNearbyPlayers(new JsonArray());
        MsgUtils.sendPlayer("msg_nearby_clear", false, Formatting.AQUA, true);
        return 1;
    })));
}
Also used : JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) JsonArray(com.google.gson.JsonArray) Formatting(net.minecraft.util.Formatting) TranslatableText(net.minecraft.text.TranslatableText) EarthMCEssentials(net.emc.emce.EarthMCEssentials) MsgUtils(net.emc.emce.utils.MsgUtils) MinecraftClient(net.minecraft.client.MinecraftClient) EarthMCEssentials.instance(net.emc.emce.EarthMCEssentials.instance) ClientCommandManager(net.fabricmc.fabric.api.client.command.v1.ClientCommandManager) TranslatableText(net.minecraft.text.TranslatableText) JsonArray(com.google.gson.JsonArray) JsonElement(com.google.gson.JsonElement) MinecraftClient(net.minecraft.client.MinecraftClient) Formatting(net.minecraft.util.Formatting) JsonObject(com.google.gson.JsonObject)

Example 64 with TranslatableText

use of net.minecraft.text.TranslatableText in project Hypnotic-Client by Hypnotic-Development.

the class GetProtocolPacketListener method onResponse.

@Override
public void onResponse(QueryResponseS2CPacket packet) {
    protocol = packet.getServerMetadata().getVersion().getProtocolVersion();
    completed = true;
    connection.disconnect(new TranslatableText("multiplayer.status.finished"));
}
Also used : TranslatableText(net.minecraft.text.TranslatableText)

Example 65 with TranslatableText

use of net.minecraft.text.TranslatableText in project tweed-api by Siphalor.

the class TweedClothBridge method open.

public Screen open() {
    inGame = MinecraftClient.getInstance().world != null;
    parentScreen = MinecraftClient.getInstance().currentScreen;
    if (inGame) {
        boolean requiresSync = false;
        for (ConfigFileEntry entry : configFiles) {
            if (entry.configFile.getRootCategory().entryStream().anyMatch(configEntry -> configEntry.getValue().getEnvironment() != ConfigEnvironment.CLIENT)) {
                requiresSync = true;
                break;
            }
        }
        if (!requiresSync) {
            return buildScreen();
        }
        for (ConfigFileEntry entry : configFiles) {
            PacketByteBuf buffer = new PacketByteBuf(Unpooled.buffer());
            buffer.writeString(entry.configFile.getName());
            buffer.writeEnumConstant(ConfigEnvironment.UNIVERSAL);
            buffer.writeEnumConstant(ConfigScope.SMALLEST);
            buffer.writeEnumConstant(ConfigOrigin.MAIN);
            ClientSidePacketRegistry.INSTANCE.sendToServer(Tweed.REQUEST_SYNC_C2S_PACKET, buffer);
            entry.awaitSync = true;
        }
        ClientCore.scheduledClothBridge = this;
        return new NoticeScreen(() -> {
            MinecraftClient.getInstance().openScreen(parentScreen);
            ClientCore.scheduledClothBridge = null;
        }, new TranslatableText("tweed.gui.screen.syncFromServer"), new TranslatableText("tweed.gui.screen.syncFromServer.note"));
    } else {
        return buildScreen();
    }
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) NoticeScreen(net.minecraft.client.gui.screen.NoticeScreen) PacketByteBuf(net.minecraft.util.PacketByteBuf)

Aggregations

TranslatableText (net.minecraft.text.TranslatableText)161 LiteralText (net.minecraft.text.LiteralText)30 Text (net.minecraft.text.Text)19 ItemStack (net.minecraft.item.ItemStack)16 ArrayList (java.util.ArrayList)15 ButtonWidget (net.minecraft.client.gui.widget.ButtonWidget)14 List (java.util.List)12 MinecraftClient (net.minecraft.client.MinecraftClient)12 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)12 SPEInterface (eu.pb4.armorstandeditor.helpers.SPEInterface)9 LivingEntity (net.minecraft.entity.LivingEntity)9 PlayerEntity (net.minecraft.entity.player.PlayerEntity)8 ListTag (net.minecraft.nbt.ListTag)8 Formatting (net.minecraft.util.Formatting)8 BlockPos (net.minecraft.util.math.BlockPos)8 Environment (net.fabricmc.api.Environment)7 AbstractButtonWidget (net.minecraft.client.gui.widget.AbstractButtonWidget)7 Entity (net.minecraft.entity.Entity)7 Collection (java.util.Collection)6 ArmorStandPreset (eu.pb4.armorstandeditor.config.ArmorStandPreset)5