From bbf4c43a1ed431c94c2a95e67ea8494a8007cdee Mon Sep 17 00:00:00 2001 From: shedaniel Date: Wed, 23 Jul 2025 20:50:25 +0200 Subject: Port to 1.21.6 (#1907) * Port to 1.21.6 * Fix tooltip Z-rendering * Fix config screen * Add workflow --- .github/workflows/curseforge.yml | 1 + .../rei/api/client/config/ConfigObject.java | 10 - .../entry/renderer/BatchedEntryRenderer.java | 117 --------- .../client/favorites/CompoundFavoriteRenderer.java | 8 +- .../rei/api/client/gui/SimpleDisplayRenderer.java | 10 +- .../rei/api/client/gui/widgets/Widget.java | 17 +- .../rei/api/client/gui/widgets/Widgets.java | 12 +- .../transfer/simple/SimpleTransferHandler.java | 3 - .../shedaniel/rei/api/client/util/MatrixUtils.java | 53 +++- .../rei/api/client/util/SpriteRenderer.java | 11 +- .../me/shedaniel/rei/impl/ClientInternals.java | 9 +- .../client/categories/DefaultBrewingCategory.java | 6 +- .../client/categories/DefaultFuelCategory.java | 3 - .../categories/DefaultInformationCategory.java | 23 +- .../categories/anvil/DefaultAnvilCategory.java | 2 +- .../client/categories/tag/DefaultTagCategory.java | 20 +- .../categories/tag/ReferenceTagNodeWidget.java | 5 +- .../client/categories/tag/TagTreeWidget.java | 2 +- .../client/categories/tag/ValueTagNodeWidget.java | 14 +- .../client/favorites/GameModeFavoriteEntry.java | 14 +- .../plugin/client/favorites/TimeFavoriteEntry.java | 12 +- .../client/favorites/WeatherFavoriteEntry.java | 12 +- .../shedaniel/rei/fabric/PluginDetectorImpl.java | 26 -- .../client/gui/fabric/ScreenOverlayImplFabric.java | 16 +- fabric/src/main/resources/error_notifier.json | 4 +- .../resources/roughlyenoughitems.accessWidener | 6 +- .../client/gui/forge/ScreenOverlayImplForge.java | 4 +- gradle.properties | 18 +- .../client/gui/forge/ScreenOverlayImplForge.java | 6 +- .../main/resources/META-INF/accesstransformer.cfg | 7 +- .../rei/RoughlyEnoughItemsCoreClient.java | 2 +- .../shedaniel/rei/RoughlyEnoughItemsNetwork.java | 6 +- .../rei/impl/client/config/ConfigObjectImpl.java | 11 - .../client/config/addon/ConfigAddonsScreen.java | 4 +- .../config/entries/ConfigureCategoriesScreen.java | 9 +- .../config/entries/FilteringRulesScreen.java | 4 +- .../client/config/entries/FilteringScreen.java | 15 +- .../filtering/rules/SearchFilteringRuleType.java | 4 +- .../rei/impl/client/gui/ScreenOverlayImpl.java | 9 +- .../impl/client/gui/config/REIConfigScreen.java | 2 +- .../components/ConfigCategoryEntryWidget.java | 14 +- .../gui/config/components/ConfigGroupWidget.java | 18 +- .../config/components/ConfigOptionValueWidget.java | 6 +- .../gui/config/components/ConfigOptionWidget.java | 8 +- .../gui/config/components/ConfigSearchWidget.java | 8 +- .../gui/config/options/AllREIConfigCategories.java | 2 +- .../gui/config/options/AllREIConfigGroups.java | 5 +- .../gui/config/options/AllREIConfigOptions.java | 2 - .../config/options/preview/InterfacePreviewer.java | 4 +- .../config/options/preview/TooltipPreviewer.java | 32 +-- .../client/gui/credits/CreditsEntryListWidget.java | 2 +- .../client/gui/dragging/CurrentDraggingStack.java | 9 - .../client/gui/error/ErrorsEntryListWidget.java | 42 +-- .../rei/impl/client/gui/error/ErrorsScreen.java | 8 +- .../client/gui/hints/ImportantWarningsWidget.java | 22 +- .../rei/impl/client/gui/modules/MenuHolder.java | 3 +- .../client/gui/modules/entries/SubMenuEntry.java | 10 +- .../client/gui/modules/entries/TextMenuEntry.java | 2 +- .../gui/modules/entries/ToggleMenuEntry.java | 11 +- .../gui/performance/DisplayRegistryInfoScreen.java | 2 - .../performance/entry/PerformanceEntryImpl.java | 2 - .../performance/entry/SubCategoryListEntry.java | 6 +- .../gui/screen/AbstractDisplayViewingScreen.java | 22 +- .../gui/screen/CompositeDisplayViewingScreen.java | 8 +- .../gui/screen/DefaultDisplayViewingScreen.java | 68 +++-- .../rei/impl/client/gui/screen/ScreenWithMenu.java | 3 - .../gui/screen/UncertainDisplayViewingScreen.java | 8 +- .../client/gui/screen/WarningAndErrorScreen.java | 2 +- .../collapsible/CollapsibleEntriesScreen.java | 12 +- .../screen/collapsible/CollapsibleEntryWidget.java | 52 ++-- .../CustomCollapsibleEntrySelectionScreen.java | 20 +- .../gui/screen/generic/OptionEntriesScreen.java | 6 +- .../gui/toast/CopyRecipeIdentifierToast.java | 6 +- .../gui/toast/ExportRecipeIdentifierToast.java | 6 +- .../gui/widget/BatchedEntryRendererManager.java | 285 --------------------- .../impl/client/gui/widget/ConfigButtonWidget.java | 7 +- .../gui/widget/CraftableFilterButtonWidget.java | 6 +- .../gui/widget/DefaultDisplayChoosePageWidget.java | 3 - .../gui/widget/DelegateWidgetWithTranslate.java | 41 ++- .../client/gui/widget/DisplayCompositeWidget.java | 26 +- .../client/gui/widget/DisplayTooltipComponent.java | 16 +- .../widget/DynamicErrorFreeEntryListWidget.java | 25 +- .../impl/client/gui/widget/EntryHighlighter.java | 7 +- .../client/gui/widget/EntryRendererManager.java | 111 ++++++++ .../rei/impl/client/gui/widget/EntryWidget.java | 8 +- .../rei/impl/client/gui/widget/HoleWidget.java | 8 +- .../impl/client/gui/widget/InternalWidgets.java | 4 +- .../rei/impl/client/gui/widget/ListWidget.java | 8 +- .../rei/impl/client/gui/widget/OverflowWidget.java | 10 +- .../impl/client/gui/widget/PaddedCenterWidget.java | 8 +- .../rei/impl/client/gui/widget/PaddedWidget.java | 8 +- .../client/gui/widget/ScrollableViewWidget.java | 4 +- .../impl/client/gui/widget/TabContainerWidget.java | 20 +- .../rei/impl/client/gui/widget/TabWidget.java | 11 +- .../rei/impl/client/gui/widget/VStackWidget.java | 8 +- .../client/gui/widget/VanillaWrappedWidget.java | 4 +- .../client/gui/widget/basewidgets/ArrowWidget.java | 8 +- .../gui/widget/basewidgets/BurningFireWidget.java | 8 +- .../gui/widget/basewidgets/ButtonWidget.java | 4 +- .../basewidgets/FillRectangleDrawableConsumer.java | 16 +- .../client/gui/widget/basewidgets/PanelWidget.java | 4 +- .../gui/widget/basewidgets/TextFieldWidget.java | 25 +- .../basewidgets/TexturedDrawableConsumer.java | 21 +- .../gui/widget/entrylist/CachingEntryRenderer.java | 47 +--- .../entrylist/CollapsedEntriesBorderRenderer.java | 6 +- .../widget/entrylist/CollapsedEntriesTooltip.java | 12 +- .../gui/widget/entrylist/EntryListStackEntry.java | 6 - .../gui/widget/entrylist/EntryListWidget.java | 8 +- .../widget/entrylist/PaginatedEntryListWidget.java | 30 +-- .../widget/entrylist/ScrolledEntryListWidget.java | 8 +- .../gui/widget/favorites/history/DisplayEntry.java | 40 ++- .../favorites/history/DisplayHistoryWidget.java | 47 +--- .../panel/FadingFavoritesPanelButton.java | 8 +- .../gui/widget/favorites/panel/FavoritesPanel.java | 6 +- .../panel/FavoritesTogglePanelButton.java | 14 +- .../panel/rows/FavoritesPanelEntriesRow.java | 2 - .../impl/client/gui/widget/hint/HintWidget.java | 25 +- .../gui/widget/region/EntryStacksRegionWidget.java | 5 +- .../gui/widget/region/RegionEntryWidget.java | 9 +- .../gui/widget/region/RegionRenderingDebugger.java | 9 +- .../gui/widget/search/OverlaySearchField.java | 27 +- .../screen/DefaultScreenOverlayRenderer.java | 13 +- .../impl/client/transfer/MissingStacksTooltip.java | 14 +- .../plugin/client/entry/FluidEntryDefinition.java | 59 +---- .../plugin/client/entry/ItemEntryDefinition.java | 112 +------- .../client/runtime/DefaultClientRuntimePlugin.java | 18 +- 126 files changed, 681 insertions(+), 1506 deletions(-) delete mode 100644 api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/BatchedEntryRenderer.java delete mode 100644 runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/BatchedEntryRendererManager.java create mode 100644 runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryRendererManager.java diff --git a/.github/workflows/curseforge.yml b/.github/workflows/curseforge.yml index c268d74ae..e9436becf 100644 --- a/.github/workflows/curseforge.yml +++ b/.github/workflows/curseforge.yml @@ -23,6 +23,7 @@ on: - 17.x-1.21.2 - 18.x-1.21.4 - 19.x-1.21.5 + - 20.x-1.21.6 jobs: build: diff --git a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java index 11fbe4a37..a0d429db1 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java @@ -115,14 +115,6 @@ public interface ConfigObject { */ boolean isGrabbingItems(); - /** - * Returns whether favorites motions are animated. - * - * @return whether favorites motions are animated - */ - @Deprecated(forRemoval = true) - boolean isFavoritesAnimated(); - /** * Returns whether motions are reduced. * @@ -281,8 +273,6 @@ public interface ConfigObject { @ApiStatus.Experimental boolean doDisplayIMEHints(); - boolean doesFastEntryRendering(); - boolean doesCacheEntryRendering(); @ApiStatus.Experimental diff --git a/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/BatchedEntryRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/BatchedEntryRenderer.java deleted file mode 100644 index 2aba4ba67..000000000 --- a/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/BatchedEntryRenderer.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023 shedaniel - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.shedaniel.rei.api.client.entry.renderer; - -import com.mojang.blaze3d.vertex.PoseStack; -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.common.entry.EntryStack; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.renderer.MultiBufferSource; - -/** - * A batched renderer for rendering a lot of {@link EntryStack} at once with better performance. - * - * @param the entry type - * @param the type of extra data returned in {@link #getExtraData(EntryStack)} - */ -@Environment(EnvType.CLIENT) -public interface BatchedEntryRenderer extends EntryRenderer { - default boolean isBatched(EntryStack entry) { - return true; - } - - /** - * Returns extra data to be passed to various rendering methods. - * - * @param entry the stack - * @return the extra data - */ - E getExtraData(EntryStack entry); - - /** - * Returns a batch identifier, stacks with the same batch identifier will be grouped together - * into a batch. - * - * @param entry the stack - * @param bounds the bounds of the entry - * @param extraData the extra data returned from {@link #getExtraData(EntryStack)} - * @return the batch identifier - */ - int getBatchIdentifier(EntryStack entry, Rectangle bounds, E extraData); - - /** - * Modifies the {@link PoseStack} passed tp various batch rendering methods. - * - * @param matrices the matrix stack - * @return the modified matrix stack, could be an entirely different stack - */ - default PoseStack batchModifyMatrices(PoseStack matrices) { - return matrices; - } - - /** - * Starts the batch rendering, used to setup states, only called once with every batch. - * - * @param entry the first entry in the batch - * @param extraData the extra data returned from {@link #getExtraData(EntryStack)} - * @param graphics the graphics context - * @param delta the tick delta - */ - void startBatch(EntryStack entry, E extraData, GuiGraphics graphics, float delta); - - void renderBase(EntryStack entry, E extraData, GuiGraphics graphics, MultiBufferSource.BufferSource immediate, Rectangle bounds, int mouseX, int mouseY, float delta); - - void afterBase(EntryStack entry, E extraData, GuiGraphics graphics, float delta); - - void renderOverlay(EntryStack entry, E extraData, GuiGraphics graphics, MultiBufferSource.BufferSource immediate, Rectangle bounds, int mouseX, int mouseY, float delta); - - /** - * Ends the batch rendering, used to setup states, only called once with every batch. - * - * @param entry the first entry in the batch - * @param extraData the extra data returned from {@link #getExtraData(EntryStack)} - * @param graphics the graphics context - * @param delta the tick delta - */ - void endBatch(EntryStack entry, E extraData, GuiGraphics graphics, float delta); - - @Override - default void render(EntryStack entry, GuiGraphics graphics, Rectangle bounds, int mouseX, int mouseY, float delta) { - PoseStack newStack = batchModifyMatrices(graphics.pose()); - graphics.pose().pushPose(); - graphics.pose().last().pose().set(newStack.last().pose()); - graphics.pose().last().normal().set(newStack.last().normal()); - E data = getExtraData(entry); - startBatch(entry, data, graphics, delta); - MultiBufferSource.BufferSource immediate = graphics.bufferSource; - renderBase(entry, data, graphics, immediate, bounds, mouseX, mouseY, delta); - immediate.endBatch(); - renderOverlay(entry, data, graphics, immediate, bounds, mouseX, mouseY, delta); - immediate.endBatch(); - endBatch(entry, data, graphics, delta); - graphics.pose().popPose(); - } -} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/favorites/CompoundFavoriteRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/favorites/CompoundFavoriteRenderer.java index b00381a07..6dda97e5b 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/favorites/CompoundFavoriteRenderer.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/favorites/CompoundFavoriteRenderer.java @@ -90,13 +90,13 @@ public class CompoundFavoriteRenderer implements Renderer { public void render(GuiGraphics graphics, Rectangle bounds, int mouseX, int mouseY, float delta) { updateAnimator(delta); graphics.enableScissor(bounds.x, bounds.y, bounds.getMaxX(), bounds.getMaxY()); - graphics.pose().pushPose(); - graphics.pose().translate(0, this.offset.floatValue() * -bounds.getHeight(), 0); + graphics.pose().pushMatrix(); + graphics.pose().translate(0, this.offset.floatValue() * -bounds.getHeight()); for (int i = 0; i < count; i++) { renderers.apply(i).render(graphics, bounds, mouseX, mouseY, delta); - graphics.pose().translate(0, bounds.height, 0); + graphics.pose().translate(0, bounds.height); } - graphics.pose().popPose(); + graphics.pose().popMatrix(); graphics.disableScissor(); } diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/SimpleDisplayRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/SimpleDisplayRenderer.java index f7863abcc..aced40fa1 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/SimpleDisplayRenderer.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/SimpleDisplayRenderer.java @@ -36,7 +36,7 @@ import me.shedaniel.rei.api.common.util.CollectionUtils; import me.shedaniel.rei.api.common.util.EntryStacks; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; -import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; import org.jetbrains.annotations.ApiStatus; @@ -120,8 +120,6 @@ public class SimpleDisplayRenderer extends DisplayRenderer implements WidgetHold int xx = bounds.x + 4, yy = bounds.y + 2; int j = 0; int itemsPerLine = getItemsPerLine(); - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 50); for (Slot entryWidget : inputWidgets) { entryWidget.getBounds().setLocation(xx, yy); entryWidget.render(graphics, mouseX, mouseY, delta); @@ -133,20 +131,16 @@ public class SimpleDisplayRenderer extends DisplayRenderer implements WidgetHold j = 0; } } - graphics.pose().popPose(); xx = bounds.x + 4 + 18 * (getItemsPerLine() - 2); yy = bounds.y + getHeight() / 2 - 8; - graphics.blit(RenderType::guiTextured, CHEST_GUI_TEXTURE, xx, yy, 0, 28, 18, 18, 256, 256); + graphics.blit(RenderPipelines.GUI_TEXTURED, CHEST_GUI_TEXTURE, xx, yy, 0, 28, 18, 18, 256, 256); xx += 18; yy += outputWidgets.size() * -9 + 9; - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 50); for (Slot outputWidget : outputWidgets) { outputWidget.getBounds().setLocation(xx, yy); outputWidget.render(graphics, mouseX, mouseY, delta); yy += 18; } - graphics.pose().popPose(); } @Nullable diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widget.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widget.java index 499383833..8a3c01f77 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widget.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widget.java @@ -23,7 +23,6 @@ package me.shedaniel.rei.api.client.gui.widgets; -import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.math.impl.PointHelper; @@ -36,8 +35,8 @@ import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Renderable; import org.jetbrains.annotations.ApiStatus; -import org.joml.Matrix4f; -import org.joml.Vector4f; +import org.joml.Matrix3x2f; +import org.joml.Vector3f; import java.util.Stack; @@ -71,17 +70,13 @@ public abstract class Widget extends AbstractContainerEventHandler implements Re return mouseStack.pop(); } - public static Point translateMouse(PoseStack poses) { - return translateMouse(poses.last().pose()); + public static Point translateMouse(double x, double y) { + return translateMouse(new Matrix3x2f().translate((float) x, (float) y)); } - public static Point translateMouse(double x, double y, double z) { - return translateMouse(new Matrix4f().translate((float) x, (float) y, (float) z)); - } - - public static Point translateMouse(Matrix4f pose) { + public static Point translateMouse(Matrix3x2f pose) { Point mouse = mouse(); - Vector4f mouseVec = new Vector4f(mouse.x, mouse.y, 0, 1); + Vector3f mouseVec = new Vector3f(mouse.x, mouse.y, 1); pose.transform(mouseVec); return pushMouse(new Point(mouseVec.x(), mouseVec.y())); } diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java index 6b4567038..79068b463 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java @@ -44,7 +44,7 @@ import net.minecraft.sounds.SoundEvents; import net.minecraft.world.item.Item; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; -import org.joml.Matrix4f; +import org.joml.Matrix3x2f; import java.util.*; import java.util.function.Consumer; @@ -110,19 +110,19 @@ public final class Widgets { return ClientInternals.getWidgetsProvider().wrapVanillaWidget(element); } - public static WidgetWithBounds withTranslate(Widget widget, double x, double y, double z) { - return withTranslate(widget, new Matrix4f().translate((float) x, (float) y, (float) z)); + public static WidgetWithBounds withTranslate(Widget widget, double x, double y) { + return withTranslate(widget, new Matrix3x2f().translate((float) x, (float) y)); } - public static WidgetWithBounds withTranslate(Widget widget, Matrix4f translate) { + public static WidgetWithBounds withTranslate(Widget widget, Matrix3x2f translate) { return withTranslate(widget, () -> translate); } - public static WidgetWithBounds withTranslate(T widget, Function translate) { + public static WidgetWithBounds withTranslate(T widget, Function translate) { return withTranslate(widget, () -> translate.apply(widget)); } - public static WidgetWithBounds withTranslate(Widget widget, Supplier translate) { + public static WidgetWithBounds withTranslate(Widget widget, Supplier translate) { WidgetWithBounds widgetWithBounds = wrapWidgetWithBounds(widget); return ClientInternals.getWidgetsProvider().withTranslate(widgetWithBounds, translate); } diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/simple/SimpleTransferHandler.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/simple/SimpleTransferHandler.java index f5c8981f8..e88791644 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/simple/SimpleTransferHandler.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/simple/SimpleTransferHandler.java @@ -174,11 +174,8 @@ public interface SimpleTransferHandler extends TransferHandler, TransferHandlerM for (Widget widget : widgets) { if (widget instanceof Slot && ((Slot) widget).getNoticeMark() == Slot.INPUT) { if (missingIndices.contains(i++)) { - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 50); Rectangle innerBounds = ((Slot) widget).getInnerBounds(); graphics.fill(innerBounds.x, innerBounds.y, innerBounds.getMaxX(), innerBounds.getMaxY(), 0x40ff0000); - graphics.pose().popPose(); } } } diff --git a/api/src/main/java/me/shedaniel/rei/api/client/util/MatrixUtils.java b/api/src/main/java/me/shedaniel/rei/api/client/util/MatrixUtils.java index 6ca6595ff..6884b0776 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/util/MatrixUtils.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/util/MatrixUtils.java @@ -23,26 +23,53 @@ package me.shedaniel.rei.api.client.util; -import com.mojang.math.Transformation; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import org.jetbrains.annotations.ApiStatus; -import org.joml.Matrix4f; -import org.joml.Vector4f; +import org.joml.Matrix3x2f; +import org.joml.Vector3f; @ApiStatus.Experimental public class MatrixUtils { - public static Matrix4f inverse(Matrix4f matrix) { - Transformation transformation = new Transformation(matrix); - Transformation inverse = transformation.inverse(); - if (inverse != null) inverse.getScale(); // This has a side effect - return inverse == null ? Transformation.identity().getMatrixCopy() : inverse.getMatrixCopy(); + public static Matrix3x2f inverse(Matrix3x2f matrix) { + float m00 = matrix.m00; + float m01 = matrix.m01; + float m10 = matrix.m10; + float m11 = matrix.m11; + float m20 = matrix.m20; // Translation X + float m21 = matrix.m21; // Translation Y + + // Calculate determinant of the 2x2 rotation/scale part + float det = m00 * m11 - m10 * m01; + + if (Math.abs(det) < 0.00001f) { // Check for singularity (e.g., zero scale) + System.err.println("Warning: Matrix is singular (determinant near zero), cannot be accurately inverted."); + return null; + } + + float invDet = 1.0f / det; + float invM00 = m11 * invDet; + float invM01 = -m01 * invDet; + float invM10 = -m10 * invDet; + float invM11 = m00 * invDet; + + // Apply inverse 2x2 part to translation + // T_inv = -M_inv * T + float invM20 = -(invM00 * m20 + invM10 * m21); + float invM21 = -(invM01 * m20 + invM11 * m21); + + // Create the inverse matrix + return new Matrix3x2f( + invM00, invM01, // First column (x-axis transformation) + invM10, invM11, // Second column (y-axis transformation) + invM20, invM21 // Third column (translation) + ); } - public static Rectangle transform(Matrix4f matrix, Rectangle rectangle) { - Vector4f vec1 = new Vector4f((float) rectangle.x, (float) rectangle.y, 0, 1); + public static Rectangle transform(Matrix3x2f matrix, Rectangle rectangle) { + Vector3f vec1 = new Vector3f((float) rectangle.x, (float) rectangle.y, 1); matrix.transform(vec1); - Vector4f vec2 = new Vector4f((float) rectangle.getMaxX(), (float) rectangle.getMaxY(), 0, 1); + Vector3f vec2 = new Vector3f((float) rectangle.getMaxX(), (float) rectangle.getMaxY(), 1); matrix.transform(vec2); int x1 = Math.round(vec1.x()); int x2 = Math.round(vec2.x()); @@ -51,8 +78,8 @@ public class MatrixUtils { return new Rectangle(Math.min(x1, x2), Math.min(y1, y2), Math.abs(x2 - x1), Math.abs(y2 - y1)); } - public static Point transform(Matrix4f matrix, Point point) { - Vector4f mouse = new Vector4f((float) point.x, (float) point.y, 0, 1); + public static Point transform(Matrix3x2f matrix, Point point) { + Vector3f mouse = new Vector3f((float) point.x, (float) point.y, 1); matrix.transform(mouse); return new Point(mouse.x(), mouse.y()); } diff --git a/api/src/main/java/me/shedaniel/rei/api/client/util/SpriteRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/util/SpriteRenderer.java index f7005374f..ace052989 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/util/SpriteRenderer.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/util/SpriteRenderer.java @@ -38,6 +38,7 @@ import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.TriState; import org.joml.Matrix3f; +import org.joml.Matrix3x2fStack; import org.joml.Matrix4f; import org.joml.Vector3f; @@ -70,7 +71,7 @@ public class SpriteRenderer { private TextureAtlasSprite sprite; private VertexConsumer consumer; private MultiBufferSource consumers; - private PoseStack matrices; + private Matrix3x2fStack matrices; private Matrix4f model; private Matrix3f normal; private RenderType layer; @@ -87,7 +88,7 @@ public class SpriteRenderer { public RenderPass setup(VertexConsumer consumer, RenderType type) { this.consumer = consumer; - this.matrices = new PoseStack(); + this.matrices = new Matrix3x2fStack(); this.layer = type; return this; @@ -207,7 +208,7 @@ public class SpriteRenderer { } public void next(ResourceLocation texture) { - if (this.consumer == null) { + /*if (this.consumer == null) { throw new RuntimeException("Invalid VertexConsumer!"); } if (this.matrices == null) { @@ -229,7 +230,7 @@ public class SpriteRenderer { TextureManager textureManager = Minecraft.getInstance().getTextureManager(); AbstractTexture abstractTexture = textureManager.getTexture(texture); - abstractTexture.setFilter(TriState.FALSE, false); + abstractTexture.setFilter(false, false); RenderSystem.setShaderTexture(0, abstractTexture.getTexture()); for (float y = y1; y < y2; y += Math.min(y2 - y, sY)) { @@ -274,7 +275,7 @@ public class SpriteRenderer { .setUv2(this.u, this.v) .setOverlay(this.l), this.normal, this.nX, this.nY, this.nZ); } - } + }*/ } } diff --git a/api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java b/api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java index 0eb1c9b49..2545f0cfc 100644 --- a/api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java +++ b/api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java @@ -57,7 +57,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; -import org.joml.Matrix4f; +import org.joml.Matrix3x2f; import java.lang.reflect.Field; import java.util.Collection; @@ -81,7 +81,6 @@ public final class ClientInternals { private static BiFunction toggleEntry = (supplier, toJson) -> throwNotSetup(); private static Function> favoriteEntryFromJson = (object) -> throwNotSetup(); private static Function clickAreaHandlerResult = (result) -> throwNotSetup(); - private static BiConsumer, TooltipComponent> clientTooltipComponentProvider = (tooltip, result) -> throwNotSetup(); private static BiFunction<@Nullable Point, Collection, Tooltip> tooltipProvider = (point, texts) -> throwNotSetup(); private static QuadFunction tooltipContextProvider = (point, texts, search, context) -> throwNotSetup(); private static Function tooltipEntryProvider = (component) -> throwNotSetup(); @@ -138,10 +137,6 @@ public final class ClientInternals { return clickAreaHandlerResult.apply(applicable); } - public static void getClientTooltipComponent(List tooltip, TooltipComponent component) { - clientTooltipComponentProvider.accept(tooltip, component); - } - public static Tooltip createTooltip(@Nullable Point point, Collection texts) { return tooltipProvider.apply(point, texts); } @@ -200,7 +195,7 @@ public final class ClientInternals { WidgetWithBounds wrapRenderer(Supplier bounds, Renderer renderer); - WidgetWithBounds withTranslate(WidgetWithBounds widget, Supplier translate); + WidgetWithBounds withTranslate(WidgetWithBounds widget, Supplier translate); Widget createDrawableWidget(DrawableConsumer drawable); diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultBrewingCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultBrewingCategory.java index a770553c4..65c16054d 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultBrewingCategory.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultBrewingCategory.java @@ -37,7 +37,7 @@ import me.shedaniel.rei.plugin.common.BuiltinPlugin; import me.shedaniel.rei.plugin.common.displays.brewing.DefaultBrewingDisplay; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; @@ -70,9 +70,9 @@ public class DefaultBrewingCategory implements DisplayCategory { ResourceLocation texture = REIRuntime.getInstance().getDefaultDisplayTexture(); - graphics.blit(RenderType::guiTextured, texture, startPoint.x, startPoint.y, 0, 108, 103, 59, 256, 256); + graphics.blit(RenderPipelines.GUI_TEXTURED, texture, startPoint.x, startPoint.y, 0, 108, 103, 59, 256, 256); int width = Mth.ceil(System.currentTimeMillis() / 250d % 18d); - graphics.blit(RenderType::guiTextured, texture, startPoint.x + 44, startPoint.y + 28, 103, 163, width, 4, 256, 256); + graphics.blit(RenderPipelines.GUI_TEXTURED, texture, startPoint.x + 44, startPoint.y + 28, 103, 163, width, 4, 256, 256); })); widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entry(EntryStacks.of(Items.BLAZE_POWDER)).disableBackground().markInput()); widgets.add(Widgets.createSlot(new Point(startPoint.x + 40, startPoint.y + 1)).entries(display.getInputEntries().get(0)).disableBackground().markInput()); diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultFuelCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultFuelCategory.java index 2f1157a13..a542d873c 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultFuelCategory.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultFuelCategory.java @@ -104,11 +104,8 @@ public class DefaultFuelCategory implements DisplayCategory @Override public void render(GuiGraphics graphics, Rectangle bounds, int mouseX, int mouseY, float delta) { - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 50); slot.getBounds().setLocation(bounds.x + 4, bounds.y + 2); slot.render(graphics, mouseX, mouseY, delta); - graphics.pose().popPose(); graphics.drawString(Minecraft.getInstance().font, text.getVisualOrderText(), bounds.x + 25, bounds.y + 8, -1); } }; diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultInformationCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultInformationCategory.java index 9ef500b6f..78bc3e856 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultInformationCategory.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultInformationCategory.java @@ -24,7 +24,6 @@ package me.shedaniel.rei.plugin.client.categories; import com.google.common.collect.Lists; -import com.mojang.blaze3d.vertex.VertexConsumer; import me.shedaniel.clothconfig2.ClothConfigInitializer; import me.shedaniel.clothconfig2.api.scroll.ScrollingContainer; import me.shedaniel.math.Point; @@ -45,11 +44,10 @@ import net.fabricmc.api.Environment; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; -import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.FormattedText; import net.minecraft.util.FormattedCharSequence; -import org.joml.Matrix4f; import java.util.Collections; import java.util.List; @@ -57,16 +55,6 @@ import java.util.Objects; @Environment(EnvType.CLIENT) public class DefaultInformationCategory implements DisplayCategory { - protected static void innerBlit(GuiGraphics graphics, Matrix4f matrix4f, int xStart, int xEnd, int yStart, int yEnd, int z, float uStart, float uEnd, float vStart, float vEnd) { - graphics.drawSpecial(source -> { - VertexConsumer buffer = source.getBuffer(RenderType.guiTextured(REIRuntime.getInstance().getDefaultDisplayTexture())); - buffer.addVertex(matrix4f, xStart, yEnd, z).setUv(uStart, vEnd).setColor(0xFFFFFFFF); - buffer.addVertex(matrix4f, xEnd, yEnd, z).setUv(uEnd, vEnd).setColor(0xFFFFFFFF); - buffer.addVertex(matrix4f, xEnd, yStart, z).setUv(uEnd, vStart).setColor(0xFFFFFFFF); - buffer.addVertex(matrix4f, xStart, yStart, z).setUv(uStart, vStart).setColor(0xFFFFFFFF); - }); - } - @Override public CategoryIdentifier getCategoryIdentifier() { return BuiltinPlugin.INFO; @@ -98,11 +86,10 @@ public class DefaultInformationCategory implements DisplayCategory[] tagNode = new TagNode[]{null}; - widgets.add(Widgets.withTranslate(Widgets.delegateWithBounds(() -> delegate[0]), 0, 0, 20)); + widgets.add(Widgets.delegateWithBounds(() -> delegate[0])); TagNodes.create(display.getKey(), dataResult -> { if (dataResult.error().isPresent()) { @@ -140,10 +138,10 @@ public class DefaultTagCategory implements DisplayCategory Widgets.withTranslate(widget, () -> - expanded[0] || !boundsAnimator.value().equals(boundsAnimator.target()) ? translateMatrix : identity)); + return widgets; } } diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/ReferenceTagNodeWidget.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/ReferenceTagNodeWidget.java index b00e6b993..7e17c6986 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/ReferenceTagNodeWidget.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/ReferenceTagNodeWidget.java @@ -34,6 +34,7 @@ import me.shedaniel.rei.api.common.util.EntryIngredients; import me.shedaniel.rei.plugin.common.displays.tag.TagNode; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; +import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.client.renderer.RenderType; import net.minecraft.core.Holder; import net.minecraft.network.chat.Component; @@ -69,8 +70,8 @@ public class ReferenceTagNodeWidget extends TagNodeWidget { @Override public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { - if (this.overflowBounds.intersects(MatrixUtils.transform(graphics.pose().last().pose(), getBounds()))) { - graphics.innerBlit(RenderType::guiTextured, ResourceLocation.withDefaultNamespace("textures/gui/sprites/advancements/task_frame_unobtained.png"), + if (this.overflowBounds.intersects(MatrixUtils.transform(graphics.pose(), getBounds()))) { + graphics.innerBlit(RenderPipelines.GUI_TEXTURED, ResourceLocation.withDefaultNamespace("textures/gui/sprites/advancements/task_frame_unobtained.png"), bounds.x - 1, bounds.x - 1 + 26, bounds.y - 1, bounds.y - 1 + 26, 0, 1, 0, 1, -1); this.slot.getBounds().setLocation(bounds.getCenterX() - this.slot.getBounds().getWidth() / 2, bounds.y + (bounds.height - this.slot.getBounds().getHeight()) / 2 + 1); diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/TagTreeWidget.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/TagTreeWidget.java index 9b5c2747e..6a3c25514 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/TagTreeWidget.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/TagTreeWidget.java @@ -91,7 +91,7 @@ public class TagTreeWidget extends WidgetWithBounds { rootWidget.getBounds().getMaxY() + 6, rootWidget.getBounds().getMaxY() + 16, 0xFFFFFFFF); childWidget.getBounds().setLocation(getBounds().getCenterX() - childrenTotalWidth / 2 + x, this.rootWidget.getBounds().getMaxY() + 16); - if (this.overflowBounds.intersects(MatrixUtils.transform(graphics.pose().last().pose(), childWidget.getBounds()))) { + if (this.overflowBounds.intersects(MatrixUtils.transform(graphics.pose(), childWidget.getBounds()))) { childWidget.render(graphics, mouseX, mouseY, delta); } x += childWidget.getBounds().width + 6; diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/ValueTagNodeWidget.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/ValueTagNodeWidget.java index a108bdaa6..d5537063c 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/ValueTagNodeWidget.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/ValueTagNodeWidget.java @@ -34,7 +34,7 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.core.Holder; import net.minecraft.core.HolderSet; -import org.joml.Matrix4f; +import org.joml.Matrix3x2f; import java.util.ArrayList; import java.util.Collections; @@ -71,7 +71,7 @@ public class ValueTagNodeWidget extends TagNodeWidget { i++; } this.widget = Widgets.withTranslate(Widgets.concat(this.widgets), - $ -> new Matrix4f().translate(getBounds().x, getBounds().y, 0)); + $ -> new Matrix3x2f().translate(getBounds().x, getBounds().y)); this.children = Collections.singletonList(this.widget); } @@ -83,17 +83,17 @@ public class ValueTagNodeWidget extends TagNodeWidget { @Override public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { Rectangle bounds = getBounds(); - if (this.overflowBounds.intersects(MatrixUtils.transform(graphics.pose().last().pose(), bounds))) { - graphics.pose().pushPose(); - graphics.pose().translate(bounds.x, bounds.y, 0); + if (this.overflowBounds.intersects(MatrixUtils.transform(graphics.pose(), bounds))) { + graphics.pose().pushMatrix(); + graphics.pose().translate(bounds.x, bounds.y); Point mouse = new Point(mouseX - bounds.x, mouseY - bounds.y); for (Widget widget : this.widgets) { if (!(widget instanceof WidgetWithBounds withBounds) || - this.overflowBounds.intersects(MatrixUtils.transform(graphics.pose().last().pose(), withBounds.getBounds()))) { + this.overflowBounds.intersects(MatrixUtils.transform(graphics.pose(), withBounds.getBounds()))) { widget.render(graphics, mouse.x, mouse.y, delta); } } - graphics.pose().popPose(); + graphics.pose().popMatrix(); } } diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java index e78e10cc3..161b3deda 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java @@ -105,21 +105,21 @@ public class GameModeFavoriteEntry extends FavoriteEntry { public void render(GuiGraphics graphics, Rectangle bounds, int mouseX, int mouseY, float delta) { int color = bounds.contains(mouseX, mouseY) ? 0xFFEEEEEE : 0xFFAAAAAA; if (bounds.width > 4 && bounds.height > 4) { - graphics.pose().pushPose(); - graphics.pose().translate(bounds.getCenterX(), bounds.getCenterY(), 0); - graphics.pose().scale(bounds.getWidth() / 18f, bounds.getHeight() / 18f, 1); + graphics.pose().pushMatrix(); + graphics.pose().translate(bounds.getCenterX(), bounds.getCenterY()); + graphics.pose().scale(bounds.getWidth() / 18f, bounds.getHeight() / 18f); renderGameModeText(graphics, type, 0, 0, color); - graphics.pose().popPose(); + graphics.pose().popMatrix(); } } private void renderGameModeText(GuiGraphics graphics, GameType type, int centerX, int centerY, int color) { Component s = Component.translatable("text.rei.short_gamemode." + type.getName()); Font font = Minecraft.getInstance().font; - graphics.pose().pushPose(); - graphics.pose().translate(centerX - font.width(s) / 2f + 0.5f, centerY - 3.5f, 0); + graphics.pose().pushMatrix(); + graphics.pose().translate(centerX - font.width(s) / 2f + 0.5f, centerY - 3.5f); graphics.drawString(font, s, 0, 0, color, false); - graphics.pose().popPose(); + graphics.pose().popMatrix(); } @Override diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java index dec965a60..ef2fcdec6 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java @@ -40,7 +40,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.client.resources.language.I18n; import net.minecraft.client.resources.sounds.SimpleSoundInstance; import net.minecraft.nbt.CompoundTag; @@ -140,16 +140,16 @@ public class TimeFavoriteEntry extends FavoriteEntry { public void render(GuiGraphics graphics, Rectangle bounds, int mouseX, int mouseY, float delta) { int color = bounds.contains(mouseX, mouseY) ? 0xFFEEEEEE : 0xFFAAAAAA; if (bounds.width > 4 && bounds.height > 4) { - graphics.pose().pushPose(); - graphics.pose().translate(bounds.getCenterX(), bounds.getCenterY(), 0); - graphics.pose().scale(bounds.getWidth() / 18f, bounds.getHeight() / 18f, 1); + graphics.pose().pushMatrix(); + graphics.pose().translate(bounds.getCenterX(), bounds.getCenterY()); + graphics.pose().scale(bounds.getWidth() / 18f, bounds.getHeight() / 18f); renderTimeIcon(graphics, time, 0, 0, color); - graphics.pose().popPose(); + graphics.pose().popMatrix(); } } private void renderTimeIcon(GuiGraphics graphics, Time time, int centerX, int centerY, int color) { - graphics.blit(RenderType::guiTextured, CHEST_GUI_TEXTURE, centerX - 7, centerY - 7, time.ordinal() * 14 + 42, 14, 14, 14, 256, 256); + graphics.blit(RenderPipelines.GUI_TEXTURED, CHEST_GUI_TEXTURE, centerX - 7, centerY - 7, time.ordinal() * 14 + 42, 14, 14, 14, 256, 256); } @Override diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java index fde840d21..d20ea2939 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java @@ -40,7 +40,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.client.resources.language.I18n; import net.minecraft.client.resources.sounds.SimpleSoundInstance; import net.minecraft.nbt.CompoundTag; @@ -116,16 +116,16 @@ public class WeatherFavoriteEntry extends FavoriteEntry { public void render(GuiGraphics graphics, Rectangle bounds, int mouseX, int mouseY, float delta) { int color = bounds.contains(mouseX, mouseY) ? 0xFFEEEEEE : 0xFFAAAAAA; if (bounds.width > 4 && bounds.height > 4) { - graphics.pose().pushPose(); - graphics.pose().translate(bounds.getCenterX(), bounds.getCenterY(), 0); - graphics.pose().scale(bounds.getWidth() / 18f, bounds.getHeight() / 18f, 1); + graphics.pose().pushMatrix(); + graphics.pose().translate(bounds.getCenterX(), bounds.getCenterY()); + graphics.pose().scale(bounds.getWidth() / 18f, bounds.getHeight() / 18f); renderWeatherIcon(graphics, weather, 0, 0, color); - graphics.pose().popPose(); + graphics.pose().popMatrix(); } } private void renderWeatherIcon(GuiGraphics graphics, Weather type, int centerX, int centerY, int color) { - graphics.blit(RenderType::guiTextured, CHEST_GUI_TEXTURE, centerX - 7, centerY - 7, type.getId() * 14, 14, 14, 14, 256, 256); + graphics.blit(RenderPipelines.GUI_TEXTURED, CHEST_GUI_TEXTURE, centerX - 7, centerY - 7, type.getId() * 14, 14, 14, 14, 256, 256); } @Override diff --git a/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java b/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java index 7585fb2e6..f77d7b2fa 100644 --- a/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java +++ b/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java @@ -23,28 +23,20 @@ package me.shedaniel.rei.fabric; -import com.google.common.base.Suppliers; import dev.architectury.platform.Platform; import dev.architectury.utils.Env; import me.shedaniel.rei.RoughlyEnoughItemsState; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.common.plugins.*; -import me.shedaniel.rei.impl.ClientInternals; import me.shedaniel.rei.impl.init.PluginDetector; import me.shedaniel.rei.impl.init.PrimitivePlatformAdapter; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.entrypoint.EntrypointContainer; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; -import net.minecraft.world.inventory.tooltip.TooltipComponent; import org.apache.commons.lang3.tuple.Pair; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.util.*; -import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Supplier; import java.util.stream.Collectors; @@ -139,24 +131,6 @@ public class PluginDetectorImpl implements PluginDetector { public Supplier detectClientPlugins() { return () -> () -> { loadPlugin(REIClientPlugin.class, PluginManager.getClientInstance().view()::registerPlugin); - Supplier method = Suppliers.memoize(() -> { - String methodName = FabricLoader.getInstance().isDevelopmentEnvironment() ? FabricLoader.getInstance().getMappingResolver().mapMethodName("intermediary", "net.minecraft.class_332", "method_51442", "(Ljava/util/List;Lnet/minecraft/class_5632;)V") - : "method_51442"; - try { - Method declaredMethod = GuiGraphics.class.getDeclaredMethod(methodName, List.class, TooltipComponent.class); - if (declaredMethod != null) declaredMethod.setAccessible(true); - return declaredMethod; - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } - }); - ClientInternals.attachInstance((BiConsumer, TooltipComponent>) (lines, component) -> { - try { - method.get().invoke(null, lines, component); - } catch (IllegalAccessException | InvocationTargetException e) { - throw new RuntimeException(e); - } - }, "clientTooltipComponentProvider"); }; } } diff --git a/fabric/src/main/java/me/shedaniel/rei/impl/client/gui/fabric/ScreenOverlayImplFabric.java b/fabric/src/main/java/me/shedaniel/rei/impl/client/gui/fabric/ScreenOverlayImplFabric.java index 89883f9fd..fe6c103ca 100644 --- a/fabric/src/main/java/me/shedaniel/rei/impl/client/gui/fabric/ScreenOverlayImplFabric.java +++ b/fabric/src/main/java/me/shedaniel/rei/impl/client/gui/fabric/ScreenOverlayImplFabric.java @@ -24,7 +24,6 @@ package me.shedaniel.rei.impl.client.gui.fabric; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; -import me.shedaniel.rei.impl.ClientInternals; import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; @@ -64,13 +63,8 @@ public class ScreenOverlayImplFabric extends ScreenOverlayImpl { if (component instanceof ClientTooltipComponent client) { lines.add(client); - continue; - } - - try { - ClientInternals.getClientTooltipComponent(lines, component); - } catch (Throwable exception) { - throw new IllegalArgumentException("Failed to add tooltip component! " + component + ", Class: " + (component == null ? null : component.getClass().getCanonicalName()), exception); + } else { + lines.add(ClientTooltipComponent.create(component)); } } } @@ -81,8 +75,8 @@ public class ScreenOverlayImplFabric extends ScreenOverlayImpl { if (lines.isEmpty()) { return; } - graphics.pose().pushPose(); - graphics.renderTooltipInternal(Minecraft.getInstance().font, lines, mouseX, mouseY, DefaultTooltipPositioner.INSTANCE, tooltipStyle); - graphics.pose().popPose(); + graphics.pose().pushMatrix(); + graphics.setTooltipForNextFrameInternal(Minecraft.getInstance().font, lines, mouseX, mouseY, DefaultTooltipPositioner.INSTANCE, tooltipStyle, false); + graphics.pose().popMatrix(); } } diff --git a/fabric/src/main/resources/error_notifier.json b/fabric/src/main/resources/error_notifier.json index a2e3d01ed..4c0867265 100644 --- a/fabric/src/main/resources/error_notifier.json +++ b/fabric/src/main/resources/error_notifier.json @@ -12,14 +12,14 @@ "type": "depends", "modId": "architectury", "modName": "Architectury API", - "versions": ">=16.1.0 <17.0.0", + "versions": ">=17.0.0 <18.0.0", "url": "https://www.curseforge.com/minecraft/mc-mods/architectury-api/" }, { "type": "depends", "modId": "cloth-config2", "modName": "Cloth Config", - "versions": ">=18.0.0 <19.0.0", + "versions": ">=19.0.0 <20.0.0", "url": "https://www.curseforge.com/minecraft/mc-mods/cloth-config/" } ] diff --git a/fabric/src/main/resources/roughlyenoughitems.accessWidener b/fabric/src/main/resources/roughlyenoughitems.accessWidener index 84e1facb8..5dcf72cba 100644 --- a/fabric/src/main/resources/roughlyenoughitems.accessWidener +++ b/fabric/src/main/resources/roughlyenoughitems.accessWidener @@ -1,5 +1,4 @@ accessWidener v1 named -accessible class net/minecraft/client/gui/Font$StringRenderOutput accessible class net/minecraft/world/item/alchemy/PotionBrewing$Mix accessible field net/minecraft/client/gui/components/ImageButton sprites Lnet/minecraft/client/gui/components/WidgetSprites; accessible field net/minecraft/client/gui/screens/inventory/AbstractContainerScreen hoveredSlot Lnet/minecraft/world/inventory/Slot; @@ -25,7 +24,8 @@ extendable method net/minecraft/client/gui/screens/Screen accessible method net/minecraft/client/gui/screens/Screen addRenderableWidget (Lnet/minecraft/client/gui/components/events/GuiEventListener;)Lnet/minecraft/client/gui/components/events/GuiEventListener; accessible method net/minecraft/client/gui/screens/Screen addRenderableOnly (Lnet/minecraft/client/gui/components/Renderable;)Lnet/minecraft/client/gui/components/Renderable; accessible method net/minecraft/client/gui/screens/Screen addWidget (Lnet/minecraft/client/gui/components/events/GuiEventListen