use of net.minecraft.text.LiteralText in project meteor-client by MeteorDevelopment.
the class FakeClientPlayer method getPlayerListEntry.
public static PlayerListEntry getPlayerListEntry() {
if (playerListEntry == null || needsNewEntry) {
playerListEntry = new PlayerListEntry(PlayerListEntryFactory.create(mc.getSession().getProfile(), 0, GameMode.SURVIVAL, new LiteralText(mc.getSession().getProfile().getName())));
needsNewEntry = false;
}
return playerListEntry;
}
use of net.minecraft.text.LiteralText in project FZMM-Mod by Zailer43.
the class FzmmItemGroup method addItemFrames.
private static void addItemFrames(List<ItemStack> stacks) {
ItemStack itemFrame = new ItemStack(Items.ITEM_FRAME);
ItemStack glowItemFrame = new ItemStack(Items.GLOW_ITEM_FRAME);
NbtCompound entityTag = new NbtCompound();
entityTag.putBoolean("Invisible", true);
itemFrame.setSubNbt(EntityType.ENTITY_TAG_KEY, entityTag);
glowItemFrame.setSubNbt(EntityType.ENTITY_TAG_KEY, entityTag);
itemFrame.setCustomName(new LiteralText("Invisible item frame").setStyle(Style.EMPTY.withItalic(false)));
glowItemFrame.setCustomName(new LiteralText("Invisible glow item frame").setStyle(Style.EMPTY.withItalic(false)));
stacks.add(itemFrame);
stacks.add(glowItemFrame);
}
use of net.minecraft.text.LiteralText in project FZMM-Mod by Zailer43.
the class GradientLogic method getGradient.
public static MutableText getGradient(String message, byte red, byte green, byte blue, byte red2, byte green2, byte blue2, Style style) {
List<String> messageList = splitString(message);
int gradientLength = messageList.size();
byte[] gradientRed = getByteGradient(red, red2, gradientLength);
byte[] gradientGreen = getByteGradient(green, green2, gradientLength);
byte[] gradientBlue = getByteGradient(blue, blue2, gradientLength);
MutableText gradientText = LiteralText.EMPTY.copy();
for (int i = 0; i != gradientLength; i++) {
int rgb = rgbToInt(gradientRed[i], gradientGreen[i], gradientBlue[i]);
gradientText.append(new LiteralText(String.valueOf(messageList.get(i))).setStyle(style.withColor(TextColor.fromRgb(rgb))));
}
return gradientText;
}
use of net.minecraft.text.LiteralText in project FZMM-Mod by Zailer43.
the class ImagetextLine method getLine.
public ArrayList<String> getLine() {
ArrayList<String> lineString = new ArrayList<>();
short lineIndex = 0;
for (int i = 0; i != this.line.size(); i++) {
int color = this.line.get(i).getLeft();
byte amount = this.line.get(i).getRight();
String message;
if (this.isDefaultText && color == -16777216) {
// -16777216 = 255 0 0 0 (ARGB)
String emptyString = " ".repeat(amount);
message = '"' + emptyString + Formatting.BOLD + emptyString + Formatting.RESET + '"';
lineIndex += amount;
} else {
StringBuilder text = new StringBuilder();
Color pixel = new Color(color);
color = (pixel.getRed() << 16) + (pixel.getGreen() << 8) + pixel.getBlue();
for (int x = 0; x != amount; x++) {
text.append(this.getCharacter(lineIndex++));
}
message = Text.Serializer.toJson(new LiteralText(text.toString()).setStyle(this.style.withColor(color)));
}
lineString.add(message);
}
return lineString;
}
use of net.minecraft.text.LiteralText in project tweakermore by Fallen-Breath.
the class ShulkerToolTipEnhancer method appendEnchantmentHints.
public static void appendEnchantmentHints(ItemStack itemStack, Text text) {
if (TweakerMoreConfigs.SHULKER_TOOLTIP_ENCHANTMENT_HINT.getBooleanValue()) {
List<Text> enchantmentTexts = Lists.newArrayList();
ListTag enchantmentTag = itemStack.getItem() instanceof EnchantedBookItem ? EnchantedBookItem.getEnchantmentTag(itemStack) : itemStack.getEnchantments();
ItemStack.appendEnchantments(enchantmentTexts, enchantmentTag);
int amount = enchantmentTexts.size();
if (amount > 0) {
TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
Text extraText = new LiteralText(" | ").formatted(Formatting.DARK_GRAY);
int idx;
for (idx = 0; idx < amount; idx++) {
if (idx > 0 && textRenderer.getStringWidth(extraText.getString() + enchantmentTexts.get(idx).getString()) > MAX_TEXT_LENGTH) {
break;
}
extraText.append(enchantmentTexts.get(idx));
if (idx < amount - 1) {
extraText.append(new LiteralText(", ").formatted(Formatting.GRAY));
}
}
if (idx < amount) {
extraText.append(new TranslatableText("tweakermore.config.shulkerTooltipEnchantmentHint.more", amount - idx).formatted(Formatting.GRAY));
}
text.append(extraText);
}
}
}
Aggregations