use of net.minecraft.text.OrderedText in project BedrockIfy by juancarloscp52.
the class ChatHudMixin method render.
/**
* Use bedrock-like chat if enabled.
*/
@Inject(method = "render", at = @At("HEAD"), cancellable = true)
private void render(MatrixStack matrixStack, int ticks, CallbackInfo info) {
if (!settings.isBedrockChatEnabled())
return;
if (!this.isChatHidden()) {
this.processMessageQueue();
int visibleLines = Math.min(this.getVisibleLineCount(), this.getAvailableLines());
int visibleMessagesCount = this.visibleMessages.size();
if (visibleMessagesCount > 0) {
boolean isChatFocused = this.isChatFocused();
int posY = settings.getPositionHUDHeight() + (settings.getPositionHUDHeight() < 50 ? 50 : 0) + (settings.isShowPositionHUDEnabled() ? 10 : 0) + (settings.getFPSHUDoption() == 2 ? 10 : 0) + settings.getScreenSafeArea();
double chatScale = this.getChatScale();
int scaledChatWidth = MathHelper.ceil((double) this.getWidth() / chatScale);
RenderSystem.pushMatrix();
RenderSystem.translatef(settings.getScreenSafeArea(), (float) (48 - MinecraftClient.getInstance().getWindow().getScaledHeight() + (counter1 * (9.0D * chatScale * (this.client.options.chatLineSpacing + 1.0D)))) + posY, 0.0F);
RenderSystem.scaled(chatScale, chatScale, 1.0D);
double textOpacity = this.client.options.chatOpacity * 0.9D + 0.1D;
double backgroundOpacity = this.client.options.textBackgroundOpacity;
double chatLineSpacing1 = 9.0D * (this.client.options.chatLineSpacing + 1.0D);
double chatLineSpacing2 = -8.0D * (this.client.options.chatLineSpacing + 1.0D) + 4.0D * this.client.options.chatLineSpacing;
// Shown messages
counter1 = 0;
for (int i = 0; i + this.scrolledLines < this.visibleMessages.size() && i < visibleLines; ++i) {
ChatHudLine<OrderedText> chatHudLine = this.visibleMessages.get(i + this.scrolledLines);
if (chatHudLine != null) {
int ticksSinceCreation;
ticksSinceCreation = ticks - chatHudLine.getCreationTick();
if (ticksSinceCreation < 200 || isChatFocused) {
double opacityMultiplayer = isChatFocused ? 1.0D : getMessageOpacityMultiplier(ticksSinceCreation);
int finalTextOpacity = (int) (255.0D * opacityMultiplayer * textOpacity);
int finalBackgroundOpacity = (int) (255.0D * opacityMultiplayer * backgroundOpacity);
++counter1;
if (finalTextOpacity > 3) {
double currentMessageHeight = (double) (-i) * chatLineSpacing1;
matrixStack.push();
matrixStack.translate(0, 0, 0);
fill(matrixStack, 0, (int) currentMessageHeight, scaledChatWidth + 4, (int) (currentMessageHeight - chatLineSpacing1), finalBackgroundOpacity << 24);
RenderSystem.enableBlend();
matrixStack.translate(0, 0, 0);
this.client.textRenderer.drawWithShadow(matrixStack, chatHudLine.getText(), 2F, (float) ((int) (currentMessageHeight + chatLineSpacing2)), 16777215 + (finalTextOpacity << 24));
RenderSystem.disableAlphaTest();
RenderSystem.disableBlend();
matrixStack.pop();
}
}
}
}
// Unread Messages:
if (!this.messageQueue.isEmpty()) {
int textOpacityFinal = (int) (128.0D * textOpacity);
int backgroundOpacityFinal = (int) (255.0D * backgroundOpacity);
matrixStack.push();
matrixStack.translate(0.0D, 0.0D, 50.0D);
fill(matrixStack, -2, 0, scaledChatWidth + 4, 9, backgroundOpacityFinal << 24);
RenderSystem.enableBlend();
matrixStack.translate(0.0D, 0.0D, 50.0D);
this.client.textRenderer.drawWithShadow(matrixStack, new TranslatableText("chat.queue", this.messageQueue.size()), 2F, 1.0F, 16777215 + (textOpacityFinal << 24));
matrixStack.pop();
RenderSystem.disableAlphaTest();
RenderSystem.disableBlend();
}
if (isChatFocused) {
int textSize = 9;
RenderSystem.translatef(-3.0F, 0.0F, 0.0F);
int x = visibleMessagesCount * textSize + visibleMessagesCount;
int renderedMessages = counter1 * textSize + counter1;
int z = this.scrolledLines * renderedMessages / visibleMessagesCount;
int aa = renderedMessages * renderedMessages / x;
if (x != renderedMessages) {
int alpha = z > 0 ? 170 : 96;
int color = this.hasUnreadNewMessages ? 13382451 : 3355562;
fill(matrixStack, 2, -z, 2, -z - aa, color + (alpha << 24));
fill(matrixStack, 4, -z, 1, -z - aa, 13421772 + (alpha << 24));
}
}
RenderSystem.popMatrix();
}
}
info.cancel();
}
use of net.minecraft.text.OrderedText in project AdvancedChatBox by DarkKronicle.
the class ChatSuggestorGui method render.
public void render(MatrixStack matrices, int mouseX, int mouseY) {
if (this.window != null) {
this.window.render(matrices, mouseX, mouseY);
} else {
int i = 0;
for (OrderedText message : this.messages) {
i++;
int j = this.chatScreenSized ? this.owner.height - 14 - 13 - 12 * i : 72 + 12 * i;
DrawableHelper.fill(matrices, this.x - 1, j, this.x + this.width + 1, j + 12, ChatBoxConfigStorage.General.BACKGROUND_COLOR.config.get().color());
if (message != null) {
this.textRenderer.drawWithShadow(matrices, message, (float) this.x, (float) (j + 2), -1);
}
}
}
}
use of net.minecraft.text.OrderedText in project AdvancedChatBox by DarkKronicle.
the class ChatSuggestorGui method formatException.
private static OrderedText formatException(CommandSyntaxException exception) {
Text text = Texts.toText(exception.getRawMessage());
String string = exception.getContext();
return string == null ? text.asOrderedText() : (new TranslatableText("command.context.parse_error", text, exception.getCursor(), string)).asOrderedText();
}
use of net.minecraft.text.OrderedText in project Client by MatHax.
the class BookTooltipComponent method drawItems.
@Override
public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer, int z) {
// Background
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderTexture(0, TEXTURE_BOOK_BACKGROUND);
DrawableHelper.drawTexture(matrices, x, y, z, 12, 0, 112, 134, 179, 179);
// Content
matrices.push();
matrices.translate(x + 16, y + 12, z + 1);
matrices.scale(0.7f, 0.7f, 1f);
int offset = 0;
for (OrderedText line : textRenderer.wrapLines(page, 112)) {
textRenderer.draw(matrices, line, 0, offset, 0x000000);
offset += 8;
}
matrices.pop();
}
use of net.minecraft.text.OrderedText in project reeses-sodium-options by FlashyReese.
the class OptionPageScrollFrame method renderOptionTooltip.
private void renderOptionTooltip(MatrixStack matrixStack, int mouseX, int mouseY, ControlElement<?> element) {
if (this.lastTime + 500 > System.currentTimeMillis())
return;
Dim2i dim = element.getDimensions();
int textPadding = 3;
int boxPadding = 3;
int boxWidth = dim.width();
// Offset based on mouse position, width and height of content and width and height of the window
int boxY = dim.getLimitY();
int boxX = dim.x();
Option<?> option = element.getOption();
List<OrderedText> tooltip = new ArrayList<>(MinecraftClient.getInstance().textRenderer.wrapLines(option.getTooltip(), boxWidth - (textPadding * 2)));
OptionImpact impact = option.getImpact();
if (impact != null) {
tooltip.add(Language.getInstance().reorder(new TranslatableText("sodium.options.performance_impact_string", impact.getLocalizedName()).formatted(Formatting.GRAY)));
}
int boxHeight = (tooltip.size() * 12) + boxPadding;
int boxYLimit = boxY + boxHeight;
int boxYCutoff = this.dim.getLimitY();
// If the box is going to be cutoff on the Y-axis, move it back up the difference
if (boxYLimit > boxYCutoff) {
boxY -= boxHeight + dim.height();
}
if (boxY < 0) {
boxY = dim.getLimitY();
}
this.drawRect(boxX, boxY, boxX + boxWidth, boxY + boxHeight, 0xE0000000);
this.drawRectOutline(boxX, boxY, boxX + boxWidth, boxY + boxHeight, 0xFF94E4D3);
for (int i = 0; i < tooltip.size(); i++) {
MinecraftClient.getInstance().textRenderer.draw(matrixStack, tooltip.get(i), boxX + textPadding, boxY + textPadding + (i * 12), 0xFFFFFFFF);
}
}
Aggregations