Search in sources :

Example 56 with TranslatableText

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

the class LevelLoadingScreenMixin method render.

/**
 * Draws the loading screen widget and allows to toggle the chunk map loading widget.
 */
@Inject(method = "render", at = @At("HEAD"), cancellable = true)
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo info) {
    if (!Bedrockify.getInstance().settings.isLoadingScreenEnabled())
        return;
    this.renderBackground(matrices);
    int xPosition = this.width / 2;
    int yPosition = this.height / 2;
    LoadingScreenWidget.getInstance().render(matrices, xPosition, yPosition, new TranslatableText("menu.generatingLevel"), null, this.progressProvider.getProgressPercentage());
    String string = MathHelper.clamp(this.progressProvider.getProgressPercentage(), 0, 100) + "%";
    long l = Util.getMeasuringTimeMs();
    if (l - this.field_19101 > 2000L) {
        this.field_19101 = l;
        NarratorManager.INSTANCE.narrate((new TranslatableText("narrator.loading", new Object[] { string })).getString());
    }
    if (Bedrockify.getInstance().settings.isShowChunkMapEnabled())
        drawChunkMap(matrices, this.progressProvider, xPosition, yPosition + yPosition / 2 + 89 / 4, 1, 0);
    info.cancel();
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 57 with TranslatableText

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

the class ChatHudMixin method render.

/**
 * Use bedrock-like chat if enabled.
 */
@Inject(method = "render", at = @At("HEAD"), cancellable = true)
private void render(MatrixStack matrixStack, int ticks, CallbackInfo info) {
    if (!settings.isBedrockChatEnabled())
        return;
    if (!this.isChatHidden()) {
        this.processMessageQueue();
        int visibleLines = Math.min(this.getVisibleLineCount(), this.getAvailableLines());
        int visibleMessagesCount = this.visibleMessages.size();
        if (visibleMessagesCount > 0) {
            boolean isChatFocused = this.isChatFocused();
            int posY = settings.getPositionHUDHeight() + (settings.getPositionHUDHeight() < 50 ? 50 : 0) + (settings.isShowPositionHUDEnabled() ? 10 : 0) + (settings.getFPSHUDoption() == 2 ? 10 : 0) + settings.getScreenSafeArea();
            double chatScale = this.getChatScale();
            int scaledChatWidth = MathHelper.ceil((double) this.getWidth() / chatScale);
            RenderSystem.pushMatrix();
            RenderSystem.translatef(settings.getScreenSafeArea(), (float) (48 - MinecraftClient.getInstance().getWindow().getScaledHeight() + (counter1 * (9.0D * chatScale * (this.client.options.chatLineSpacing + 1.0D)))) + posY, 0.0F);
            RenderSystem.scaled(chatScale, chatScale, 1.0D);
            double textOpacity = this.client.options.chatOpacity * 0.9D + 0.1D;
            double backgroundOpacity = this.client.options.textBackgroundOpacity;
            double chatLineSpacing1 = 9.0D * (this.client.options.chatLineSpacing + 1.0D);
            double chatLineSpacing2 = -8.0D * (this.client.options.chatLineSpacing + 1.0D) + 4.0D * this.client.options.chatLineSpacing;
            // Shown messages
            counter1 = 0;
            for (int i = 0; i + this.scrolledLines < this.visibleMessages.size() && i < visibleLines; ++i) {
                ChatHudLine<OrderedText> chatHudLine = this.visibleMessages.get(i + this.scrolledLines);
                if (chatHudLine != null) {
                    int ticksSinceCreation;
                    ticksSinceCreation = ticks - chatHudLine.getCreationTick();
                    if (ticksSinceCreation < 200 || isChatFocused) {
                        double opacityMultiplayer = isChatFocused ? 1.0D : getMessageOpacityMultiplier(ticksSinceCreation);
                        int finalTextOpacity = (int) (255.0D * opacityMultiplayer * textOpacity);
                        int finalBackgroundOpacity = (int) (255.0D * opacityMultiplayer * backgroundOpacity);
                        ++counter1;
                        if (finalTextOpacity > 3) {
                            double currentMessageHeight = (double) (-i) * chatLineSpacing1;
                            matrixStack.push();
                            matrixStack.translate(0, 0, 0);
                            fill(matrixStack, 0, (int) currentMessageHeight, scaledChatWidth + 4, (int) (currentMessageHeight - chatLineSpacing1), finalBackgroundOpacity << 24);
                            RenderSystem.enableBlend();
                            matrixStack.translate(0, 0, 0);
                            this.client.textRenderer.drawWithShadow(matrixStack, chatHudLine.getText(), 2F, (float) ((int) (currentMessageHeight + chatLineSpacing2)), 16777215 + (finalTextOpacity << 24));
                            RenderSystem.disableAlphaTest();
                            RenderSystem.disableBlend();
                            matrixStack.pop();
                        }
                    }
                }
            }
            // Unread Messages:
            if (!this.messageQueue.isEmpty()) {
                int textOpacityFinal = (int) (128.0D * textOpacity);
                int backgroundOpacityFinal = (int) (255.0D * backgroundOpacity);
                matrixStack.push();
                matrixStack.translate(0.0D, 0.0D, 50.0D);
                fill(matrixStack, -2, 0, scaledChatWidth + 4, 9, backgroundOpacityFinal << 24);
                RenderSystem.enableBlend();
                matrixStack.translate(0.0D, 0.0D, 50.0D);
                this.client.textRenderer.drawWithShadow(matrixStack, new TranslatableText("chat.queue", this.messageQueue.size()), 2F, 1.0F, 16777215 + (textOpacityFinal << 24));
                matrixStack.pop();
                RenderSystem.disableAlphaTest();
                RenderSystem.disableBlend();
            }
            if (isChatFocused) {
                int textSize = 9;
                RenderSystem.translatef(-3.0F, 0.0F, 0.0F);
                int x = visibleMessagesCount * textSize + visibleMessagesCount;
                int renderedMessages = counter1 * textSize + counter1;
                int z = this.scrolledLines * renderedMessages / visibleMessagesCount;
                int aa = renderedMessages * renderedMessages / x;
                if (x != renderedMessages) {
                    int alpha = z > 0 ? 170 : 96;
                    int color = this.hasUnreadNewMessages ? 13382451 : 3355562;
                    fill(matrixStack, 2, -z, 2, -z - aa, color + (alpha << 24));
                    fill(matrixStack, 4, -z, 1, -z - aa, 13421772 + (alpha << 24));
                }
            }
            RenderSystem.popMatrix();
        }
    }
    info.cancel();
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) OrderedText(net.minecraft.text.OrderedText) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 58 with TranslatableText

use of net.minecraft.text.TranslatableText in project AdvancedChatBox by DarkKronicle.

the class ChatSuggestorGui method formatException.

private static OrderedText formatException(CommandSyntaxException exception) {
    Text text = Texts.toText(exception.getRawMessage());
    String string = exception.getContext();
    return string == null ? text.asOrderedText() : (new TranslatableText("command.context.parse_error", text, exception.getCursor(), string)).asOrderedText();
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) TranslatableText(net.minecraft.text.TranslatableText) OrderedText(net.minecraft.text.OrderedText) Text(net.minecraft.text.Text)

Example 59 with TranslatableText

use of net.minecraft.text.TranslatableText in project Biome-Makeover by Lemonszz.

the class DirectionalDataScreen method init.

@Override
protected void init() {
    this.client.keyboard.setRepeatEvents(true);
    this.buttonDone = this.addButton(new ButtonWidget(this.width / 2 - 4 - 150, 210, 150, 20, ScreenTexts.DONE, (buttonWidget) -> {
        this.done();
    }));
    this.buttonCancel = this.addButton(new ButtonWidget(this.width / 2 + 4, 210, 150, 20, ScreenTexts.CANCEL, (buttonWidget) -> {
        this.cancel();
    }));
    this.inputMetadata = new TextFieldWidget(this.textRenderer, this.width / 2 - 152, 120, 308, 20, new TranslatableText("structure_block.custom_data"));
    this.inputMetadata.setMaxLength(128);
    this.inputMetadata.setText(initialMeta);
    this.children.add(this.inputMetadata);
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) TextFieldWidget(net.minecraft.client.gui.widget.TextFieldWidget) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget)

Example 60 with TranslatableText

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

the class ConfigScreen method init.

@Override
protected void init() {
    super.init();
    this.addDrawableChild(new ButtonWidget(this.width / 2 - 154, this.height - 29, 150, 20, new TranslatableText("gui.cancel"), (buttonWidgetx) -> {
        ConfigManager.discardConfig();
        this.client.setScreen(parentScreen);
    }));
    this.addDrawableChild(new ButtonWidget(this.width / 2 + 4, this.height - 29, 150, 20, new TranslatableText("gui.done"), (buttonWidgetx) -> {
        ConfigManager.applyConfig();
        ConfigManager.saveConfig();
        this.client.setScreen(parentScreen);
    }));
    this.configListWidget = new ConfigListWidget(this, this.client);
    this.addSelectableChild(this.configListWidget);
    // generate configs...
    configListWidget.addEntries(Config.values());
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) ConfigListWidget(org.moon.moonfix.config.widgets.ConfigListWidget) Screen(net.minecraft.client.gui.screen.Screen) InputUtil(net.minecraft.client.util.InputUtil) MatrixStack(net.minecraft.client.util.math.MatrixStack) TranslatableText(net.minecraft.text.TranslatableText) Config(org.moon.moonfix.config.ConfigManager.Config) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) KeyBinding(net.minecraft.client.option.KeyBinding) ConfigListWidget(org.moon.moonfix.config.widgets.ConfigListWidget) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget)

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