Search in sources :

Example 31 with TranslatableText

use of net.minecraft.text.TranslatableText in project Rug by RubixDev.

the class MaxEffectCommand method register.

public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
    LiteralArgumentBuilder<ServerCommandSource> command = literal("maxeffect").requires((player) -> SettingsManager.canUseCommand(player, RugSettings.commandMaxEffect)).then(argument("effect", StatusEffectArgumentType.statusEffect()).executes(context -> {
        ServerCommandSource source = context.getSource();
        ServerPlayerEntity player = source.getPlayer();
        StatusEffect effect = StatusEffectArgumentType.getStatusEffect(context, "effect");
        boolean success = false;
        if (player instanceof LivingEntity) {
            StatusEffectInstance statusEffectInstance = new StatusEffectInstance(effect, effect.isInstant() ? 999999 : (999999 * 20), 255, false, false);
            success = (player).addStatusEffect(statusEffectInstance, source.getEntity());
        }
        if (!success) {
            throw new SimpleCommandExceptionType(new TranslatableText("commands.effect.give.failed")).create();
        }
        source.sendFeedback(new TranslatableText("commands.effect.give.success.single", effect.getName(), player.getDisplayName(), 999999), true);
        return 1;
    }));
    dispatcher.register(command);
}
Also used : StatusEffectArgumentType(net.minecraft.command.argument.StatusEffectArgumentType) CommandDispatcher(com.mojang.brigadier.CommandDispatcher) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) LivingEntity(net.minecraft.entity.LivingEntity) SettingsManager(carpet.settings.SettingsManager) TranslatableText(net.minecraft.text.TranslatableText) RugSettings(de.rubixdev.rug.RugSettings) CommandManager.literal(net.minecraft.server.command.CommandManager.literal) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) SimpleCommandExceptionType(com.mojang.brigadier.exceptions.SimpleCommandExceptionType) CommandManager.argument(net.minecraft.server.command.CommandManager.argument) StatusEffect(net.minecraft.entity.effect.StatusEffect) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) TranslatableText(net.minecraft.text.TranslatableText) StatusEffect(net.minecraft.entity.effect.StatusEffect) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) SimpleCommandExceptionType(com.mojang.brigadier.exceptions.SimpleCommandExceptionType) ServerCommandSource(net.minecraft.server.command.ServerCommandSource)

Example 32 with TranslatableText

use of net.minecraft.text.TranslatableText in project Primeval by devs-immortal.

the class ClayMoldItem method appendTooltip.

@Environment(EnvType.CLIENT)
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context) {
    NbtCompound nbt = stack.getOrCreateNbt();
    NbtCompound fluidNbt = nbt.getCompound("Fluid");
    int fluidAmount = fluidNbt.getInt("Amount");
    if (fluidAmount > 0) {
        tooltip.add((new TranslatableText("text.primeval.fluid.contains", fluidAmount, new TranslatableText("block." + fluidNbt.getString("fluid").replace(':', '.')))).formatted(Formatting.GRAY));
    }
    tooltip.add((new TranslatableText("⚖ ").append(this.weight.getText()).append(" ⤧ ").append(this.size.getText())).formatted(Formatting.GRAY));
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) NbtCompound(net.minecraft.nbt.NbtCompound) Environment(net.fabricmc.api.Environment)

Example 33 with TranslatableText

use of net.minecraft.text.TranslatableText in project MiniMap by pl3xgaming.

the class AboutCategory method renderContent.

@Override
public void renderContent(MatrixStack matrixStack, float mouseX, float mouseY, float delta) {
    float x = (Monitor.width() + baseX()) / 2F;
    float y = baseY() + 80F;
    Texture.ICON.tint(matrixStack, x - 32 + 4F, y + 4F, 64, 64, 0x88000000);
    Texture.ICON.draw(matrixStack, x - 32, y, 64, 64);
    Font.GOODDOG.drawCentered(matrixStack, Lang.TITLE, x + 3F, y + 85F + 3F, 0x88000000);
    Font.GOODDOG.drawCentered(matrixStack, Lang.TITLE, x, y + 85F, 0xFFFFFFFF);
    Font.NOTOSANS.drawCentered(matrixStack, "Copyright (c) 2020-2022", x + 1F, y + 140 + 1F, 0x88000000);
    Font.NOTOSANS.drawCentered(matrixStack, "Copyright (c) 2020-2022", x, y + 140, 0xFFFFFFFF);
    Font.NOTOSANS.drawCentered(matrixStack, "William Blake Galbreath", x + 1F, y + 160 + 1F, 0x88000000);
    Font.NOTOSANS.drawCentered(matrixStack, "William Blake Galbreath", x, y + 160, 0xFFFFFFFF);
    String mc = UpdateChecker.INSTANCE.getMinecraftVersion();
    int current = UpdateChecker.INSTANCE.getCurrentVersion();
    int latest = UpdateChecker.INSTANCE.getLatestVersion();
    // todo cache this component somewhere
    Text currentVersion = new TranslatableText("Current Version: " + mc + (current < 0 ? " SNAPSHOT" : " build " + current));
    Font.NOTOSANS.drawCentered(matrixStack, currentVersion, x + 1F, y + 230 + 1F, 0x88000000);
    Font.NOTOSANS.drawCentered(matrixStack, currentVersion, x, y + 230, 0xFFFFFFFF);
    // todo cache this component somewhere
    Text text;
    if (latest > 0) {
        text = new TranslatableText("Latest Version: " + mc + " build " + latest);
    } else if (latest == UpdateChecker.Status.CHECKING) {
        text = new TranslatableText("Checking for updates...").formatted(Formatting.LIGHT_PURPLE);
    } else if (latest == UpdateChecker.Status.ERROR) {
        text = new TranslatableText("Error checking for updates!").formatted(Formatting.RED);
    } else if (latest == current) {
        text = new TranslatableText("Up to date!").formatted(Formatting.GREEN);
    } else {
        text = new TranslatableText("Unknown").formatted(Formatting.GOLD);
    }
    Font.NOTOSANS.drawCentered(matrixStack, text.copy().formatted(Formatting.RESET), x + 1F, y + 260 + 1F, 0x88000000);
    Font.NOTOSANS.drawCentered(matrixStack, text, x, y + 260, 0xFFFFFFFF);
    if (UpdateChecker.INSTANCE.hasUpdate()) {
        Font.ROBOTO.drawCentered(matrixStack, "Updates Available!", x + 1F, y + 280 + 1F, 0x88880000);
        Font.ROBOTO.drawCentered(matrixStack, "Updates Available!", x, y + 280, 0xFFFF5555);
    }
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) TranslatableText(net.minecraft.text.TranslatableText) Text(net.minecraft.text.Text)

Example 34 with TranslatableText

use of net.minecraft.text.TranslatableText in project BlockMeter by ModProg.

the class ColorButton method init.

@Override
protected void init() {
    ModConfig config = BlockMeterClient.getConfigManager().getConfig();
    // Create Color Selector
    for (int i = 0; i < 4; ++i) {
        for (int j = 0; j < 4; ++j) {
            final int colorIndex = i * 4 + j;
            this.addDrawableChild(new ColorButton(this.width / 2 - 44 + j * 22, this.height / 2 - 88 + i * 22, 20, 20, null, DyeColor.byId(colorIndex).getColorComponents(), config.colorIndex == colorIndex, false, button -> {
                ClientMeasureBox.setColorIndex(colorIndex);
                final ClientMeasureBox currentBox = BlockMeterClient.getInstance().getCurrentBox();
                if (currentBox != null)
                    currentBox.setColor(DyeColor.byId(colorIndex));
                MinecraftClient.getInstance().setScreen((Screen) null);
            }));
        }
    }
    this.addDrawableChild(new ButtonWidget(this.width / 2 - BUTTONWIDTH / 2, this.height / 2 + 10, BUTTONWIDTH, 20, new TranslatableText("blockmeter.keepColor", new Object[] { new TranslatableText(config.incrementColor ? "options.off" : "options.on") }), button -> {
        config.incrementColor = !config.incrementColor;
        MinecraftClient.getInstance().setScreen((Screen) null);
        // Todo find a way to increment to a new Color if a box was created while
        // incrementColor was disabled
        BlockMeterClient.getConfigManager().save();
    }));
    this.addDrawableChild(new ButtonWidget(this.width / 2 - BUTTONWIDTH / 2, this.height / 2 + 32, BUTTONWIDTH, 20, new TranslatableText("blockmeter.diagonal", new Object[] { new TranslatableText(config.innerDiagonal ? "options.on" : "options.off") }), button -> {
        System.err.println("IDK WHAT YOU ARE DOING");
        config.innerDiagonal = !config.innerDiagonal;
        MinecraftClient.getInstance().setScreen((Screen) null);
        BlockMeterClient.getConfigManager().save();
    }));
    this.addDrawableChild(new ButtonWidget(this.width / 2 - BUTTONWIDTH / 2, this.height / 2 + 54, BUTTONWIDTH, 20, new TranslatableText("blockmeter.showOthers", new Object[] { new TranslatableText(config.showOtherUsersBoxes ? "options.on" : "options.off") }), button -> {
        System.err.println("IDK WHAT YOU ARE DOING");
        config.showOtherUsersBoxes = !config.showOtherUsersBoxes;
        MinecraftClient.getInstance().setScreen((Screen) null);
        BlockMeterClient.getConfigManager().save();
    }));
}
Also used : LiteralText(net.minecraft.text.LiteralText) Tessellator(net.minecraft.client.render.Tessellator) Color(me.shedaniel.math.Color) BlockMeterClient(win.baruna.blockmeter.BlockMeterClient) GameRenderer(net.minecraft.client.render.GameRenderer) MatrixStack(net.minecraft.client.util.math.MatrixStack) TranslatableText(net.minecraft.text.TranslatableText) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) ModConfig(win.baruna.blockmeter.ModConfig) NarratorManager(net.minecraft.client.util.NarratorManager) Screen(net.minecraft.client.gui.screen.Screen) DrawMode(net.minecraft.client.render.VertexFormat.DrawMode) DyeColor(net.minecraft.util.DyeColor) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) BufferBuilder(net.minecraft.client.render.BufferBuilder) MutableText(net.minecraft.text.MutableText) MinecraftClient(net.minecraft.client.MinecraftClient) ClientMeasureBox(win.baruna.blockmeter.measurebox.ClientMeasureBox) TextRenderer(net.minecraft.client.font.TextRenderer) VertexFormats(net.minecraft.client.render.VertexFormats) TranslatableText(net.minecraft.text.TranslatableText) Screen(net.minecraft.client.gui.screen.Screen) ClientMeasureBox(win.baruna.blockmeter.measurebox.ClientMeasureBox) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) ModConfig(win.baruna.blockmeter.ModConfig)

Example 35 with TranslatableText

use of net.minecraft.text.TranslatableText in project BlockMeter by ModProg.

the class SelectBoxGui method init.

@Override
protected void init() {
    final int uiHeight = (boxes.length + 1) * (BUTTONHEIGHT + PADDING);
    for (int i = 0; i < boxes.length; i++) {
        final ClientMeasureBox box = boxes[i];
        final TranslatableText text = new TranslatableText("blockmeter.boxToString", new Object[] { box.getBlockStart().getX(), box.getBlockStart().getY(), box.getBlockStart().getZ(), box.getBlockEnd().getX(), box.getBlockEnd().getY(), box.getBlockEnd().getZ() });
        // text.setStyle(text.getStyle().withColor(TextColor.fromRgb(box.getColor().getSignColor())));
        this.addDrawableChild(new ColorButton(this.width / 2 - (BUTTONWIDTH) / 2, this.height / 2 - uiHeight / 2 + i * (BUTTONHEIGHT + PADDING), BUTTONWIDTH, BUTTONHEIGHT, text, box.getColor().getColorComponents(), false, true, button -> {
            box.loosenCorner(block);
            MinecraftClient.getInstance().setScreen((Screen) null);
        }));
    }
    this.addDrawableChild(new ButtonWidget(this.width / 2 - BUTTONWIDTH / 2, this.height / 2 - uiHeight / 2 + boxes.length * (BUTTONHEIGHT + PADDING) + PADDING, BUTTONWIDTH, BUTTONHEIGHT, new TranslatableText("gui.cancel"), button -> {
        MinecraftClient.getInstance().setScreen((Screen) null);
    }));
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) NarratorManager(net.minecraft.client.util.NarratorManager) Screen(net.minecraft.client.gui.screen.Screen) MatrixStack(net.minecraft.client.util.math.MatrixStack) TranslatableText(net.minecraft.text.TranslatableText) MinecraftClient(net.minecraft.client.MinecraftClient) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) BlockPos(net.minecraft.util.math.BlockPos) ClientMeasureBox(win.baruna.blockmeter.measurebox.ClientMeasureBox) Screen(net.minecraft.client.gui.screen.Screen) ClientMeasureBox(win.baruna.blockmeter.measurebox.ClientMeasureBox) 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