From 8981a2f730942e169ba5efa2f25ad3066dc0f797 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Tue, 16 Apr 2024 01:34:03 +0900 Subject: Fix merge conflicts --- .../config/entries/ConfigureCategoriesScreen.java | 10 +- .../impl/client/gui/config/REIConfigScreen.java | 27 +++--- .../components/ConfigCategoryEntryWidget.java | 30 +++--- .../gui/config/components/ConfigGroupWidget.java | 13 ++- .../config/components/ConfigOptionValueWidget.java | 6 +- .../gui/config/components/ConfigOptionWidget.java | 12 +-- .../gui/config/components/ConfigSearchWidget.java | 16 ++-- .../configure/PanelBoundariesConfiguration.java | 28 +++--- .../preview/AccessibilityDisplayPreviewer.java | 2 +- .../config/options/preview/TooltipPreviewer.java | 18 ++-- .../gui/screen/UncertainDisplayViewingScreen.java | 4 +- .../collapsible/CollapsibleEntriesScreen.java | 43 +++++---- .../screen/collapsible/CollapsibleEntryWidget.java | 102 +++++++++++---------- .../CustomCollapsibleEntrySelectionScreen.java | 47 +++++----- .../client/gui/widget/DisplayCompositeWidget.java | 4 +- .../client/gui/widget/DisplayTooltipComponent.java | 2 +- .../widget/DynamicErrorFreeEntryListWidget.java | 4 +- .../rei/impl/client/gui/widget/HoleWidget.java | 8 +- .../rei/impl/client/gui/widget/ListWidget.java | 7 +- .../client/gui/widget/MergedWidgetWithBounds.java | 11 +-- .../impl/client/gui/widget/ScissoredWidget.java | 10 +- .../client/gui/widget/ScrollableViewWidget.java | 8 +- .../impl/client/gui/widget/TabContainerWidget.java | 19 ++-- .../rei/impl/client/gui/widget/VStackWidget.java | 2 +- .../gui/widget/region/EntryStacksRegionWidget.java | 26 +++--- .../client/runtime/DefaultClientRuntimePlugin.java | 22 ++--- 26 files changed, 242 insertions(+), 239 deletions(-) diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigureCategoriesScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigureCategoriesScreen.java index 229c8dba0..3199e2575 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigureCategoriesScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigureCategoriesScreen.java @@ -280,22 +280,22 @@ public class ConfigureCategoriesScreen extends Screen { { Component subtitle = Component.translatable("config.roughlyenoughitems.configureCategories.visibility." + shown) .withStyle(shown ? ChatFormatting.GREEN : ChatFormatting.RED); - int i = client.font.drawShadow(matrices, subtitle.getVisualOrderText(), xPos, y + 22, 8421504); + int i = graphics.drawString(client.font, subtitle.getVisualOrderText(), xPos, y + 22, 8421504); visibilityToggleButton.getPoint().setLocation(i + 3, y + 22); - visibilityToggleButton.render(matrices, mouseX, mouseY, delta); + visibilityToggleButton.render(graphics, mouseX, mouseY, delta); } if (shown) { Component subtitle = Component.translatable("config.roughlyenoughitems.filtering.filteringQuickCraftCategories.configure." + filteringQuickCraftCategories.getOrDefault(configuration.getCategoryIdentifier(), configuration.isQuickCraftingEnabledByDefault())) .withStyle(ChatFormatting.GRAY); - int i = client.font.drawShadow(matrices, subtitle.getVisualOrderText(), xPos, y + 32, 8421504); + int i = graphics.drawString(client.font, subtitle.getVisualOrderText(), xPos, y + 32, 8421504); quickCraftToggleButton.getPoint().setLocation(i + 3, y + 32); - quickCraftToggleButton.render(matrices, mouseX, mouseY, delta); + quickCraftToggleButton.render(graphics, mouseX, mouseY, delta); } else { quickCraftToggleButton.getPoint().setLocation(-12390, -12390); } upButton.setX(x + entryWidth - 20); upButton.setY(y + entryHeight / 2 - 21); - upButton.render(matrices, mouseX, mouseY, delta); + upButton.render(graphics, mouseX, mouseY, delta); downButton.setX(x + entryWidth - 20); downButton.setY(y + entryHeight / 2 + 1); downButton.render(graphics, mouseX, mouseY, delta); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/REIConfigScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/REIConfigScreen.java index 6ce0d98c8..d1cdccd00 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/REIConfigScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/REIConfigScreen.java @@ -25,7 +25,6 @@ package me.shedaniel.rei.impl.client.gui.config; import com.google.common.base.Preconditions; import com.mojang.blaze3d.platform.InputConstants; -import com.mojang.blaze3d.vertex.PoseStack; import dev.architectury.utils.value.IntValue; import me.shedaniel.clothconfig2.api.Modifier; import me.shedaniel.clothconfig2.api.ModifierKeyCode; @@ -54,7 +53,7 @@ import me.shedaniel.rei.impl.client.gui.widget.HoleWidget; import me.shedaniel.rei.impl.client.gui.widget.basewidgets.TextFieldWidget; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.resources.language.I18n; @@ -142,27 +141,27 @@ public class REIConfigScreen extends Screen implements ConfigAccess { this.widgets.add(HoleWidget.createBackground(new Rectangle(8 + sideWidth + 4, 32, width - 16 - sideWidth - 4, 20), () -> 0, 32)); TextFieldWidget textField = new TextFieldWidget(new Rectangle(8 + sideWidth + 4 + 6, 32 + 6, width - 16 - sideWidth - 4 - 10, 12)) { @Override - protected void renderSuggestion(PoseStack matrices, int x, int y) { + protected void renderSuggestion(GuiGraphics graphics, int x, int y) { int color; if (containsMouse(PointHelper.ofMouse()) || isFocused()) { color = 0xddeaeaea; } else { color = -6250336; } - this.font.drawShadow(matrices, this.font.plainSubstrByWidth(this.getSuggestion(), this.getWidth()), x, y, color); + graphics.drawString(this.font, this.font.plainSubstrByWidth(this.getSuggestion(), this.getWidth()), x, y, color); } }; textField.setHasBorder(false); textField.setMaxLength(9000); this.widgets.add(textField); - this.widgets.add(Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> { + this.widgets.add(Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> { textField.setSuggestion(!textField.isFocused() && textField.getText().isEmpty() ? I18n.get("config.rei.texts.search_options") : null); if (!textField.isFocused()) return; Rectangle bounds = textField.getBounds(); - GuiComponent.fill(matrices, bounds.x - 6, bounds.y - 6, bounds.getMaxX() + 4, bounds.y - 5, 0xffe0e0e0); - GuiComponent.fill(matrices, bounds.x - 6, bounds.getMaxY() + 1, bounds.getMaxX() + 4, bounds.getMaxY() + 2, 0xffe0e0e0); - GuiComponent.fill(matrices, bounds.x - 6, bounds.y - 6, bounds.x - 7, bounds.getMaxY() + 2, 0xffe0e0e0); - GuiComponent.fill(matrices, bounds.getMaxX() + 3, bounds.y - 6, bounds.getMaxX() + 4, bounds.getMaxY() + 2, 0xffe0e0e0); + graphics.fill(bounds.x - 6, bounds.y - 6, bounds.getMaxX() + 4, bounds.y - 5, 0xffe0e0e0); + graphics.fill(bounds.x - 6, bounds.getMaxY() + 1, bounds.getMaxX() + 4, bounds.getMaxY() + 2, 0xffe0e0e0); + graphics.fill(bounds.x - 6, bounds.y - 6, bounds.x - 7, bounds.getMaxY() + 2, 0xffe0e0e0); + graphics.fill(bounds.getMaxX() + 3, bounds.y - 6, bounds.getMaxX() + 4, bounds.getMaxY() + 2, 0xffe0e0e0); })); this.widgets.add(ConfigSearchListWidget.create(this, this.categories, textField, new Rectangle(8, 32 + 20 + 4, width - 16, height - 32 - (32 + 20 + 4)))); } else { @@ -224,13 +223,13 @@ public class REIConfigScreen extends Screen implements ConfigAccess { } @Override - public void render(PoseStack poses, int mouseX, int mouseY, float delta) { - this.renderDirtBackground(poses); - super.render(poses, mouseX, mouseY, delta); + public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { + this.renderDirtBackground(graphics); + super.render(graphics, mouseX, mouseY, delta); for (Widget widget : widgets) { - widget.render(poses, mouseX, mouseY, delta); + widget.render(graphics, mouseX, mouseY, delta); } - ScreenOverlayImpl.getInstance().lateRender(poses, mouseX, mouseY, delta); + ScreenOverlayImpl.getInstance().lateRender(graphics, mouseX, mouseY, delta); } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/components/ConfigCategoryEntryWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/components/ConfigCategoryEntryWidget.java index e682dbe23..e6f7332ae 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/components/ConfigCategoryEntryWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/components/ConfigCategoryEntryWidget.java @@ -23,7 +23,6 @@ package me.shedaniel.rei.impl.client.gui.config.components; -import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.widgets.*; @@ -33,6 +32,7 @@ import me.shedaniel.rei.impl.client.gui.config.options.OptionCategory; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; import net.minecraft.util.FormattedCharSequence; @@ -47,8 +47,8 @@ public class ConfigCategoryEntryWidget { .leftAligned(); Font font = Minecraft.getInstance().font; MutableComponent description = category.getDescription().copy().withStyle(style -> style.withColor(0xFF909090)); - Widget descriptionLabel = Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> { - renderTextScrolling(matrices, description, 0, 0, (int) ((width - 21 - 6) / 0.75), 0xFF909090); + Widget descriptionLabel = Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> { + renderTextScrolling(graphics, description, 0, 0, (int) ((width - 21 - 6) / 0.75), 0xFF909090); }); Rectangle bounds = new Rectangle(0, 0, label.getBounds().getMaxX(), hasDescription ? 24 : 7 * 3); return Widgets.concatWithBounds( @@ -69,25 +69,25 @@ public class ConfigCategoryEntryWidget { ); } - private static void renderTextScrolling(PoseStack poses, Component text, int x, int y, int width, int color) { - renderTextScrolling(poses, text.getVisualOrderText(), x, y, width, color); + private static void renderTextScrolling(GuiGraphics graphics, Component text, int x, int y, int width, int color) { + renderTextScrolling(graphics, text.getVisualOrderText(), x, y, width, color); } - private static void renderTextScrolling(PoseStack poses, FormattedCharSequence text, int x, int y, int width, int color) { - try (CloseableScissors scissors = scissor(poses, new Rectangle(x, y, width, y + 9))) { + private static void renderTextScrolling(GuiGraphics graphics, FormattedCharSequence text, int x, int y, int width, int color) { + try (CloseableScissors scissors = scissor(graphics, new Rectangle(x, y, width, y + 9))) { Font font = Minecraft.getInstance().font; int textWidth = font.width(text); - textWidth = MatrixUtils.transform(MatrixUtils.inverse(poses.last().pose()), new Rectangle(0, 0, textWidth, 100)).width; - width = MatrixUtils.transform(MatrixUtils.inverse(poses.last().pose()), new Rectangle(0, 0, width, 100)).width; + textWidth = MatrixUtils.transform(MatrixUtils.inverse(graphics.pose().last().pose()), new Rectangle(0, 0, textWidth, 100)).width; + width = MatrixUtils.transform(MatrixUtils.inverse(graphics.pose().last().pose()), new Rectangle(0, 0, width, 100)).width; if (textWidth > width && !ConfigUtils.isReducedMotion()) { - poses.pushPose(); + graphics.pose().pushPose(); float textX = (System.currentTimeMillis() % ((textWidth + 10) * textWidth / 3)) / (float) textWidth * 3; - poses.translate(-textX, 0, 0); - font.drawShadow(poses, text, x + width - textWidth - 10, y, color); - font.drawShadow(poses, text, x + width, y, color); - poses.popPose(); + graphics.pose().translate(-textX, 0, 0); + graphics.drawString(font, text, x + width - textWidth - 10, y, color); + graphics.drawString(font, text, x + width, y, color); + graphics.pose().popPose(); } else { - font.drawShadow(poses, text, x, y, color); + graphics.drawString(font, text, x, y, color); } } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/components/ConfigGroupWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/components/ConfigGroupWidget.java index 161a38f69..c5ad01340 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/components/ConfigGroupWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/components/ConfigGroupWidget.java @@ -37,7 +37,6 @@ import me.shedaniel.rei.impl.client.gui.config.options.preview.AccessibilityDisp import me.shedaniel.rei.impl.client.gui.config.options.preview.InterfacePreviewer; import me.shedaniel.rei.impl.client.gui.config.options.preview.TooltipPreviewer; import me.shedaniel.rei.impl.client.gui.text.TextTransformations; -import net.minecraft.client.gui.GuiComponent; import org.apache.commons.lang3.tuple.Pair; import org.jetbrains.annotations.Nullable; import org.joml.Matrix4f; @@ -110,16 +109,16 @@ public class ConfigGroupWidget { widgets.add(WidgetComposite.of(ConfigOptionWidget.create(access, option, width))); if (entry.getOptions().get(entry.getOptions().size() - 1) != option) { - Widget separator = Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> { + Widget separator = Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> { for (int x = 0; x <= width; x += 4) { - GuiComponent.fill(matrices, Math.min(width, x), 1, Math.min(width, x + 2), 2, 0xFF757575); + graphics.fill(Math.min(width, x), 1, Math.min(width, x + 2), 2, 0xFF757575); } }); widgets.add(WidgetComposite.of(Widgets.withBounds(separator, new Rectangle(0, 0, 1, 7)))); } } - widgets.add(WidgetComposite.ofNonAccounting(Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> { + widgets.add(WidgetComposite.ofNonAccounting(Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> { recalculateHeight(widgets, i -> height[0] = i); }))); recalculateHeight(widgets, i -> height[0] = i); @@ -172,10 +171,10 @@ public class ConfigGroupWidget { } private static Widget createBackgroundSlot(Supplier bounds) { - return Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> { + return Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> { Rectangle rectangle = bounds.get(); - GuiComponent.fill(matrices, rectangle.x, rectangle.y, rectangle.getMaxX(), rectangle.getMaxY(), 0xFF333333); - GuiComponent.fill(matrices, rectangle.x + 1, rectangle.y + 1, rectangle.getMaxX() - 1, rectangle.getMaxY() - 1, 0xFF000000); + graphics.fill(rectangle.x, rectangle.y, rectangle.getMaxX(), rectangle.getMaxY(), 0xFF333333); + graphics.fill(rectangle.x + 1, rectangle.y + 1, rectangle.getMaxX() - 1, rectangle.getMaxY() - 1, 0xFF000000); }); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/components/ConfigOptionValueWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/components/ConfigOptionValueWidget.java index 7d605ccbe..a469a95b5 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/components/ConfigOptionValueWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/components/ConfigOptionValueWidget.java @@ -23,7 +23,6 @@ package me.shedaniel.rei.impl.client.gui.config.components; -import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.clothconfig2.api.ModifierKeyCode; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; @@ -42,6 +41,7 @@ import me.shedaniel.rei.impl.client.gui.modules.entries.ToggleMenuEntry; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.FormattedText; @@ -113,7 +113,7 @@ public class ConfigOptionValueWidget { return Widgets.concatWithBounds(() -> new Rectangle(-label.getBounds().width, 0, label.getBounds().width + 8, 14), label, - Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> matrix[0] = matrices.last().pose()), + Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> matrix[0] = graphics.pose().last().pose()), Widgets.withTranslate(Widgets.createTexturedWidget(new ResourceLocation("roughlyenoughitems:textures/gui/config/selector.png"), new Rectangle(1, 1, 4, 6), 0, 0, 1, 1, 1, 1), 0, 0.5, 0) ); @@ -151,7 +151,7 @@ public class ConfigOptionValueWidget { access.closeMenu(); access.focusKeycode((CompositeOption) option); }); - BiConsumer render = label.getOnRender(); + BiConsumer render = label.getOnRender(); label.onRender((poses, $) -> { render.accept(poses, $); setText.accept(((ModifierKeyCode) access.get(option)).getLocalizedName()); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/components/ConfigOptionWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/components/ConfigOptionWidget.java index ec6ee275c..e695d79b0 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/components/ConfigOptionWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/components/ConfigOptionWidget.java @@ -23,7 +23,6 @@ package me.shedaniel.rei.impl.client.gui.config.components; -import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.clothconfig2.api.ScissorsHandler; import me.shedaniel.clothconfig2.api.animator.NumberAnimator; import me.shedaniel.clothconfig2.api.animator.ValueAnimator; @@ -40,6 +39,7 @@ import me.shedaniel.rei.impl.client.gui.config.options.ConfigUtils; import me.shedaniel.rei.impl.client.gui.text.TextTransformations; import net.minecraft.Util; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.network.chat.MutableComponent; import net.minecraft.util.FormattedCharSequence; @@ -106,13 +106,13 @@ public class ConfigOptionWidget { } @Override - public void render(PoseStack poses, int mouseX, int mouseY, float delta) { + public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { this.previewHeight.update(delta); if (ConfigUtils.isReducedMotion()) this.previewHeight.completeImmediately(); height[0] = stableHeight[0] + Math.round(this.previewHeight.value()); for (int i = 0; i < split.size(); i++) { - Minecraft.getInstance().font.draw(poses, split.get(i), 0, 12 + 12 * i, -1); + graphics.drawString(Minecraft.getInstance().font, split.get(i), 0, 12 + 12 * i, -1, false); } if (hasPreview) { @@ -122,12 +122,12 @@ public class ConfigOptionWidget { this.previewLabel.setPoint(new Point(width, 12 + 12 * split.size() - 12)); } - this.previewLabel.render(poses, mouseX, mouseY, delta); + this.previewLabel.render(graphics, mouseX, mouseY, delta); if (this.preview != null && this.previewHeight.value() > 0.1f) { - ScissorsHandler.INSTANCE.scissor(MatrixUtils.transform(poses.last().pose(), new Rectangle(0, 24 + 12 * split.size() - (nextLinePreview ? 0 : 12), width, this.previewHeight.value()))); + ScissorsHandler.INSTANCE.scissor(MatrixUtils.transform(graphics.pose().last().pose(), new Rectangle(0, 24 + 12 * split.size() - (nextLinePreview ? 0 : 12), width, this.previewHeight.value()))); this.previewTranslation = new Matrix4f().translate(0, 12 + 12 * split.size(), 100); - this.preview.render(poses, mouseX, mouseY, delta); + this.preview.render(graphics, mouseX, mouseY, delta); ScissorsHandler.INSTANCE.removeLastScissor(); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/components/ConfigSearchWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/components/ConfigSearchWidget.java index d68ff3933..f910d88e0 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/components/ConfigSearchWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/components/ConfigSearchWidget.java @@ -23,7 +23,6 @@ package me.shedaniel.rei.impl.client.gui.config.components; -import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.widgets.Label; @@ -36,6 +35,7 @@ import me.shedaniel.rei.impl.client.gui.config.options.OptionCategory; import me.shedaniel.rei.impl.client.gui.config.options.OptionGroup; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.resources.ResourceLocation; @@ -56,14 +56,14 @@ public class ConfigSearchWidget { bounds, new Widget() { @Override - public void render(PoseStack poses, int mouseX, int mouseY, float delta) { + public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { boolean hovering = new Rectangle(-1, -1, width.getAsInt() + 2, 21).contains(mouseX, mouseY); for (Widget widget : List.of(Widgets.createFilledRectangle(new Rectangle(1, 1, width.getAsInt() - 2, 18), hovering ? 0x50FFFFFF : 0x25FFFFFF), Widgets.createFilledRectangle(new Rectangle(-1, -1, width.getAsInt() + 2, 1), hovering ? 0x90FFFFFF : 0x45FFFFFF), Widgets.createFilledRectangle(new Rectangle(-1, 20, width.getAsInt() + 2, 1), hovering ? 0x90FFFFFF : 0x45FFFFFF), Widgets.createFilledRectangle(new Rectangle(-1, 0, 1, 20), hovering ? 0x90FFFFFF : 0x45FFFFFF), Widgets.createFilledRectangle(new Rectangle(width.getAsInt(), 0, 1, 20), hovering ? 0x90FFFFFF : 0x45FFFFFF))) { - widget.render(poses, mouseX, mouseY, delta); + widget.render(graphics, mouseX, mouseY, delta); } label.setColor(hovering ? 0xFFE1E1E1 : 0xFFC0C0C0); } @@ -96,18 +96,18 @@ public class ConfigSearchWidget { bounds, new Widget() { @Override - public void render(PoseStack poses, int mouseX, int mouseY, float delta) { + public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { boolean hovering = new Rectangle(-1, -1, 18, 18).contains(mouseX, mouseY); - poses.pushPose(); - poses.translate(-0.5, -0.5, 0); + graphics.pose().pushPose(); + graphics.pose().translate(-0.5, -0.5, 0); for (Widget widget : List.of(Widgets.createFilledRectangle(new Rectangle(-1, -1, 18, 18), hovering ? 0x50FFFFFF : 0x25FFFFFF), Widgets.createFilledRectangle(new Rectangle(-3, -3, 22, 1), hovering ? 0x90FFFFFF : 0x45FFFFFF), Widgets.createFilledRectangle(new Rectangle(-3, 18, 22, 1), hovering ? 0x90FFFFFF : 0x45FFFFFF), Widgets.createFilledRectangle(new Rectangle(-3, -2, 1, 20), hovering ? 0x90FFFFFF : 0x45FFFFFF), Widgets.createFilledRectangle(new Rectangle(18, -2, 1, 20), hovering ? 0x90FFFFFF : 0x45FFFFFF))) { - widget.render(poses, mouseX, mouseY, delta); + widget.render(graphics, mouseX, mouseY, delta); } - poses.popPose(); + graphics.pose().popPose(); } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/configure/PanelBoundariesConfiguration.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/configure/PanelBoundariesConfiguration.java index b8e3e619e..0530ba503 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/configure/PanelBoundariesConfiguration.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/configure/PanelBoundariesConfiguration.java @@ -23,7 +23,6 @@ package me.shedaniel.rei.impl.client.gui.config.options.configure; -import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.clothconfig2.api.animator.NumberAnimator; import me.shedaniel.clothconfig2.api.animator.ValueAnimator; import me.shedaniel.math.FloatingRectangle; @@ -38,6 +37,7 @@ import me.shedaniel.rei.impl.client.gui.config.options.OptionValueEntry; import net.minecraft.ChatFormatting; import net.minecraft.Util; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractSliderButton; import net.minecraft.client.gui.components.Checkbox; import net.minecraft.client.gui.screens.Screen; @@ -268,19 +268,19 @@ public enum PanelBoundariesConfiguration implements OptionValueEntry.Configurato } @Override - public void render(PoseStack poses, int mouseX, int mouseY, float delta) { + public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { this.innerAlphaAnimator.setTarget(this.innerAlphaAnimator.target() + (1.0F - this.innerAlphaAnimator.target()) * 0.06F); this.innerAlphaAnimator.update(delta); - this.renderBackground(poses); + this.renderBackground(graphics); Rectangle panelBounds = new Rectangle(this.width * 3 / 10, this.height * 4 / 40, this.width * 4 / 10, this.height * 32 / 40); - Widgets.createCategoryBase(panelBounds).render(poses, mouseX, mouseY, delta); + Widgets.createCategoryBase(panelBounds).render(graphics, mouseX, mouseY, delta); int y = panelBounds.y + 6; - this.font.draw(poses, translatable("config.rei.options.layout.boundaries.desc.configure").withStyle(ChatFormatting.UNDERLINE), panelBounds.x + 6, y, 0xff404040); + graphics.drawString(this.font, translatable("config.rei.options.layout.boundaries.desc.configure").withStyle(ChatFormatting.UNDERLINE), panelBounds.x + 6, y, 0xff404040, false); y += 14; - this.font.draw(poses, translatable("config.rei.options.layout.boundaries.desc.horizontal"), panelBounds.x + 6, y, 0xff404040); + graphics.drawString(this.font, translatable("config.rei.options.layout.boundaries.desc.horizontal"), panelBounds.x + 6, y, 0xff404040, false); this.horizontalLimit.setX(panelBounds.x + 6); this.horizontalLimit.setY(y + 10); - this.font.draw(poses, translatable("config.rei.options.layout.boundaries.desc.limit_by_percentage"), horizontalLimit.getX() + 24, horizontalLimit.getY() + 6, 0xff404040); + graphics.drawString(this.font, translatable("config.rei.options.layout.boundaries.desc.limit_by_percentage"), horizontalLimit.getX() + 24, horizontalLimit.getY() + 6, 0xff404040, false); y += 32; this.horizontalSlider.setX(panelBounds.x + 6); this.horizontalSlider.setY(y); @@ -291,10 +291,10 @@ public enum PanelBoundariesConfiguration implements OptionValueEntry.Configurato this.horizontalAlignmentSlider.setWidth(panelBounds.width - 12); y += 28; - this.font.draw(poses, translatable("config.rei.options.layout.boundaries.desc.vertical"), panelBounds.x + 6, y, 0xff404040); + graphics.drawString(this.font, translatable("config.rei.options.layout.boundaries.desc.vertical"), panelBounds.x + 6, y, 0xff404040, false); this.verticalLimit.setX(panelBounds.x + 6); this.verticalLimit.setY(y + 10); - this.font.draw(poses, translatable("config.rei.options.layout.boundaries.desc.limit_by_percentage"), verticalLimit.getX() + 24, verticalLimit.getY() + 6, 0xff404040); + graphics.drawString(this.font, translatable("config.rei.options.layout.boundaries.desc.limit_by_percentage"), verticalLimit.getX() + 24, verticalLimit.getY() + 6, 0xff404040, false); y += 32; this.verticalSlider.setX(panelBounds.x + 6); this.verticalSlider.setY(y); @@ -304,11 +304,11 @@ public enum PanelBoundariesConfiguration implements OptionValueEntry.Configurato this.verticalAlignmentSlider.setY(y); this.verticalAlignmentSlider.setWidth(panelBounds.width - 12); - super.render(poses, mouseX, mouseY, delta); - renderPreview(poses, panelBounds, delta); + super.render(graphics, mouseX, mouseY, delta); + renderPreview(graphics, panelBounds, delta); } - private void renderPreview(PoseStack poses, Rectangle panelBounds, float delta) { + private void renderPreview(GuiGraphics graphics, Rectangle panelBounds, float delta) { int entrySize = Mth.ceil(18 * access.get(AllREIConfigOptions.ZOOM)); Rectangle overlayBounds; DisplayPanelLocation location = access.get(AllREIConfigOptions.LOCATION); @@ -343,7 +343,7 @@ public enum PanelBoundariesConfiguration implements OptionValueEntry.Configurato }) || isReducedMotion() ? 0 : 200); overlayBounds = this.boundsAnimator.value().getBounds(); - this.fillGradient(poses, overlayBounds.x, overlayBounds.y, overlayBounds.getMaxX(), overlayBounds.getMaxY(), 0x80fff0ad, 0x80fff0ad); + graphics.fillGradient(overlayBounds.x, overlayBounds.y, overlayBounds.getMaxX(), overlayBounds.getMaxY(), 0x80fff0ad, 0x80fff0ad); int width = Math.max(Mth.floor((overlayBounds.width - 2) / (float) entrySize), 1); int height = Math.max(Mth.floor((overlayBounds.height - 2) / (float) entrySize), 1); @@ -353,7 +353,7 @@ public enum PanelBoundariesConfiguration implements OptionValueEntry.Configurato for (int j = 0; j < height; j++) { int slotX = innerBounds.x + i * entrySize + 1; int slotY = innerBounds.y + j * entrySize + 1; - this.fillGradient(poses, slotX, slotY, slotX + entrySize - 2, slotY + entrySize - 2, color, color); + graphics.fillGradient(slotX, slotY, slotX + entrySize - 2, slotY + entrySize - 2, color, color); } } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/preview/AccessibilityDisplayPreviewer.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/preview/AccessibilityDisplayPreviewer.java index ccebdab45..f708ca875 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/preview/AccessibilityDisplayPreviewer.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/preview/AccessibilityDisplayPreviewer.java @@ -49,7 +49,7 @@ public class AccessibilityDisplayPreviewer { Widgets.scissored(new Rectangle(1, 1, width - 2, 34 + 17), Widgets.createCategoryBase(new Rectangle(width / 2 - 28 * 3 / 2 - 10, 30 + 17, 28 * 3 + 20, 28))), Widgets.delegate(() -> MoreObjects.firstNonNull(selected[0] < 4 ? tabs[selected[0]] : null, Widgets.noOp())), Widgets.delegate(() -> MoreObjects.firstNonNull(buttons[0], Widgets.noOp())), - Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> { + Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> { boolean largerTabs = access.get(AllREIConfigOptions.LARGER_TABS); boolean largerArrowButtons = access.get(AllREIConfigOptions.LARGER_ARROW_BUTTONS); int tabSize = largerTabs ? 28 : 24; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/preview/TooltipPreviewer.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/preview/TooltipPreviewer.java index bc1922412..f3f4d6820 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/preview/TooltipPreviewer.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/preview/TooltipPreviewer.java @@ -53,7 +53,7 @@ import java.util.stream.Stream; public class TooltipPreviewer { public static WidgetWithBounds create(ConfigAccess access, int width, @Nullable IntSupplier height) { Rectangle bounds = new Rectangle(); - return Widgets.withBounds(Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> { + return Widgets.withBounds(Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> { EntryStack stack = EntryStacks.of(Items.OAK_PLANKS); boolean appendModNames = access.get(AllREIConfigOptions.APPEND_MOD_NAMES); boolean appendFavorites = access.get(AllREIConfigOptions.APPEND_FAVORITES_HINT); @@ -72,17 +72,17 @@ public class TooltipPreviewer { int minHeight = components.stream().mapToInt(component -> components.get(0) == component && components.size() >= 2 ? 2 + 10 : 10).sum() + 4; int tX = Math.max(6, (width - minWidth) / 2), tWidth = Math.min(width - 12, minWidth), tY = 24 + 4, tHeight = Math.min(minHeight, height == null ? 100000 : height.getAsInt() - tY - 4); - matrices.pushPose(); - matrices.translate(0, height == null ? 4 : Math.max(0, (height.getAsInt() - (tY + tHeight)) / 2), 400); + graphics.pose().pushPose(); + graphics.pose().translate(0, height == null ? 4 : Math.max(0, (height.getAsInt() - (tY + tHeight)) / 2), 400); bounds.setSize(width, height == null ? tY + tHeight + 12 : height.getAsInt()); - stack.getRenderer().render(stack, matrices, new Rectangle(width / 2 - 12, 0, 24, 24), mouseX, mouseY, delta); + stack.getRenderer().render(stack, graphics, new Rectangle(width / 2 - 12, 0, 24, 24), mouseX, mouseY, delta); - matrices.translate(0, 0, -400); + graphics.pose().translate(0, 0, -400); Tesselator tesselator = Tesselator.getInstance(); BufferBuilder bufferBuilder = tesselator.getBuilder(); RenderSystem.setShader(GameRenderer::getPositionColorShader); bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); - Matrix4f matrix4f = matrices.last().pose(); + Matrix4f matrix4f = graphics.pose().last().pose(); fillGradient(matrix4f, bufferBuilder, tX - 3, tY - 4, tX + tWidth + 3, tY - 3, 400, -267386864, -267386864); fillGradient(matrix4f, bufferBuilder, tX - 3, tY + tHeight + 3, tX + tWidth + 3, tY + tHeight + 4, 400, -267386864, -267386864); fillGradient(matrix4f, bufferBuilder, tX - 3, tY - 3, tX + tWidth + 3, tY + tHeight + 3, 400, -267386864, -267386864); @@ -98,14 +98,14 @@ public class TooltipPreviewer { BufferUploader.drawWithShader(bufferBuilder.end()); RenderSystem.disableBlend(); - matrices.translate(0, 0, 400); + graphics.pose().translate(0, 0, 400); for (int i = 0; i < components.size(); i++) { - Minecraft.getInstance().font.draw(matrices, components.get(i), tX + 2, tY + 2, -1); + graphics.drawString(Minecraft.getInstance().font, components.get(i), tX + 2, tY + 2, -1, false); tY += 10 + (i == 0 ? 2 : 0); } - matrices.popPose(); + graphics.pose().popPose(); }), bounds); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/UncertainDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/UncertainDisplayViewingScreen.java index 9d9eaa12d..f72927df9 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/UncertainDisplayViewingScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/UncertainDisplayViewingScreen.java @@ -24,7 +24,6 @@ package me.shedaniel.rei.impl.client.gui.screen; import com.google.common.collect.Lists; -import com.mojang.blaze3d.systems.RenderSystem; import it.unimi.dsi.fastutil.booleans.BooleanConsumer; import me.shedaniel.clothconfig2.api.ScissorsHandler; import me.shedaniel.clothconfig2.gui.widget.DynamicNewSmoothScrollingEntryListWidget; @@ -48,7 +47,6 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.util.FormattedCharSequence; import net.minecraft.util.Mth; import org.jetbrains.annotations.ApiStatus; -import org.joml.Matrix4f; import java.util.Collections; import java.util.List; @@ -137,7 +135,7 @@ public class UncertainDisplayViewingScreen extends Screen { graphics.drawCenteredString(this.font, Component.translatable("text.rei.recipe_screen_type.selection"), this.width / 2, 20, 16777215); ScissorsHandler.INSTANCE.scissor(new Rectangle(0, 20 + font.lineHeight + 2, width, height - 42)); if (showTips) { - float i = 32; + int i = 32; for (FormattedCharSequence s : this.font.split(Component.translatable("text.rei.recipe_screen_type.selection.sub").withStyle(ChatFormatting.GRAY), width - 30)) { graphics.drawString(font, s, width / 2 - font.width(s) / 2, i, -1); i += 10; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntriesScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntriesScreen.java index 6c088cadf..c072e84e3 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntriesScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntriesScreen.java @@ -26,7 +26,10 @@ package me.shedaniel.rei.impl.client.gui.screen.collapsible; import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.*; +import com.mojang.blaze3d.vertex.BufferBuilder; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import com.mojang.blaze3d.vertex.Tesselator; +import com.mojang.blaze3d.vertex.VertexFormat; import me.shedaniel.clothconfig2.ClothConfigInitializer; import me.shedaniel.clothconfig2.api.scroll.ScrollingContainer; import me.shedaniel.math.Rectangle; @@ -49,7 +52,7 @@ import me.shedaniel.rei.impl.common.util.HashedEntryStackWrapper; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.Screen; @@ -168,7 +171,7 @@ public class CollapsibleEntriesScreen extends Screen { } @Override - public void render(PoseStack poses, int mouseX, int mouseY, float delta) { + public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { if (this.dirty) { this.listWidget.clear(); @@ -179,20 +182,20 @@ public class CollapsibleEntriesScreen extends Screen { this.dirty = false; } - this.listWidget.render(poses, mouseX, mouseY, delta); - super.render(poses, mouseX, mouseY, delta); - this.font.drawShadow(poses, this.title, this.width / 2.0F - this.font.width(this.title) / 2.0F, 12.0F, -1); + this.listWidget.render(graphics, mouseX, mouseY, delta); + super.render(graphics, mouseX, mouseY, delta); + graphics.drawString(this.font, this.title, this.width / 2 - this.font.width(this.title) / 2, 12, -1); if (ConfigObject.getInstance().doDebugRenderTimeRequired()) { Component debugText = Component.literal(String.format("%s fps", minecraft.fpsString.split(" ")[0])); int stringWidth = font.width(debugText); - fillGradient(poses, minecraft.screen.width - stringWidth - 2, 32, minecraft.screen.width, 32 + font.lineHeight + 2, -16777216, -16777216); + graphics.fillGradient(minecraft.screen.width - stringWidth - 2, 32, minecraft.screen.width, 32 + font.lineHeight + 2, -16777216, -16777216); MultiBufferSource.BufferSource immediate = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder()); - poses.pushPose(); - Matrix4f matrix = poses.last().pose(); + graphics.pose().pushPose(); + Matrix4f matrix = graphics.pose().last().pose(); font.drawInBatch(debugText.getVisualOrderText(), minecraft.screen.width - stringWidth, 32 + 2, -1, false, matrix, immediate, Font.DisplayMode.NORMAL, 0, 15728880); immediate.endBatch(); - poses.popPose(); + graphics.pose().popPose(); } } @@ -246,17 +249,17 @@ public class CollapsibleEntriesScreen extends Screen { } @Override - public void render(PoseStack poses, int mouseX, int mouseY, float delta) { + public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { this.scroller.updatePosition(delta); Tesselator tesselator = Tesselator.getInstance(); BufferBuilder buffer = tesselator.getBuilder(); - DynamicErrorFreeEntryListWidget.renderBackBackground(poses, buffer, tesselator, - GuiComponent.BACKGROUND_LOCATION, 0, this.top, this.width, this.height, 0, 32); + DynamicErrorFreeEntryListWidget.renderBackBackground(graphics, buffer, tesselator, + Screen.BACKGROUND_LOCATION, 0, this.top, this.width, this.height, 0, 32); RenderSystem.enableBlend(); RenderSystem.blendFuncSeparate(770, 771, 0, 1); RenderSystem.setShader(GameRenderer::getPositionTexColorShader); - Matrix4f matrix = poses.last().pose(); + Matrix4f matrix = graphics.pose().last().pose(); buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); buffer.vertex(matrix, 0, this.top + 4, 0.0F).uv(0, 1).color(0x00000000).endVertex(); buffer.vertex(matrix, this.width, this.top + 4, 0.0F).uv(1, 1).color(0x00000000).endVertex(); @@ -265,7 +268,7 @@ public class CollapsibleEntriesScreen extends Screen { tesselator.end(); RenderSystem.disableBlend(); - try (CloseableScissors scissors = scissor(poses, new Rectangle(0, this.top, this.width - 6, this.height - this.top))) { + try (CloseableScissors scissors = scissor(graphics, new Rectangle(0, this.top, this.width - 6, this.height - this.top))) { int entryWidth = (this.width - 12 - 6 - PADDING) / this.columns.length - PADDING; for (int i = 0; i < this.columns.length; i++) { int x = 6 + PADDING + i * (entryWidth + PADDING); @@ -273,17 +276,17 @@ public class CollapsibleEntriesScreen extends Screen { for (CollapsibleEntryWidget widget : this.columns[i]) { widget.setPosition(x, y); widget.setWidth(entryWidth); - widget.render(poses, mouseX, mouseY, delta); + widget.render(graphics, mouseX, mouseY, delta); y += widget.getHeight() + PADDING; } } } - this.scroller.renderScrollBar(); + this.scroller.renderScrollBar(graphics); - DynamicErrorFreeEntryListWidget.renderBackBackground(poses, buffer, tesselator, - GuiComponent.BACKGROUND_LOCATION, 0, 0, this.width, this.top, 0, 64); - ScreenOverlayImpl.getInstance().lateRender(poses, mouseX, mouseY, delta); + DynamicErrorFreeEntryListWidget.renderBackBackground(graphics, buffer, tesselator, + Screen.BACKGROUND_LOCATION, 0, 0, this.width, this.top, 0, 64); + ScreenOverlayImpl.getInstance().lateRender(graphics, mouseX, mouseY, delta); } private int getMaxScrollDist() { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntryWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntryWidget.java index 88596a0f7..e93d5d733 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntryWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntryWidget.java @@ -24,7 +24,10 @@ package me.shedaniel.rei.impl.client.gui.screen.collapsible; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.*; +import com.mojang.blaze3d.vertex.BufferBuilder; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import com.mojang.blaze3d.vertex.Tesselator; +import com.mojang.blaze3d.vertex.VertexFormat; import me.shedaniel.clothconfig2.ClothConfigInitializer; import me.shedaniel.clothconfig2.api.animator.ProgressValueAnimator; import me.shedaniel.clothconfig2.api.animator.ValueAnimator; @@ -44,6 +47,7 @@ import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl; import me.shedaniel.rei.impl.client.gui.text.TextTransformations; import me.shedaniel.rei.impl.client.gui.widget.BatchedEntryRendererManager; import me.shedaniel.rei.impl.client.gui.widget.EntryWidget; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.renderer.GameRenderer; @@ -118,10 +122,10 @@ public class CollapsibleEntryWidget extends WidgetWithBounds { CollapsibleEntriesScreen.setupCustom(this.id, this.component.getString(), new ArrayList<>(stacks), this.configObject, markDirty); }, Supplier::get) { @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { - super.render(matrices, mouseX, mouseY, delta); + public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { + super.render(graphics, mouseX, mouseY, delta); RenderSystem.setShaderTexture(0, InternalTextures.CHEST_GUI_TEXTURE); - blit(matrices, x + 3, y + 3, 0, 0, 14, 14); + graphics.blit(InternalTextures.CHEST_GUI_TEXTURE, x + 3, y + 3, 0, 0, 14, 14); } }; } else { @@ -153,84 +157,84 @@ public class CollapsibleEntryWidget extends WidgetWithBounds { } @Override - public void render(PoseStack poses, int mouseX, int mouseY, float delta) { + public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { this.scroller.updatePosition(delta); this.idDrawer.update(delta); this.modIdDrawer.update(delta); Rectangle bounds = this.getBounds(); - fillGradient(poses, bounds.x, bounds.y, bounds.getMaxX(), bounds.getMaxY(), 0xFF777777, 0xFF777777); - fillGradient(poses, bounds.x + 1, bounds.y + 1, bounds.getMaxX() - 1, bounds.getMaxY() - 1, 0xFF000000, 0xFF000000); + graphics.fillGradient(bounds.x, bounds.y, bounds.getMaxX(), bounds.getMaxY(), 0xFF777777, 0xFF777777); + graphics.fillGradient(bounds.x + 1, bounds.y + 1, bounds.getMaxX() - 1, bounds.getMaxY() - 1, 0xFF000000, 0xFF000000); int y = bounds.y + 4; if (y + 9 >= 30 && y < minecraft.screen.height) { - renderTextScrolling(poses, this.component, bounds.x + 4, y, bounds.width - 8, 0xFFDDDDDD); + renderTextScrolling(graphics, this.component, bounds.x + 4, y, bounds.width - 8, 0xFFDDDDDD); } y += 13; if (y + 9 >= 30 && y < minecraft.screen.height) { Rectangle lineBounds = new Rectangle(bounds.x + 4, y, bounds.width - 8, 9); idDrawer.setTo(lineBounds.contains(mouseX, mouseY), ConfigObject.getInstance().isReducedMotion() ? 0 : 400); - try (CloseableScissors scissors = scissor(poses, lineBounds)) { - poses.pushPose(); - poses.translate(0, -idDrawer.progress() * 10, 0); - font.drawShadow(poses, Component.translatable("text.rei.collapsible.entries.count", this.stacks.size() + ""), bounds.x + 4, y, 0xFFAAAAAA); + try (CloseableScissors scissors = scissor(graphics, lineBounds)) { + graphics.pose().pushPose(); + graphics.pose().translate(0, -idDrawer.progress() * 10, 0); + graphics.drawString(font, Component.translatable("text.rei.collapsible.entries.count", this.stacks.size() + ""), bounds.x + 4, y, 0xFFAAAAAA); boolean enabled = !this.configObject.disabledGroups.contains(this.id); Component sideText = Component.translatable("text.rei.collapsible.entries.enabled." + enabled); - font.drawShadow(poses, sideText, bounds.getMaxX() - 4 - font.width(sideText), y, enabled ? 0xDD55FF55 : 0xDDFF5555); - renderTextScrolling(poses, Component.literal(this.id.toString()), bounds.x + 4, y + 10, bounds.width - 8, 0xFF777777); - poses.popPose(); + graphics.drawString(font, sideText, bounds.getMaxX() - 4 - font.width(sideText), y, enabled ? 0xDD55FF55 : 0xDDFF5555); + renderTextScrolling(graphics, Component.literal(this.id.toString()), bounds.x + 4, y + 10, bounds.width - 8, 0xFF777777); + graphics.pose().popPose(); } } y += 10; if (y + 9 >= 30 && y < minecraft.screen.height) { Rectangle lineBounds = new Rectangle(bounds.x + 4, y, bounds.width - 8, 9); modIdDrawer.setTo(lineBounds.contains(mouseX, mouseY), ConfigObject.getInstance().isReducedMotion() ? 0 : 400); - int xo = font.drawShadow(poses, Component.translatable("text.rei.collapsible.entries.source").append(" "), bounds.x + 4, y, 0xFFAAAAAA); - try (CloseableScissors scissors = scissor(poses, lineBounds)) { - poses.pushPose(); + int xo = graphics.drawString(font, Component.translatable("text.rei.collapsible.entries.source").append(" "), bounds.x + 4, y, 0xFFAAAAAA); + try (CloseableScissors scissors = scissor(graphics, lineBounds)) { + graphics.pose().pushPose(); if (this.custom) { - renderTextScrolling(poses, TextTransformations.applyRainbow(Component.translatable("text.rei.collapsible.entries.source.custom").getVisualOrderText(), xo - 1, y), xo - 1, y, bounds.getWidth() - 8, 0xFFAAAAAA); + renderTextScrolling(graphics, TextTransformations.applyRainbow(Component.translatable("text.rei.collapsible.entries.source.custom").getVisualOrderText(), xo - 1, y), xo - 1, y, bounds.getWidth() - 8, 0xFFAAAAAA); } else { - poses.translate(0, -modIdDrawer.progress() * 10, 0); - renderTextScrolling(poses, Component.literal(ClientHelper.getInstance().getModFromModId(this.id.getNamespace())), xo - 1, y, bounds.getMaxX() - 4 - (xo - 1), 0xFF777777); - renderTextScrolling(poses, Component.literal(this.id.getNamespace().toString()), xo - 1, y + 10, bounds.getMaxX() - 4 - (xo - 1), 0xFF777777); + graphics.pose().translate(0, -modIdDrawer.progress() * 10, 0); + renderTextScrolling(graphics, Component.literal(ClientHelper.getInstance().getModFromModId(this.id.getNamespace())), xo - 1, y, bounds.getMaxX() - 4 - (xo - 1), 0xFF777777); + renderTextScrolling(graphics, Component.literal(this.id.getNamespace().toString()), xo - 1, y + 10, bounds.getMaxX() - 4 - (xo - 1), 0xFF777777); } - poses.popPose(); + graphics.pose().popPose(); } } - renderStacks(poses, mouseX, mouseY, delta, bounds, y); + renderStacks(graphics, mouseX, mouseY, delta, bounds, y); bounds.y = this.y; - poses.pushPose(); - poses.translate(0, 0, 400); + graphics.pose().pushPose(); + graphics.pose().translate(0, 0, 400); this.toggleButton.setX(bounds.getMaxX() - 4 - toggleButton.getWidth()); this.toggleButton.setY(bounds.getMaxY() - 4 - toggleButton.getHeight()); - this.toggleButton.render(poses, mouseX, mouseY, delta); + this.toggleButton.render(graphics, mouseX, mouseY, delta); if (this.toggleButton.isMouseOver(mouseX, mouseY)) { ScreenOverlayImpl.getInstance().clearTooltips(); } if (this.custom) { this.deleteButton.setX(toggleButton.getX() - 2 - deleteButton.getWidth()); this.deleteButton.setY(bounds.getMaxY() - 4 - deleteButton.getHeight()); - this.deleteButton.render(poses, mouseX, mouseY, delta); + this.deleteButton.render(graphics, mouseX, mouseY, delta); if (this.deleteButton.isMouseOver(mouseX, mouseY)) { ScreenOverlayImpl.getInstance().clearTooltips(); } this.configureButton.setX(deleteButton.getX() - 2 - configureButton.getWidth()); this.configureButton.setY(bounds.getMaxY() - 4 - configureButton.getHeight()); - this.configureButton.render(poses, mouseX, mouseY, delta); + this.configureButton.render(graphics, mouseX, mouseY, delta); if (this.configureButton.isMouseOver(mouseX, mouseY)) { ScreenOverlayImpl.getInstance().clearTooltips(); } } - poses.popPose(); + graphics.pose().popPose(); } - private void renderStacks(PoseStack poses, int mouseX, int mouseY, float delta, Rectangle bounds, int y) { - poses.pushPose(); - try (CloseableScissors outerScissors = scissor(poses, new Rectangle(bounds.x, y, bounds.width, bounds.getMaxY() - 3 - y))) { + private void renderStacks(GuiGraphics graphics, int mouseX, int mouseY, float delta, Rectangle bounds, int y) { + graphics.pose().pushPose(); + try (CloseableScissors outerScissors = scissor(graphics, new Rectangle(bounds.x, y, bounds.width, bounds.getMaxY() - 3 - y))) { y = bounds.y + 37 - this.scroller.scrollAmountInt(); int x = bounds.getCenterX() - 8 * rowSize; int xIndex = 0; - poses.translate(0, 0, 100); + graphics.pose().translate(0, 0, 100); BatchedEntryRendererManager manager = new BatchedEntryRendererManager<>(); for (Slot stack : this.stacks) { if (y + 16 >= 30 && y + 16 >= bounds.y + 37) { @@ -246,10 +250,10 @@ public class CollapsibleEntryWidget extends WidgetWithBounds { } } } - try (CloseableScissors scissors = scissor(poses, new Rectangle(x, bounds.y + 37, 16 * rowSize, bounds.getMaxY() - 4 - (bounds.y + 37)))) { - manager.render(poses, mouseX, mouseY, delta); + try (CloseableScissors scissors = scissor(graphics, new Rectangle(x, bounds.y + 37, 16 * rowSize, bounds.getMaxY() - 4 - (bounds.y + 37)))) { + manager.render(graphics, mouseX, mouseY, delta); } - poses.translate(0, 0, 300); + graphics.pose().translate(0, 0, 300); if (this.stacks.size() > rowSize * 3) { Tesselator tesselator = Tesselator.getInstance(); @@ -258,7 +262,7 @@ public class CollapsibleEntryWidget extends WidgetWithBounds { RenderSystem.defaultBlendFunc(); RenderSystem.setShader(GameRenderer::getPositionColorShader); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - Matrix4f matrix = poses.last().pose(); + Matrix4f matrix = graphics.pose().last().pose(); buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); buffer.vertex(matrix, this.x + 1, this.y + this.height - 1, 0.0F).color(0xFF000000).endVertex(); buffer.vertex(matrix, this.x + this.width - 1, this.y + this.height - 1, 0.0F).color(0xFF000000).endVertex(); @@ -268,25 +272,25 @@ public class CollapsibleEntryWidget extends WidgetWithBounds { RenderSystem.disableBlend(); } } - poses.popPose(); + graphics.pose().popPose(); } - private void renderTextScrolling(PoseStack poses, Component text, int x, int y, int width, int color) { - this.renderTextScrolling(poses, text.getVisualOrderText(), x, y, width, color); + private void renderTextScrolling(GuiGraphics graphics, Component text, int x, int y, int width, int color) { + this.renderTextScrolling(graphics, text.getVisualOrderText(), x, y, width, color); } - private void renderTextScrolling(PoseStack poses, FormattedCharSequence text, int x, int y, int width, int color) { - try (CloseableScissors scissors = scissor(poses, new Rectangle(x, y, width, y + 9))) { + private void renderTextScrolling(GuiGraphics graphics, FormattedCharSequence text, int x, int y, int width, int color) { + try (CloseableScissors scissors = scissor(graphics, new Rectangle(x, y, width, y + 9))) { int textWidth = this.font.width(text); if (textWidth > width) { - poses.pushPose(); + graphics.pose().pushPose(); float textX = (System.currentTimeMillis() % ((textWidth + 10) * textWidth / 3)) / (float) textWidth * 3; - poses.translate(-textX, 0, 0); - font.drawShadow(poses, text, x + width - textWidth - 10, y, color); - font.drawShadow(poses, text, x + width, y, color); - poses.popPose(); + graphics.pose().translate(-textX, 0, 0); + graphics.drawString(font, text, x + width - textWidth - 10, y, color); + graphics.drawString(font, text, x + width, y, color); + graphics.pose().popPose(); } else { - font.drawShadow(poses, text, x, y, color); + graphics.drawString(font, text, x, y, color); } } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/selection/CustomCollapsibleEntrySelectionScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/selection/CustomCollapsibleEntrySelectionScreen.java index 8364e3cca..2d5c3bd27 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/selection/CustomCollapsibleEntrySelectionScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/selection/CustomCollapsibleEntrySelectionScreen.java @@ -47,6 +47,7 @@ import me.shedaniel.rei.impl.client.gui.widget.EntryWidget; import me.shedaniel.rei.impl.client.gui.widget.search.OverlaySearchField; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.Screen; @@ -220,8 +221,8 @@ public class CustomCollapsibleEntrySelectionScreen extends Screen { } @Override - public void render(PoseStack poses, int mouseX, int mouseY, float delta) { - renderHoleBackground(poses, 0, height, 32, 255, 255); + public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { + renderHoleBackground(graphics.pose(), 0, height, 32, 255, 255); updateSelectionCache(); Rectangle bounds = getBounds(); tooltip = null; @@ -244,17 +245,17 @@ public class CustomCollapsibleEntrySelectionScreen extends Screen { manager.add(entry); nextIndex++; } - manager.render(poses, mouseX, mouseY, delta); + manager.render(graphics, mouseX, mouseY, delta); updatePosition(delta); - scrolling.renderScrollBar(0, 1.0F, REIRuntime.getInstance().isDarkThemeEnabled() ? 0.8F : 1F); - poses.pushPose(); - poses.translate(0, 0, 300); - this.searchField.render(poses, mouseX, mouseY, delta); - this.selectAllButton.render(poses, mouseX, mouseY, delta); - this.selectNoneButton.render(poses, mouseX, mouseY, delta); - this.addButton.render(poses, mouseX, mouseY, delta); - this.removeButton.render(poses, mouseX, mouseY, delta); - poses.popPose(); + scrolling.renderScrollBar(graphics, 0, 1.0F, REIRuntime.getInstance().isDarkThemeEnabled() ? 0.8F : 1F); + graphics.pose().pushPose(); + graphics.pose().translate(0, 0, 300); + this.searchField.render(graphics, mouseX, mouseY, delta); + this.selectAllButton.render(graphics, mouseX, mouseY, delta); + this.selectNoneButton.render(graphics, mouseX, mouseY, delta); + this.addButton.render(graphics, mouseX, mouseY, delta); + this.removeButton.r