use of net.minecraft.text.MutableText in project BedrockIfy by juancarloscp52.
the class Overlay method renderPositionText.
private void renderPositionText(MatrixStack matrixStack) {
BedrockifySettings settings = Bedrockify.getInstance().settings;
int screenBorder = settings.getScreenSafeArea();
int posY = settings.getPositionHUDHeight();
if (!settings.isShowPositionHUDEnabled())
return;
BlockPos blockPos = Objects.requireNonNull(this.client.getCameraEntity(), "Camera Entity cannot be null.").getBlockPos();
MutableText position = new TranslatableText("bedrockify.hud.position").append(new LiteralText(" " + blockPos.getX() + ", " + blockPos.getY() + ", " + blockPos.getZ()));
if (settings.getFPSHUDoption() == 1)
position.append(" ").append(fps);
int positionWidth = client.textRenderer.getWidth(position);
fill(matrixStack, textPosX + screenBorder, posY + screenBorder, textPosX + positionWidth + 6 + screenBorder, posY + 10 + screenBorder, MathHelper.ceil((255.0D * client.options.textBackgroundOpacity)) << 24);
client.textRenderer.drawWithShadow(matrixStack, position, textPosX + 3 + screenBorder, posY + 1 + screenBorder, 16777215);
}
use of net.minecraft.text.MutableText in project pingspam by BasiqueEvangelist.
the class NotificationsCommand method showNotifications.
public static int showNotifications(CommandContext<ServerCommandSource> ctx) throws CommandSyntaxException {
ServerCommandSource src = ctx.getSource();
List<Text> notifs = PlayerUtils.getUnreadPingsFor(src.getPlayer());
if (!notifs.isEmpty()) {
MutableText response = new LiteralText("You have " + notifs.size() + " unread message" + (notifs.size() != 1 ? "s" : "") + ":").formatted(Formatting.GREEN);
for (Text notif : notifs) {
response.append(new LiteralText("\n- ").formatted(Formatting.WHITE).append(notif));
}
src.sendFeedback(response, false);
notifs.clear();
return 1;
} else {
src.sendFeedback(new LiteralText("You have no unread messages.").formatted(Formatting.GREEN), false);
return 0;
}
}
use of net.minecraft.text.MutableText in project LittleMaidReBirth-Fabric by SistrScarlet.
the class LittleMaidScreen method getStateText.
public Text getStateText() {
MutableText stateText = new TranslatableText("state." + LittleMaidReBirthMod.MODID + "." + openAt.getMovingState().getName());
openAt.getModeName().ifPresent(modeName -> stateText.append(" : ").append(new TranslatableText("mode." + LittleMaidReBirthMod.MODID + "." + modeName)));
return stateText;
}
use of net.minecraft.text.MutableText in project mc-discord-bridge by Selicre.
the class DiscordBotImpl method announcePossibleStream.
private void announcePossibleStream(@Nullable GuildVoiceState voice) {
if (voice != null && voice.getChannel() != null && voice.isStream() && isOnline(voice.getMember().getUser())) {
MutableText text = new LiteralText("").append(discordUserToMinecraft(voice.getMember().getUser(), getGuild(), false)).append(" is now streaming to ").append(discordChannelToMinecraft(voice.getChannel()));
broadcastNoMirror(text);
}
}
use of net.minecraft.text.MutableText in project mc-discord-bridge by Selicre.
the class DiscordBotImpl method onMessageReceived.
@Override
public void onMessageReceived(MessageReceivedEvent event) {
if (config.adminChannelId == event.getChannel().getIdLong() && event.getMessage().getContentRaw().startsWith("!") && handleAdminDiscordCommand(event.getMessage())) {
return;
}
if (config.allowsMessagesFrom(event.getChannel(), event.getAuthor())) {
if (event.getMessage().getContentRaw().startsWith("!") && handleNormalDiscordCommand(event.getMessage())) {
return;
}
Message msg = event.getMessage();
LiteralText root = new LiteralText("");
root.append("<");
root.append(discordUserToMinecraft(msg.getAuthor(), getGuild(), false));
Message refMsg = msg.getReferencedMessage();
if (refMsg != null) {
MutableText arrow = new LiteralText("[->]");
if (!refMsg.getContentRaw().isBlank()) {
arrow.setStyle(Style.EMPTY.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, discordMessageToMinecraft(refMsg))));
}
root.append(" ").append(arrow).append(" ").append(discordUserToMinecraft(refMsg.getAuthor(), getGuild(), false));
}
root.append(">");
if (!msg.getContentRaw().isEmpty()) {
root.append(" ");
root.append(discordMessageToMinecraft(msg));
}
if (!msg.getAttachments().isEmpty()) {
for (Message.Attachment attachment : msg.getAttachments()) {
root.append(" [");
LiteralText fileType = null;
if (attachment.isImage()) {
fileType = new LiteralText("image");
} else if (attachment.isVideo()) {
fileType = new LiteralText("video");
} else {
@Nullable String mediaType = attachment.getContentType();
if (mediaType != null) {
if (mediaType.startsWith("text")) {
fileType = new LiteralText("text");
} else if (mediaType.startsWith("audio")) {
fileType = new LiteralText("audio");
}
}
if (fileType == null) {
fileType = new LiteralText("attachment");
}
}
ClickEvent click = new ClickEvent(ClickEvent.Action.OPEN_URL, attachment.getUrl());
HoverEvent hover = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("").append(attachment.getFileName()).append("\n").append(new LiteralText(readableFileSize(attachment.getSize()))));
fileType.setStyle(Style.EMPTY.withClickEvent(click).withHoverEvent(hover));
root.append(fileType);
root.append("]");
}
}
this.broadcastNoMirror(root);
}
}
Aggregations