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));
}
}
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));
}
}
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;
}
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);
}
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;
}
Aggregations