use of net.minecraft.text.MutableText in project meteor-client by MeteorDevelopment.
the class BindsCommand method getTooltip.
private MutableText getTooltip(Module module) {
MutableText tooltip = new LiteralText(Utils.nameToTitle(module.title)).formatted(Formatting.BLUE, Formatting.BOLD).append("\n\n");
tooltip.append(new LiteralText(module.description).formatted(Formatting.WHITE));
return tooltip;
}
use of net.minecraft.text.MutableText in project meteor-client by MeteorDevelopment.
the class BindsCommand method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.executes(context -> {
// Modules
List<Module> modules = Modules.get().getAll().stream().filter(module -> module.keybind.isSet()).collect(Collectors.toList());
ChatUtils.info("--- Bound Modules ((highlight)%d(default)) ---", modules.size());
for (Module module : modules) {
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, getTooltip(module));
MutableText text = new LiteralText(module.title).formatted(Formatting.WHITE);
text.setStyle(text.getStyle().withHoverEvent(hoverEvent));
MutableText sep = new LiteralText(" - ");
sep.setStyle(sep.getStyle().withHoverEvent(hoverEvent));
text.append(sep.formatted(Formatting.GRAY));
MutableText key = new LiteralText(module.keybind.toString());
key.setStyle(key.getStyle().withHoverEvent(hoverEvent));
text.append(key.formatted(Formatting.GRAY));
ChatUtils.sendMsg(text);
}
return SINGLE_SUCCESS;
});
}
use of net.minecraft.text.MutableText in project FZMM-Mod by Zailer43.
the class ItemStackMixin method getTooltip.
@Inject(method = "getTooltip", at = @At("RETURN"), cancellable = true)
public void getTooltip(PlayerEntity player, TooltipContext context, CallbackInfoReturnable<List<Text>> cir) {
if (this.hasNbt() && context.isAdvanced()) {
NbtCompound nbt = this.getNbt();
assert nbt != null;
List<String> tags = nbt.getKeys().stream().toList();
int tagsSize = tags.size();
MutableText loreText = new LiteralText("Tags: ");
List<Text> list = cir.getReturnValue();
list.remove(list.size() - 1);
for (int i = 0; i != tagsSize; i++) {
loreText.append(tags.get(i) + (i == tagsSize - 1 ? "" : ", "));
if (i % 3 == 2) {
list.add(loreText.setStyle(Style.EMPTY.withColor(Formatting.DARK_GRAY)));
loreText = new LiteralText("");
}
}
if (!loreText.getString().isEmpty())
list.add(loreText.setStyle(Style.EMPTY.withColor(Formatting.DARK_GRAY)));
MutableText lengthText = new LiteralText(FzmmUtils.getNbtLengthInKB(nbt));
list.add(lengthText.setStyle(Style.EMPTY.withColor(Formatting.GRAY)));
cir.setReturnValue(list);
}
}
use of net.minecraft.text.MutableText in project carpet-discarpet by replaceitem.
the class DiscarpetCommand method register.
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
dispatcher.register(literal("discarpet").requires(serverCommandSource -> serverCommandSource.hasPermissionLevel(2)).executes(commandContext -> {
String version = FabricLoader.getInstance().getModContainer("discarpet").get().getMetadata().getVersion().getFriendlyString();
MutableText text = new LiteralText("Discarpet version " + version).formatted(Formatting.BLUE);
text.append("\nFor help, see the ");
text.append(new LiteralText("documentation").setStyle(Style.EMPTY.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://github.com/replaceitem/carpet-discarpet/blob/master/docs/Full.md")).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("Click to get to the Discarpet documentation"))).withFormatting(Formatting.UNDERLINE).withColor(Formatting.DARK_BLUE)));
commandContext.getSource().sendFeedback(text, true);
return 1;
}).then(literal("list").executes(commandContext -> {
Set<String> botIDs = Discarpet.discordBots.keySet();
final LiteralText t;
if (botIDs.size() == 0) {
t = (LiteralText) new LiteralText("There are no bots active:\n").formatted(Formatting.RED);
} else {
t = (LiteralText) new LiteralText("There are " + botIDs.size() + " bots active\n").formatted(Formatting.GREEN);
}
botIDs.forEach(id -> t.append(new LiteralText(id + "\n").formatted(Formatting.BLUE)));
commandContext.getSource().sendFeedback(t, true);
return botIDs.size();
})).then(literal("getInvite").then(CommandManager.argument("id", StringArgumentType.string()).suggests(BOTS).executes(commandContext -> {
String id = StringArgumentType.getString(commandContext, "id");
String invite = Discarpet.discordBots.get(id).getInvite();
Text text = ((new LiteralText("Click here to get the invite link for the bot")).styled((style) -> {
return style.withColor(Formatting.BLUE).withFormatting(Formatting.UNDERLINE).withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, invite)).withHoverEvent(new HoverEvent(net.minecraft.text.HoverEvent.Action.SHOW_TEXT, new LiteralText("Click to open the invite link"))).withInsertion(invite);
}));
commandContext.getSource().sendFeedback(text, false);
return 1;
}))).then(literal("reload").executes(commandContext -> {
Discarpet.loadConfig(commandContext.getSource());
return 1;
})));
}
use of net.minecraft.text.MutableText in project SpeedRunIGT by RedLime.
the class TimerDrawer method draw.
public void draw() {
if (!toggle)
return;
client.getProfiler().push("create");
MutableText igtText = getIGTText();
MutableText rtaText = getRTAText();
client.getProfiler().swap("font");
// 폰트 조정
float fontHeight = 8;
FontManagerAccessor fontManager = (FontManagerAccessor) ((MinecraftClientAccessor) client).getFontManager();
if (getTimerFont() != MinecraftClient.DEFAULT_FONT_ID && fontManager.getFontStorages().containsKey(getTimerFont())) {
rtaText.setStyle(rtaText.getStyle().withFont(getTimerFont()));
igtText.setStyle(igtText.getStyle().withFont(getTimerFont()));
fontHeight = fontHeightMap.computeIfAbsent(getTimerFont().toString(), key -> {
RenderableGlyph glyph = ((FontStorageAccessor) fontManager.getFontStorages().get(getTimerFont())).invokeRenderableGlyph('I');
return glyph.getHeight() / glyph.getOversample();
});
}
// 초기 값 조정
client.getProfiler().swap("init");
TimerElement igtTimerElement = new TimerElement();
TimerElement rtaTimerElement = new TimerElement();
rtaTimerElement.init(rtaXPos, rtaYPos, rtaScale, rtaText, rtaColor, rtaDecoration, fontHeight);
igtTimerElement.init(igtXPos, igtYPos, igtScale, igtText, igtColor, igtDecoration, fontHeight);
MatrixStack matrixStack = new MatrixStack();
// 배경 렌더
client.getProfiler().swap("background");
if (bgOpacity > 0.01f) {
Position rtaMin = new Position(rtaTimerElement.getPosition().getX() - rtaPadding, rtaTimerElement.getPosition().getY() - rtaPadding);
Position rtaMax = new Position(rtaMin.getX() + rtaTimerElement.getScaledTextWidth() + ((rtaPadding - 1) + rtaPadding), rtaMin.getY() + rtaTimerElement.getScaledTextHeight() + ((rtaPadding - 1) + rtaPadding));
Position igtMin = new Position(igtTimerElement.getPosition().getX() - igtPadding, igtTimerElement.getPosition().getY() - igtPadding);
Position igtMax = new Position(igtMin.getX() + igtTimerElement.getScaledTextWidth() + ((igtPadding - 1) + igtPadding), igtMin.getY() + igtTimerElement.getScaledTextHeight() + ((igtPadding - 1) + igtPadding));
int opacity = BackgroundHelper.ColorMixer.getArgb((int) (bgOpacity * 255), 0, 0, 0);
if (rtaMin.getX() < igtMax.getX() && rtaMin.getY() < igtMax.getY() && igtMin.getX() < rtaMax.getX() && igtMin.getY() < rtaMax.getY()) {
DrawableHelper.fill(matrixStack, Math.min(rtaMin.getX(), igtMin.getX()), Math.min(rtaMin.getY(), igtMin.getY()), Math.max(rtaMax.getX(), igtMax.getX()), Math.max(rtaMax.getY(), igtMax.getY()), opacity);
} else {
if (rtaScale != 0)
DrawableHelper.fill(matrixStack, rtaMin.getX(), rtaMin.getY(), rtaMax.getX(), rtaMax.getY(), opacity);
if (igtScale != 0)
DrawableHelper.fill(matrixStack, igtMin.getX(), igtMin.getY(), igtMax.getX(), igtMax.getY(), opacity);
}
}
// 렌더
client.getProfiler().swap("draw");
if (igtScale != 0)
igtTimerElement.draw(matrixStack, translateZ);
if (rtaScale != 0)
rtaTimerElement.draw(matrixStack, translateZ);
client.getProfiler().pop();
}
Aggregations