Search in sources :

Example 1 with LiteralText

use of net.minecraft.text.LiteralText in project nbt-crafting by Siphalor.

the class MixinAnvilContainer method updateResult.

@Inject(method = "updateResult", at = @At("HEAD"), cancellable = true)
public void updateResult(CallbackInfo callbackInfo) {
    recipe = player.world.getRecipeManager().getFirstMatch(NbtCrafting.ANVIL_RECIPE_TYPE, inventory, player.world).orElse(null);
    if (recipe != null) {
        ItemStack resultStack = recipe.craft(inventory);
        repairItemUsage = 1;
        if (userChangedName) {
            if (!StringUtils.isBlank(newItemName) && !newItemName.equals(resultStack.getName().getString())) {
                resultStack.setCustomName(new LiteralText(newItemName));
            }
            userChangedName = false;
        } else {
            newItemName = resultStack.getName().getString();
            if (player instanceof ServerPlayerEntity) {
                if (NbtCrafting.hasClientMod((ServerPlayerEntity) player)) {
                    PacketByteBuf packetByteBuf = new PacketByteBuf(Unpooled.buffer());
                    packetByteBuf.writeString(newItemName);
                    ServerSidePacketRegistry.INSTANCE.sendToPlayer(player, NbtCrafting.UPDATE_ANVIL_TEXT_S2C_PACKET_ID, packetByteBuf);
                }
            }
        }
        result.setInvStack(0, resultStack);
        levelCost.set(recipe.getLevels());
        sendContentUpdates();
        callbackInfo.cancel();
    }
}
Also used : PacketByteBuf(net.minecraft.util.PacketByteBuf) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ItemStack(net.minecraft.item.ItemStack) LiteralText(net.minecraft.text.LiteralText) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with LiteralText

use of net.minecraft.text.LiteralText in project reeses-sodium-options by FlashyReese.

the class SodiumVideoOptionsScreen method parentFrameBuilder.

protected BasicFrame.Builder parentFrameBuilder() {
    BasicFrame.Builder basicFrameBuilder;
    Dim2i basicFrameDim = new Dim2i(0, 0, this.width, this.height);
    Dim2i tabFrameDim = new Dim2i(basicFrameDim.width() / 20 / 2, basicFrameDim.height() / 4 / 2, basicFrameDim.width() - (basicFrameDim.width() / 20), basicFrameDim.height() / 4 * 3);
    Dim2i undoButtonDim = new Dim2i(tabFrameDim.getLimitX() - 203, tabFrameDim.getLimitY() + 5, 65, 20);
    Dim2i applyButtonDim = new Dim2i(tabFrameDim.getLimitX() - 134, tabFrameDim.getLimitY() + 5, 65, 20);
    Dim2i closeButtonDim = new Dim2i(tabFrameDim.getLimitX() - 65, tabFrameDim.getLimitY() + 5, 65, 20);
    Dim2i donateButtonDim = new Dim2i(tabFrameDim.getLimitX() - 122, tabFrameDim.y() - 26, 100, 20);
    Dim2i hideDonateButtonDim = new Dim2i(tabFrameDim.getLimitX() - 20, tabFrameDim.y() - 26, 20, 20);
    this.undoButton = new FlatButtonWidget(undoButtonDim, new TranslatableText("sodium.options.buttons.undo"), this::undoChanges);
    this.applyButton = new FlatButtonWidget(applyButtonDim, new TranslatableText("sodium.options.buttons.apply"), this::applyChanges);
    this.closeButton = new FlatButtonWidget(closeButtonDim, new TranslatableText("gui.done"), this::close);
    this.donateButton = new FlatButtonWidget(donateButtonDim, new TranslatableText("sodium.options.buttons.donate"), this::openDonationPage);
    this.hideDonateButton = new FlatButtonWidget(hideDonateButtonDim, new LiteralText("x"), this::hideDonationButton);
    if (SodiumClientMod.options().notifications.hideDonationButton) {
        this.setDonationButtonVisibility(false);
    }
    basicFrameBuilder = this.parentBasicFrameBuilder(basicFrameDim, tabFrameDim);
    if (FabricLoader.getInstance().isModLoaded("iris")) {
        int size = this.client.textRenderer.getWidth(new TranslatableText(IrisApi.getInstance().getMainScreenLanguageKey()));
        Dim2i shaderPackButtonDim;
        if (!SodiumClientMod.options().notifications.hideDonationButton) {
            shaderPackButtonDim = new Dim2i(tabFrameDim.getLimitX() - 134 - size, tabFrameDim.y() - 26, 10 + size, 20);
        } else {
            shaderPackButtonDim = new Dim2i(tabFrameDim.getLimitX() - size - 10, tabFrameDim.y() - 26, 10 + size, 20);
        }
        FlatButtonWidget shaderPackButton = new FlatButtonWidget(shaderPackButtonDim, new TranslatableText(IrisApi.getInstance().getMainScreenLanguageKey()), () -> this.client.setScreen((Screen) IrisApi.getInstance().openMainIrisScreenObj(this)));
        basicFrameBuilder.addChild(dim -> shaderPackButton);
    }
    return basicFrameBuilder;
}
Also used : Dim2i(me.jellysquid.mods.sodium.client.util.Dim2i) TranslatableText(net.minecraft.text.TranslatableText) VideoOptionsScreen(net.minecraft.client.gui.screen.option.VideoOptionsScreen) Screen(net.minecraft.client.gui.screen.Screen) FlatButtonWidget(me.jellysquid.mods.sodium.client.gui.widgets.FlatButtonWidget) BasicFrame(me.flashyreese.mods.reeses_sodium_options.client.gui.frame.BasicFrame) LiteralText(net.minecraft.text.LiteralText)

Example 3 with LiteralText

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

the class SpeedRunIGTInfoScreen method render.

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
    this.renderBackground(matrices);
    matrices.push();
    matrices.scale(1.5F, 1.5F, 1.5F);
    this.drawCenteredText(matrices, this.textRenderer, this.title, this.width / 3, 15, 16777215);
    matrices.pop();
    this.drawCenteredText(matrices, this.textRenderer, new LiteralText("Made by RedLime"), this.width / 2, 50, 16777215);
    this.drawCenteredText(matrices, this.textRenderer, new LiteralText("Discord : RedLime#0817"), this.width / 2, 62, 16777215);
    this.drawCenteredText(matrices, this.textRenderer, new LiteralText("Version : " + SpeedRunIGT.MOD_VERSION.split("\\+")[0]), this.width / 2, 78, 16777215);
    if (UPDATE_STATUS != UpdateStatus.NONE) {
        if (UPDATE_STATUS == UpdateStatus.OUTDATED) {
            update.active = true;
            this.drawCenteredText(matrices, this.textRenderer, new LiteralText("Updated Version : " + UPDATE_VERSION).formatted(Formatting.YELLOW), this.width / 2, 88, 16777215);
        }
        this.drawCenteredText(matrices, this.textRenderer, new TranslatableText("speedrunigt.message.update." + UPDATE_STATUS.name().toLowerCase(Locale.ROOT)), this.width / 2, 116, 16777215);
    }
    super.render(matrices, mouseX, mouseY, delta);
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) LiteralText(net.minecraft.text.LiteralText)

Example 4 with LiteralText

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

the class TimerCustomizeScreen method render.

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
    saveButton.active = changed;
    this.renderBackground(matrices);
    drawer.draw();
    this.drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 15, 16777215);
    if (!hide) {
        if (!igtButton.active || !rtaButton.active) {
            if (drawer.isLocked()) {
                drawCenteredText(matrices, this.textRenderer, new TranslatableText("speedrunigt.option.timer_position.description.lock"), this.width / 2, this.height / 2 - 80, 16777215);
            } else {
                drawCenteredText(matrices, this.textRenderer, new TranslatableText("speedrunigt.option.timer_position.description"), this.width / 2, this.height / 2 - 80, 16777215);
                drawCenteredText(matrices, this.textRenderer, new TranslatableText("speedrunigt.option.timer_position.description.move"), this.width / 2, this.height / 2 - 69, 16777215);
            }
        }
        if (!fontButton.active && client != null) {
            int c = fontPage * 3;
            FontManagerAccessor fontManager = (FontManagerAccessor) ((MinecraftClientAccessor) client).getFontManager();
            for (int i = 0; i < fontSelectButtons.size(); i++) {
                if (c + i < availableFonts.size()) {
                    Identifier fontIdentifier = availableFonts.get(c + i);
                    LiteralText text = new LiteralText(fontIdentifier.getPath());
                    if (client != null && fontManager.getFontStorages().containsKey(fontIdentifier)) {
                        text.setStyle(text.getStyle().withFont(fontIdentifier));
                    } else {
                        text.append(new LiteralText(" (Unavailable)")).formatted(Formatting.RED);
                    }
                    if (fontIdentifier.toString().equals(drawer.getTimerFont().toString())) {
                        text.append(" [Selected]").formatted(Formatting.ITALIC);
                    }
                    drawCenteredText(matrices, this.textRenderer, text, this.width / 2 - 30, this.height / 2 - 11 + (i * 22), 16777215);
                }
            }
        }
    }
    super.render(matrices, mouseX, mouseY, delta);
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) Identifier(net.minecraft.util.Identifier) FontManagerAccessor(com.redlimerl.speedrunigt.mixins.access.FontManagerAccessor) LiteralText(net.minecraft.text.LiteralText)

Example 5 with LiteralText

use of net.minecraft.text.LiteralText in project fabric-name-history-lookup by Woolyenough.

the class ClientCommands method names.

private static int names(CommandContext<FabricClientCommandSource> context) {
    CompletableFuture.runAsync(() -> {
        String name = context.getInput().split(" ")[1];
        String[] playerNameAndUUID = get_player_name_and_uuid(name);
        String username = playerNameAndUUID[0];
        String uuid = playerNameAndUUID[1];
        if (Objects.equals(username, "None")) {
            context.getSource().sendError(new LiteralText("No account exists by that name .-."));
        } else {
            context.getSource().sendFeedback(new LiteralText("§7[Hover] §eView name history of " + username).styled(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://namemc.com/profile/" + username)).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, get_player_name_history(username, uuid).append(new LiteralText("\n\n§7§oClick to open in NameMC!"))))));
        }
    });
    return 0;
}
Also used : ClientModInitializer(net.fabricmc.api.ClientModInitializer) LiteralText(net.minecraft.text.LiteralText) java.util(java.util) CommandContext(com.mojang.brigadier.context.CommandContext) FabricClientCommandSource(net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource) Environment(net.fabricmc.api.Environment) CompletableFuture(java.util.concurrent.CompletableFuture) EntityArgumentType(net.minecraft.command.argument.EntityArgumentType) HoverEvent(net.minecraft.text.HoverEvent) ClientCommandManager(net.fabricmc.fabric.api.client.command.v1.ClientCommandManager) ClickEvent(net.minecraft.text.ClickEvent) EnvType(net.fabricmc.api.EnvType) MojangAPI(net.woolyenough.namelookup.modules.MojangAPI) HoverEvent(net.minecraft.text.HoverEvent) ClickEvent(net.minecraft.text.ClickEvent) LiteralText(net.minecraft.text.LiteralText)

Aggregations

LiteralText (net.minecraft.text.LiteralText)249 Text (net.minecraft.text.Text)63 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)51 ItemStack (net.minecraft.item.ItemStack)37 ServerCommandSource (net.minecraft.server.command.ServerCommandSource)34 TranslatableText (net.minecraft.text.TranslatableText)32 MutableText (net.minecraft.text.MutableText)28 BaseText (net.minecraft.text.BaseText)26 NbtCompound (net.minecraft.nbt.NbtCompound)24 HoverEvent (net.minecraft.text.HoverEvent)24 ButtonWidget (net.minecraft.client.gui.widget.ButtonWidget)23 Screen (net.minecraft.client.gui.screen.Screen)21 ClickEvent (net.minecraft.text.ClickEvent)20 MatrixStack (net.minecraft.client.util.math.MatrixStack)19 Formatting (net.minecraft.util.Formatting)19 Items (net.minecraft.item.Items)18 Inject (org.spongepowered.asm.mixin.injection.Inject)18 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)17 List (java.util.List)16 Identifier (net.minecraft.util.Identifier)15