Search in sources :

Example 71 with TranslatableText

use of net.minecraft.text.TranslatableText in project Neutrino by FrostWizard4.

the class DeathCapArtifact method appendTooltip.

@Override
public void appendTooltip(ItemStack itemStack, World world, List<Text> tooltip, TooltipContext tooltipContext) {
    tooltip.add(new TranslatableText("item.neutrino.death_cap_mushroom.tooltip").formatted(Formatting.AQUA));
    if (Screen.hasShiftDown()) {
        tooltip.add(new TranslatableText("item.neutrino.death_cap_mushroom.tooltip2"));
        tooltip.add(new TranslatableText("item.neutrino.death_cap_mushroom.tooltip3"));
    } else {
        tooltip.add(new TranslatableText("item.neutrino.death_cap_mushroom.shiftdown").formatted(Formatting.DARK_GRAY));
    }
}
Also used : TranslatableText(net.minecraft.text.TranslatableText)

Example 72 with TranslatableText

use of net.minecraft.text.TranslatableText in project Neutrino by FrostWizard4.

the class LightningRodArtifact method appendTooltip.

@Override
public void appendTooltip(ItemStack itemStack, World world, List<Text> tooltip, TooltipContext tooltipContext) {
    tooltip.add(new TranslatableText("item.neutrino.lightning_rod.tooltip").formatted(Formatting.AQUA));
    if (Screen.hasShiftDown()) {
        tooltip.add(new TranslatableText("item.neutrino.lightning_rod.tooltip2"));
        tooltip.add(new TranslatableText("item.neutrino.lightning_rod.tooltip3"));
    } else {
        tooltip.add(new TranslatableText("item.neutrino.lightning_rod.shiftdown").formatted(Formatting.DARK_GRAY));
    }
}
Also used : TranslatableText(net.minecraft.text.TranslatableText)

Example 73 with TranslatableText

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

the class ShulkerBoxTooltip method getTooltipText.

@Override
public TranslatableText getTooltipText() {
    TranslatableText tooltip = new TranslatableText(translationKey);
    tooltip.append(" x").append(String.valueOf(primaryValue));
    return tooltip;
}
Also used : TranslatableText(net.minecraft.text.TranslatableText)

Example 74 with TranslatableText

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

the class HeldItemTooltips method drawItemWithCustomTooltips.

public int drawItemWithCustomTooltips(TextRenderer fontRenderer, MatrixStack matrices, Text text, float x, float y, int color, ItemStack currentStack) {
    int screenBorder = Bedrockify.getInstance().settings.getScreenSafeArea();
    // Get the current held item tooltips.
    List<Tooltip> tooltips = getTooltips(currentStack);
    int tooltipOffset = 0;
    BedrockifySettings settings = Bedrockify.getInstance().settings;
    // Draw item tooltips if the option is enabled.
    if (settings.getHeldItemTooltip() > 0) {
        if (tooltips != null) {
            // Compute the max tooltip offset (used for the item name).
            int count = 0;
            // Limit the maximum number of shown tooltips to 4.
            boolean showMoreTooltip = false;
            if (tooltips.size() > 4) {
                showMoreTooltip = true;
                tooltipOffset = 12 * 4;
                count++;
            } else
                tooltipOffset = tooltips.size() * 12;
            // Render background behind tooltip if enabled.
            if (settings.getHeldItemTooltip() == 2) {
                int maxLength = getMaxTooltipLength(tooltips, fontRenderer, currentStack);
                renderBackground(matrices, y, screenBorder, tooltipOffset, maxLength);
            }
            for (Tooltip elem : tooltips) {
                // Prevent from drawing more than 4 tooltips.
                if (count > 3)
                    break;
                // Render the tooltip.
                renderTooltip(fontRenderer, matrices, y - screenBorder - (12 * count), color, elem.getTooltipText().formatted(Formatting.GRAY));
                count++;
            }
            // show the "and x more..." tooltip if the item has more than 4 tooltips.
            if (showMoreTooltip)
                renderTooltip(fontRenderer, matrices, y - screenBorder, color, new TranslatableText("container.shulkerBox.more", tooltips.size() - 4).formatted(Formatting.GRAY));
        } else if (settings.getHeldItemTooltip() == 2) {
            // draw the background
            renderBackground(matrices, y, screenBorder, tooltipOffset, fontRenderer.getWidth(text));
        }
    }
    // Render the item name.
    return fontRenderer.drawWithShadow(matrices, text, x, y - tooltipOffset - screenBorder, color);
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) BedrockifySettings(me.juancarloscp52.bedrockify.BedrockifySettings) PotionTooltip(me.juancarloscp52.bedrockify.client.features.HeldItemTooltips.Tooltip.PotionTooltip) EnchantmentTooltip(me.juancarloscp52.bedrockify.client.features.HeldItemTooltips.Tooltip.EnchantmentTooltip) Tooltip(me.juancarloscp52.bedrockify.client.features.HeldItemTooltips.Tooltip.Tooltip) ShulkerBoxTooltip(me.juancarloscp52.bedrockify.client.features.HeldItemTooltips.Tooltip.ShulkerBoxTooltip)

Example 75 with TranslatableText

use of net.minecraft.text.TranslatableText in project quilt-standard-libraries by QuiltMC.

the class ClientCommandInternals method getErrorMessage.

/**
 * Analogous to {@code CommandSuggestor#formatException}, but returns a {@link Text} rather than an
 * {@link net.minecraft.text.OrderedText OrderedText}.
 *
 * @param e the exception to get the error message from
 *
 * @return the error message as a {@link Text}
 */
private static Text getErrorMessage(CommandSyntaxException e) {
    Text message = Texts.toText(e.getRawMessage());
    String context = e.getContext();
    return context != null ? new TranslatableText("command.context.parse_error", message, context) : message;
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) LiteralText(net.minecraft.text.LiteralText) TranslatableText(net.minecraft.text.TranslatableText) Text(net.minecraft.text.Text)

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