diff options
126 files changed, 681 insertions, 1506 deletions
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 @@ -116,14 +116,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. * * @return 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 <T> the entry type - * @param <E> the type of extra data returned in {@link #getExtraData(EntryStack)} - */ -@Environment(EnvType.CLIENT) -public interface BatchedEntryRenderer<T, E> extends EntryRenderer<T> { - default boolean isBatched(EntryStack<T> entry) { - return true; - } - - /** - * Returns extra data to be passed to various rendering methods. - * - * @param entry the stack - * @return the extra data - */ - E getExtraData(EntryStack<T> 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<T> 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<T> entry, E extraData, GuiGraphics graphics, float delta); - - void renderBase(EntryStack<T> entry, E extraData, GuiGraphics graphics, MultiBufferSource.BufferSource immediate, Rectangle bounds, int mouseX, int mouseY, float delta); - - void afterBase(EntryStack<T> entry, E extraData, GuiGraphics graphics, float delta); - - void renderOverlay(EntryStack<T> 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<T> entry, E extraData, GuiGraphics graphics, float delta); - - @Override - default void render(EntryStack<T> 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 <T extends Widget> WidgetWithBounds withTranslate(T widget, Function<T, Matrix4f> translate) { + public static <T extends Widget> WidgetWithBounds withTranslate(T widget, Function<T, Matrix3x2f> translate) { return withTranslate(widget, () -> translate.apply(widget)); } - public static WidgetWithBounds withTranslate(Widget widget, Supplier<Matrix4f> translate) { + public static WidgetWithBounds withTranslate(Widget widget, Supplier<Matrix3x2f> 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<Component, BooleanValue, FavoriteMenuEntry> toggleEntry = (supplier, toJson) -> throwNotSetup(); private static Function<CompoundTag, DataResult<FavoriteEntry>> favoriteEntryFromJson = (object) -> throwNotSetup(); private static Function<Boolean, ClickArea.Result> clickAreaHandlerResult = (result) -> throwNotSetup(); - private static BiConsumer<List<ClientTooltipComponent>, TooltipComponent> clientTooltipComponentProvider = (tooltip, result) -> throwNotSetup(); private static BiFunction<@Nullable Point, Collection<Tooltip.Entry>, Tooltip> tooltipProvider = (point, texts) -> throwNotSetup(); private static QuadFunction<Point, @Nullable TooltipFlag, Boolean, Item.TooltipContext, TooltipContext> tooltipContextProvider = (point, texts, search, context) -> throwNotSetup(); private static Function<Object, Tooltip.Entry> tooltipEntryProvider = (component) -> throwNotSetup(); @@ -138,10 +137,6 @@ public final class ClientInternals { return clickAreaHandlerResult.apply(applicable); } - public static void getClientTooltipComponent(List<ClientTooltipComponent> tooltip, TooltipComponent component) { - clientTooltipComponentProvider.accept(tooltip, component); - } - public static Tooltip createTooltip(@Nullable Point point, Collection<Tooltip.Entry> texts) { return tooltipProvider.apply(point, texts); } @@ -200,7 +195,7 @@ public final class ClientInternals { WidgetWithBounds wrapRenderer(Supplier<Rectangle> bounds, Renderer renderer); - WidgetWithBounds withTranslate(WidgetWithBounds widget, Supplier<Matrix4f> translate); + WidgetWithBounds withTranslate(WidgetWithBounds widget, Supplier<Matrix3x2f> 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<DefaultBrewingDis widgets.add(Widgets.createRecipeBase(bounds)); widgets.add(Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> { 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<DefaultFuelDisplay> @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<DefaultInformationDisplay> { - 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<? extends DefaultInformationDisplay> getCategoryIdentifier() { return BuiltinPlugin.INFO; @@ -98,11 +86,10 @@ public class DefaultInformationCategory implements DisplayCategory<DefaultInform return new Renderer() { @Override public void render(GuiGraphics graphics, Rectangle bounds, int mouseX, int mouseY, float delta) { - graphics.pose().pushPose(); - graphics.pose().translate(-1.2f, -1, 0); - Matrix4f matrix = graphics.pose().last().pose(); - DefaultInformationCategory.innerBlit(graphics, matrix, bounds.getCenterX() - 8, bounds.getCenterX() + 8, bounds.getCenterY() - 8, bounds.getCenterY() + 8, 0, 116f / 256f, (116f + 16f) / 256f, 0f, 16f / 256f); - graphics.pose().popPose(); + graphics.pose().pushMatrix(); + graphics.pose().translate(-1.2f, -1); + graphics.innerBlit(RenderPipelines.GUI_TEXTURED, REIRuntime.getInstance().getDefaultDisplayTexture(), bounds.getCenterX() - 8, bounds.getCenterX() + 8, bounds.getCenterY() - 8, bounds.getCenterY() + 8, 116f / 256f, (116f + 16f) / 256f, 0f, 16f / 256f, -1); + graphics.pose().popMatrix(); } }; } diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/anvil/DefaultAnvilCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/anvil/DefaultAnvilCategory.java index c1f292e96..9f09eddeb 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/anvil/DefaultAnvilCategory.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/anvil/DefaultAnvilCategory.java @@ -73,7 +73,7 @@ public class DefaultAnvilCategory implements DisplayCategory<DefaultAnvilDisplay Component component = Component.translatable("container.repair.cost", display.getCost().getAsInt()); int x = startPoint.x + 102 - font.width(component) - 2; graphics.fill(x - 2, startPoint.y + 28, startPoint.x + 102, startPoint.y + 28 + 12, 0x4f000000); - graphics.drawString(font, component, x, startPoint.y + 28 + 2, 0x80ff20); + graphics.drawString(font, component, x, startPoint.y + 28 + 2, 0xff80ff20); })); } return widgets; diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/DefaultTagCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/DefaultTagCategory.java index 420a96dbb..e0a3711d3 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/DefaultTagCategory.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/DefaultTagCategory.java @@ -35,7 +35,6 @@ import me.shedaniel.rei.api.client.registry.display.DisplayCategory; import me.shedaniel.rei.api.client.util.ClientEntryStacks; import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.entry.EntryStack; -import me.shedaniel.rei.api.common.util.CollectionUtils; import me.shedaniel.rei.api.common.util.EntryStacks; import me.shedaniel.rei.plugin.common.BuiltinPlugin; import me.shedaniel.rei.plugin.common.displays.tag.DefaultTagDisplay; @@ -49,7 +48,6 @@ import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Items; import org.jetbrains.annotations.Nullable; -import org.joml.Matrix4f; import java.util.ArrayList; import java.util.List; @@ -118,7 +116,7 @@ public class DefaultTagCategory implements DisplayCategory<DefaultTagDisplay<?, WidgetWithBounds[] delegate = new WidgetWithBounds[]{Widgets.noOp()}; TagNode<?>[] 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<DefaultTagDisplay<?, Font font = instance.font; String text = "?"; int width = font.width(text); - graphics.pose().pushPose(); - graphics.pose().translate(bounds.getCenterX() - width / 2f + 0.2f, bounds.getCenterY() - font.lineHeight / 2f + 1f, 0); + graphics.pose().pushMatrix(); + graphics.pose().translate(bounds.getCenterX() - width / 2f + 0.2f, bounds.getCenterY() - font.lineHeight / 2f + 1f); graphics.drawString(font, text, 0, 0, REIRuntime.getInstance().isDarkThemeEnabled() ? -4473925 : -12566464, false); - graphics.pose().popPose(); + graphics.pose().popMatrix(); } @Override @@ -179,7 +177,7 @@ public class DefaultTagCategory implements DisplayCategory<DefaultTagDisplay<?, } }) .tooltipLine(Component.translatable("text.rei.tag.copy.clipboard"))); - widgets.add(Widgets.withTranslate(new DelegateWidget(Widgets.noOp()) { + widgets.add(new DelegateWidget(Widgets.noOp()) { @Override protected Widget delegate() { ResourceLocation expandTexture = !expanded[0] ? ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "textures/gui/expand.png") @@ -191,12 +189,8 @@ public class DefaultTagCategory implements DisplayCategory<DefaultTagDisplay<?, new Rectangle(recipeBounds.x + 5 + 2, recipeBounds.getMaxY() - 6 - 13 + 2, 13 - 4, 13 - 4), 0, 0, 9, 9) ); } - }, 0, 0, 10)); + }); - Matrix4f translateMatrix = new Matrix4f().translate(0, 0, 200); - Matrix4f identity = new Matrix4f(); - identity.identity(); - return CollectionUtils.map(widgets, widget -> 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<S, T> extends TagNodeWidget<S, T> { @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<S, T> 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<S, T> extends TagNodeWidget<S, T> { 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<S, T> extends TagNodeWidget<S, T> { @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<Runnable> detectClientPlugins() { return () -> () -> { loadPlugin(REIClientPlugin.class, PluginManager.getClientInstance().view()::registerPlugin); - Supplier<Method> 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<List<ClientTooltipComponent>, 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/GuiEventListener;)Lnet/minecraft/client/gui/components/events/GuiEventListener; -accessible method net/minecraft/client/gui/GuiGraphics renderTooltipInternal (Lnet/minecraft/client/gui/Font;Ljava/util/List;IILnet/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipPositioner;Lnet/minecraft/resources/ResourceLocation;)V +accessible method net/minecraft/client/gui/GuiGraphics setTooltipForNextFrameInternal (Lnet/minecraft/client/gui/Font;Ljava/util/List;IILnet/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipPositioner;Lnet/minecraft/resources/ResourceLocation;Z)V +accessible method net/minecraft/client/gui/GuiGraphics innerBlit (Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/resources/ResourceLocation;IIIIFFFFI)V accessible field net/minecraft/tags/TagEntry tag Z accessible field net/minecraft/tags/TagEntry required Z accessible field net/minecraft/tags/TagEntry id Lnet/minecraft/resources/ResourceLocation; @@ -40,8 +40,6 @@ accessible method net/minecraft/world/item/crafting/SingleItemRecipe result ()Ln accessible field net/minecraft/world/item/crafting/ShapedRecipe result Lnet/minecraft/world/item/ItemStack; accessible field net/minecraft/world/item/crafting/ShapelessRecipe result Lnet/minecraft/world/item/ItemStack; accessible field net/minecraft/client/gui/screens/inventory/AbstractRecipeBookScreen recipeBookComponent Lnet/minecraft/client/gui/screens/recipebook/RecipeBookComponent; -accessible method net/minecraft/client/gui/GuiGraphics innerBlit (Ljava/util/function/Function;Lnet/minecraft/resources/ResourceLocation;IIIIFFFFI)V -accessible field net/minecraft/client/gui/GuiGraphics bufferSource Lnet/minecraft/client/renderer/MultiBufferSource$BufferSource; accessible field net/minecraft/client/gui/GuiGraphics scissorStack Lnet/minecraft/client/gui/GuiGraphics$ScissorStack; mutable field net/minecraft/client/gui/GuiGraphics scissorStack Lnet/minecraft/client/gui/GuiGraphics$ScissorStack; accessible class net/minecraft/client/gui/GuiGraphics$ScissorStack diff --git a/forge/src/main/java/me/shedaniel/rei/impl/client/gui/forge/ScreenOverlayImplForge.java b/forge/src/main/java/me/shedaniel/rei/impl/client/gui/forge/ScreenOverlayImplForge.java index e8937ca26..3fa078850 100644 --- a/forge/src/main/java/me/shedaniel/rei/impl/client/gui/forge/ScreenOverlayImplForge.java +++ b/forge/src/main/java/me/shedaniel/rei/impl/client/gui/forge/ScreenOverlayImplForge.java @@ -46,7 +46,7 @@ import java.util.Optional; public class ScreenOverlayImplForge extends ScreenOverlayImpl { @Override public void renderTooltipInner(Screen screen, GuiGraphics graphics, Tooltip tooltip, int mouseX, int mouseY) { - graphics.pose().pushPose(); + graphics.pose().pushMatrix(); EntryStack<?> stack = tooltip.getContextStack(); ItemStack itemStack = stack.getType() == VanillaEntryTypes.ITEM ? stack.castValue() : ItemStack.EMPTY; List<Component> texts = CollectionUtils.filterAndMap(tooltip.entries(), Tooltip.Entry::isText, Tooltip.Entry::getAsText); @@ -71,6 +71,6 @@ public class ScreenOverlayImplForge extends ScreenOverlayImpl { graphics.tooltipStack = itemStack; graphics.renderTooltipInternal(font, components, mouseX, mouseY, DefaultTooltipPositioner.INSTANCE); graphics.tooltipStack = ItemStack.EMPTY; - graphics.pose().popPose(); + graphics.pose().popMatrix(); } } diff --git a/gradle.properties b/gradle.properties index b67d624e1..8daa9affd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,16 +1,16 @@ org.gradle.jvmargs=-Xmx6G -base_version=19.0 +base_version=20.0 unstable=false -supported_version=1.21.5 -minecraft_version=1.21.5 +supported_version=1.21.6/7 +minecraft_version=1.21.6 platforms=fabric,neoforge forge_version=49.1.10 -neoforge_version=21.5.23-beta +neoforge_version=21.6.19-beta neoforge_pr= -fabricloader_version=0.16.12 -cloth_config_version=18.0.145 -modmenu_version=11.0.0-rc.2 -fabric_api=0.119.6+1.21.5 -architectury_version=16.1.4 +fabricloader_version=0.16.14 +cloth_config_version=19.0.147 +modmenu_version=15.0.0-beta.3 +fabric_api=0.128.1+1.21.6 +architectury_version=17.0.6 api_exculde= #api_include=me.shedaniel.cloth:cloth-events,me.shedaniel.cloth:config-2,me.sargunvohra.mcmods:autoconfig1u,org.jetbrains:annotations,net.fabricmc.fabric-api:fabric diff --git a/neoforge/src/main/java/me/shedaniel/rei/impl/client/gui/forge/ScreenOverlayImplForge.java b/neoforge/src/main/java/me/shedaniel/rei/impl/client/gui/forge/ScreenOverlayImplForge.java index 78751b442..dea238b6d 100644 --- a/neoforge/src/main/java/me/shedaniel/rei/impl/client/gui/forge/ScreenOverlayImplForge.java +++ b/neoforge/src/main/java/me/shedaniel/rei/impl/client/gui/forge/ScreenOverlayImplForge.java @@ -46,7 +46,7 @@ import java.util.Optional; public class ScreenOverlayImplForge extends ScreenOverlayImpl { @Override public void renderTooltipInner(Screen screen, GuiGraphics graphics, Tooltip tooltip, int mouseX, int mouseY) { - graphics.pose().pushPose(); + graphics.pose().pushMatrix(); EntryStack<?> stack = tooltip.getContextStack(); ItemStack itemStack = stack.getType() == VanillaEntryTypes.ITEM ? stack.castValue() : ItemStack.EMPTY; List<Component> texts = CollectionUtils.filterAndMap(tooltip.entries(), Tooltip.Entry::isText, Tooltip.Entry::getAsText); @@ -69,8 +69,8 @@ public class ScreenOverlayImplForge extends ScreenOverlayImpl { font = ClientHooks.getTooltipFont(itemStack, font); } graphics.tooltipStack = itemStack; - graphics.renderTooltipInternal(font, components, mouseX, mouseY, DefaultTooltipPositioner.INSTANCE, tooltip.getTooltipStyle()); + graphics.setTooltipForNextFrameInternal(font, components, mouseX, mouseY, DefaultTooltipPositioner.INSTANCE, tooltip.getTooltipStyle(), false); graphics.tooltipStack = ItemStack.EMPTY; - graphics.pose().popPose(); + graphics.pose().popMatrix(); } } diff --git a/neoforge/src/main/resources/META-INF/accesstransformer.cfg b/neoforge/src/main/resources/META-INF/accesstransformer.cfg index 387e2bce5..c4c0703e4 100644 --- a/neoforge/src/main/resources/META-INF/accesstransformer.cfg +++ b/neoforge/src/main/resources/META-INF/accesstransformer.cfg @@ -1,4 +1,3 @@ -public net.minecraft.client.gui.Font$StringRenderOutput public net.minecraft.world.item.alchemy.PotionBrewing$Mix public net.minecraft.client.gui.components.ImageButton sprites public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen hoveredSlot @@ -28,9 +27,9 @@ public-f net.minecraft.client.gui.screens.inventory.AbstractContainerScreen drag protected net.minecraft.client.gui.screens.Screen init(Lnet/minecraft/client/Minecraft;II)V public net.minecraft.client.gui.screens.Screen addRenderableWidget(Lnet/minecraft/client/gui/components/events/GuiEventListener;)Lnet/minecraft/client/gui/components/events/GuiEventListener; public net.minecraft.client.gui.screens.Screen addRenderableOnly(Lnet/minecraft/client/gui/components/Renderable;)Lnet/minecraft/client/gui/components/Renderable; -public net.minecraft.client.gui.GuiGraphics renderTooltipInternal(Lnet/minecraft/client/gui/Font;Ljava/util/List;IILnet/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipPositioner;Lnet/minecraft/resources/ResourceLocation;)V # renderTooltipInternal +public net.minecraft.client.gui.GuiGraphics setTooltipForNextFrameInternal(Lnet/minecraft/client/gui/Font;Ljava/util/List;IILnet/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipPositioner;Lnet/minecraft/resources/ResourceLocation;Z)V # setTooltipForNextFrameInternal public net.minecraft.client.gui.GuiGraphics tooltipStack -public net.minecraft.client.gui.GuiGraphics innerBlit(Lnet/minecraft/resources/ResourceLocation;IIIIIFFFF)V # innerBlit +public net.minecraft.client.gui.GuiGraphics innerBlit(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/resources/ResourceLocation;IIIIFFFFI)V public net.minecraft.client.renderer.RenderType$OutlineProperty public net.minecraft.client.renderer.RenderType$CompositeState public net.minecraft.tags.TagEntry tag # tag @@ -50,8 +49,6 @@ public net.minecraft.world.item.crafting.SingleItemRecipe result()Lnet/minecraft public net.minecraft.world.item.crafting.ShapedRecipe result public net.minecraft.world.item.crafting.ShapelessRecipe result public net.minecraft.client.gui.screens.inventory.AbstractRecipeBookScreen recipeBookComponent -public net.minecraft.client.gui.GuiGraphics innerBlit(Ljava/util/function/Function;Lnet/minecraft/resources/ResourceLocation;IIIIFFFFI)V -public net.minecraft.client.gui.GuiGraphics bufferSource public-f net.minecraft.client.gui.GuiGraphics scissorStack public net.minecraft.client.gui.GuiGraphics$ScissorStack public net.minecraft.client.gui.GuiGraphics$ScissorStack stack diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java index 69275ebc9..107522bc4 100644 --- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java +++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java @@ -236,7 +236,7 @@ public class RoughlyEnoughItemsCoreClient { Minecraft client = Minecraft.getInstance(); NetworkManager.registerReceiver(NetworkManager.s2c(), RoughlyEnoughItemsNetwork.CREATE_ITEMS_MESSAGE_PACKET, (buf, context) -> { - ItemStack stack = buf.readJsonWithCodec(ItemStack.OPTIONAL_CODEC); + ItemStack stack = buf.readLenientJsonWithCodec(ItemStack.OPTIONAL_CODEC); String player = buf.readUtf(32767); if (client.player != null) { client.player.displayClientMessage(Component.literal(I18n.get("text.rei.cheat_items").replaceAll("\\{item_name}", EntryStacks.of(stack.copy()).asFormattedText().getString()).replaceAll("\\{item_count}", stack.copy().getCount() + "").replaceAll("\\{player_name}", player)), false); diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java index 511decbd6..99fd2cfca 100644 --- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java +++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java @@ -90,7 +90,7 @@ public class RoughlyEnoughItemsNetwork { player.displayClientMessage(Component.translatable("text.rei.no_permission_cheat").withStyle(ChatFormatting.RED), false); return; } - ItemStack stack = buf.readJsonWithCodec(ItemStack.OPTIONAL_CODEC); + ItemStack stack = buf.readLenientJsonWithCodec(ItemStack.OPTIONAL_CODEC); if (player.getInventory().add(stack.copy())) { RegistryFriendlyByteBuf newBuf = new RegistryFriendlyByteBuf(Unpooled.buffer(), player.registryAccess()); newBuf.writeJsonWithCodec(ItemStack.OPTIONAL_CODEC, stack.copy()); @@ -108,7 +108,7 @@ public class RoughlyEnoughItemsNetwork { } AbstractContainerMenu menu = player.containerMenu; - ItemStack itemStack = buf.readJsonWithCodec(ItemStack.OPTIONAL_CODEC); + ItemStack itemStack = buf.readLenientJsonWithCodec(ItemStack.OPTIONAL_CODEC); ItemStack stack = itemStack.copy(); if (!menu.getCarried().isEmpty() && ItemStack.isSameItemSameComponents(menu.getCarried(), stack)) { stack.setCount(Mth.clamp(stack.getCount() + menu.getCarried().getCount(), 1, stack.getMaxStackSize())); @@ -128,7 +128,7 @@ public class RoughlyEnoughItemsNetwork { player.displayClientMessage(Component.translatable("text.rei.no_permission_cheat").withStyle(ChatFormatting.RED), false); return; } - ItemStack stack = buf.readJsonWithCodec(ItemStack.OPTIONAL_CODEC); + ItemStack stack = buf.readLenientJsonWithCodec(ItemStack.OPTIONAL_CODEC); int hotbarSlotId = buf.readVarInt(); if (hotbarSlotId >= 0 && hotbarSlotId < 9) { AbstractContainerMenu menu = player.containerMenu; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java index 4b500fa1f..7a0c0e1de 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java @@ -109,11 +109,6 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { } @Override - public boolean isFavoritesAnimated() { - return !basics.reduceMotion; - } - - @Override public boolean isReducedMotion() { return basics.reduceMotion; } @@ -295,11 +290,6 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { } @Override - public boolean doesFastEntryRendering() { - return advanced.miscellaneous.newFastEntryRendering; - } - - @Override public boolean doesCacheEntryRendering() { return advanced.miscellaneous.cachingFastEntryRendering; } @@ -737,7 +727,6 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { @Comment("Declares whether arrows in containers should be clickable.") public boolean clickableRecipeArrows = true; public boolean registerRecipesInAnotherThread = true; - public boolean newFastEntryRendering = true; public boolean cachingFastEntryRendering = false; public boolean cachingDisplayLookup = true; public CategorySettings categorySettings = new CategorySettings(); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/addon/ConfigAddonsScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/addon/ConfigAddonsScreen.java index 6b973084a..2bc1e1f5a 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/addon/ConfigAddonsScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/addon/ConfigAddonsScreen.java @@ -35,7 +35,7 @@ import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.narration.NarratableEntry; import net.minecraft.client.gui.navigation.FocusNavigationEvent; import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.locale.Language; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.FormattedText; @@ -130,7 +130,7 @@ public class ConfigAddonsScreen extends Screen { @Override public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float delta) { super.renderWidget(graphics, mouseX, mouseY, delta); - graphics.blit(RenderType::guiTextured, InternalTextures.CHEST_GUI_TEXTURE, getX() + 3, getY() + 3, 0, 0, 14, 14, 256, 256); + graphics.blit(RenderPipelines.GUI_TEXTURED, InternalTextures.CHEST_GUI_TEXTURE, getX() + 3, getY() + 3, 0, 0, 14, 14, 256, 256); } }; } 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 f1d0c3ac2..cefe6d493 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 @@ -249,10 +249,7 @@ public class ConfigureCategoriesScreen extends Screen { } Minecraft client = Minecraft.getInstance(); - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 100); configuration.getCategory().getIcon().render(graphics, new Rectangle(x + 2, y, 16, 16), mouseY, mouseY, delta); - graphics.pose().popPose(); int xPos = x + 22; { Component title = configuration.getCategory().getTitle(); @@ -279,14 +276,16 @@ public class ConfigureCategoriesScreen extends Screen { { Component subtitle = Component.translatable("config.roughlyenoughitems.configureCategories.visibility." + shown) .withStyle(shown ? ChatFormatting.GREEN : ChatFormatting.RED); - int i = graphics.drawString(client.font, subtitle.getVisualOrderText(), xPos, y + 22, 8421504); + graphics.drawString(client.font, subtitle, xPos, y + 22, 8421504); + int i = xPos + client.font.width(subtitle); visibilityToggleButton.getPoint().setLocation(i + 3, y + 22); 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 = graphics.drawString(client.font, subtitle.getVisualOrderText(), xPos, y + 32, 8421504); + graphics.drawString(client.font, subtitle, xPos, y + 32, 8421504); + int i = xPos + client.font.width(subtitle); quickCraftToggleButton.getPoint().setLocation(i + 3, y + 32); quickCraftToggleButton.render(graphics, mouseX, mouseY, delta); } else { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringRulesScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringRulesScreen.java index 34b10136f..62e52d7f7 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringRulesScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringRulesScreen.java @@ -45,7 +45,7 @@ import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.narration.NarratableEntry; import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.client.resources.sounds.SimpleSoundInstance; import net.minecraft.locale.Language; import net.minecraft.network.chat.Component; @@ -189,7 +189,7 @@ public class FilteringRulesScreen extends Screen { @Override public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float delta) { super.renderWidget(graphics, mouseX, mouseY, delta); - graphics.blit(RenderType::guiTextured, InternalTextures.CHEST_GUI_TEXTURE, getX() + 3, getY() + 3, 0, 0, 14, 14, 256, 256); + graphics.blit(RenderPipelines.GUI_TEXTURED, InternalTextures.CHEST_GUI_TEXTURE, getX() + 3, getY() + 3, 0, 0, 14, 14, 256, 256); } }; { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringScreen.java index 0e322a879..c6da89b94 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringScreen.java @@ -25,7 +25,6 @@ package me.shedaniel.rei.impl.client.config.entries; import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import com.mojang.blaze3d.vertex.VertexConsumer; import me.shedaniel.clothconfig2.ClothConfigInitializer; import me.shedaniel.clothconfig2.api.scroll.ScrollingContainer; import me.shedaniel.math.Point; @@ -40,7 +39,7 @@ import me.shedaniel.rei.api.client.search.SearchProvider; import me.shedaniel.rei.api.common.entry.EntrySerializer; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl; -import me.shedaniel.rei.impl.client.gui.widget.BatchedEntryRendererManager; +import me.shedaniel.rei.impl.client.gui.widget.EntryRendererManager; import me.shedaniel.rei.impl.client.gui.widget.EntryWidget; import me.shedaniel.rei.impl.client.gui.widget.UpdatedListWidget; import me.shedaniel.rei.impl.client.gui.widget.search.OverlaySearchField; @@ -50,13 +49,11 @@ 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; -import net.minecraft.client.renderer.RenderType; import net.minecraft.network.chat.Component; import net.minecraft.util.Mth; import net.minecraft.world.item.Item; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; -import org.joml.Matrix4f; import java.util.ArrayList; import java.util.Collections; @@ -223,7 +220,7 @@ public class FilteringScreen extends Screen { int skip = Math.max(0, Mth.floor(scrolling.scrollAmount() / (float) entrySize())); int nextIndex = skip * innerBounds.width / entrySize(); int i = nextIndex; - BatchedEntryRendererManager<FilteringListEntry> manager = new BatchedEntryRendererManager<>(); + EntryRendererManager<FilteringListEntry> manager = new EntryRendererManager<>(); for (; i < entryStacks.size(); i++) { EntryStack<?> stack = entryStacks.get(i); FilteringListEntry entry = entries.get(nextIndex); @@ -237,24 +234,22 @@ public class FilteringScreen extends Screen { manager.render(graphics, mouseX, mouseY, delta); updatePosition(delta); scrolling.renderScrollBar(graphics, 0, 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.hideButton.render(graphics, mouseX, mouseY, delta); this.showButton.render(graphics, mouseX, mouseY, delta); - graphics.pose().popPose(); graphics.disableScissor(); - graphics.drawSpecial(source -> { + // TODO: add back border + /*graphics.drawSpecial(source -> { Matrix4f matrix = graphics.pose().last().pose(); VertexConsumer buffer = source.getBuffer(RenderType.gui()); buffer.addVertex(matrix, 0, bounds.y + 4, 0.0F).setColor(0, 0, 0, 0); buffer.addVertex(matrix, width, bounds.y + 4, 0.0F).setColor(0, 0, 0, 0); buffer.addVertex(matrix, width, bounds.y, 0.0F).setColor(0, 0, 0, 255); buffer.addVertex(matrix, 0, bounds.y, 0.0F).setColor(0, 0, 0, 255); - }); + });*/ this.backButton.render(graphics, mouseX, mouseY, delta); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/SearchFilteringRuleType.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/SearchFilteringRuleType.java index cfe4999e0..13a347fed 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/SearchFilteringRuleType.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/SearchFilteringRuleType.java @@ -31,7 +31,7 @@ import me.shedaniel.rei.api.client.search.SearchFilter; import me.shedaniel.rei.api.client.search.SearchProvider; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.impl.client.gui.screen.generic.OptionEntriesScreen; -import me.shedaniel.rei.impl.client.gui.widget.BatchedEntryRendererManager; +import me.shedaniel.rei.impl.client.gui.widget.EntryRendererManager; import me.shedaniel.rei.impl.client.gui.widget.EntryWidget; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; @@ -144,7 +144,7 @@ public enum SearchFilteringRuleType implements FilteringRuleType<SearchFiltering @Override public void render(GuiGraphics graphics, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) { - BatchedEntryRendererManager<EntryWidget> manager = new BatchedEntryRendererManager<>(); + EntryRendererManager<EntryWidget> manager = new EntryRendererManager<>(); int entrySize = entrySize(); int width = entryWidth / entrySize; int i = 0; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java index fe905b5cc..99e5d2dc6 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java @@ -25,7 +25,6 @@ package me.shedaniel.rei.impl.client.gui; import com.google.common.collect.Lists; import com.mojang.blaze3d.platform.Window; -import com.mojang.blaze3d.systems.RenderSystem; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.math.impl.PointHelper; @@ -243,7 +242,6 @@ public abstract class ScreenOverlayImpl extends ScreenOverlay { EntryHighlighter.render(graphics); } if (!hasSpace()) return; - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); this.renderWidgets(graphics, mouseX, mouseY, delta); if (ConfigObject.getInstance().areClickableRecipeArrowsEnabled()) { Screen screen = Minecraft.getInstance().screen; @@ -304,15 +302,9 @@ public abstract class ScreenOverlayImpl extends ScreenOverlay { else if (widget instanceof OverlaySearchField field) field.laterRender(graphics, mouseX, mouseY, delta); } - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 500); menuHolder.lateRender(graphics, mouseX, mouseY, delta); - graphics.pose().popPose(); if (choosePageWidget != null) { - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 500); graphics.fillGradient(0, 0, window.getGuiScaledWidth(), window.getGuiScaledHeight(), -1072689136, -804253680); - graphics.pose().popPose(); choosePageWidget.render(graphics, mouseX, mouseY, delta); } } @@ -325,6 +317,7 @@ public abstract class ScreenOverlayImpl extends ScreenOverlay { if (REIRuntime.getInstance().isOverlayVisible()) { menuHolder.afterRender(); } + graphics.renderDeferredTooltip(); } public void renderTooltip(GuiGraphics graphics, Tooltip tooltip) { 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 e9a766c5d..a845ea440 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 @@ -419,7 +419,7 @@ public class REIConfigScreen extends Screen implements ConfigAccess { this.widgets.remove(this.menuWidget); } this.menu = menu; - this.widgets.add(this.menuWidget = Widgets.withTranslate(menu, 0, 0, 300)); + this.widgets.add(this.menuWidget = menu); } @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 1716578a5..b4d4d8170 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 @@ -36,7 +36,7 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; import net.minecraft.util.FormattedCharSequence; -import org.joml.Matrix4f; +import org.joml.Matrix3x2f; import static me.shedaniel.rei.api.client.gui.widgets.Widget.scissor; @@ -54,7 +54,7 @@ public class ConfigCategoryEntryWidget { return Widgets.concatWithBounds( bounds, label, - hasDescription ? Widgets.withTranslate(Widgets.withTranslate(descriptionLabel, new Matrix4f().scale(0.75f, 0.75f, 0.75f)), 21, 5 + 10, 0) : Widgets.noOp(), + hasDescription ? Widgets.withTranslate(Widgets.withTranslate(descriptionLabel, new Matrix3x2f().scale(0.75f, 0.75f)), 21, 5 + 10) : Widgets.noOp(), Widgets.createTexturedWidget(category.getIcon(), new Rectangle(3, hasDescription ? 5 : 3, 16, 16), 0, 0, 1, 1, 1, 1) ); } @@ -77,15 +77,15 @@ public class ConfigCategoryEntryWidget { 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(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; + textWidth = MatrixUtils.transform(MatrixUtils.inverse(graphics.pose()), new Rectangle(0, 0, textWidth, 100)).width; + width = MatrixUtils.transform(MatrixUtils.inverse(graphics.pose()), new Rectangle(0, 0, width, 100)).width; if (textWidth > width && !ConfigUtils.isReducedMotion()) { - graphics.pose().pushPose(); + graphics.pose().pushMatrix(); float textX = (System.currentTimeMillis() % ((textWidth + 10) * textWidth / 3)) / (float) textWidth * 3; - graphics.pose().translate(-textX, 0, 0); + graphics.pose().translate(-textX, 0); graphics.drawString(font, text, x + width - textWidth - 10, y, color); graphics.drawString(font, text, x + width, y, color); - graphics.pose().popPose(); + graphics.pose().popMatrix(); } else { 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 3fc908a54..2484a0bc4 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 @@ -41,7 +41,7 @@ import me.shedaniel.rei.impl.client.gui.text.TextTransformations; import net.minecraft.client.Minecraft; import org.apache.commons.lang3.tuple.Pair; import org.jetbrains.annotations.Nullable; -import org.joml.Matrix4f; +import org.joml.Matrix3x2f; import java.util.*; import java.util.function.IntConsumer; @@ -80,7 +80,7 @@ public class ConfigGroupWidget { if (location == PreviewLocation.RIGHT) { WidgetWithBounds original = _create(access, entry, halfWidth); Widget background = createBackgroundSlot(() -> new Rectangle(halfWidth + 2, 0, width - halfWidth - 4, original.getBounds().height)); - Widget right = Widgets.withTranslate(pair.getRight().create(access, entry, width - halfWidth - 4, () -> original.getBounds().height), halfWidth + 2, 0, 0); + Widget right = Widgets.withTranslate(pair.getRight().create(access, entry, width - halfWidth - 4, () -> original.getBounds().height), halfWidth + 2, 0); contents = Widgets.concatWithBounds(() -> new Rectangle(0, 0, width, original.getBounds().height), original, background, right); } else { WidgetWithBounds original = _create(access, entry, width); @@ -89,11 +89,11 @@ public class ConfigGroupWidget { Widget background = createBackgroundSlot(widget::getBounds); if (location == PreviewLocation.TOP) { - WidgetWithBounds translatedOriginal = Widgets.withTranslate(original, () -> new Matrix4f().translate(0, widget.getBounds().height + 4, 0)); + WidgetWithBounds translatedOriginal = Widgets.withTranslate(original, () -> new Matrix3x2f().translate(0, widget.getBounds().height + 4)); contents = Widgets.concatWithBounds(() -> new Rectangle(0, 0, width, widget.getBounds().height + 4 + translatedOriginal.getBounds().height), translatedOriginal, background, widget); } else { contents = Widgets.concatWithBounds(() -> new Rectangle(0, 0, width, original.getBounds().getMaxY() + 2 + widget.getBounds().height), original, - Widgets.withTranslate(Widgets.concat(background, widget), () -> new Matrix4f().translate(0, original.getBounds().getMaxY() + 4, 0))); + Widgets.withTranslate(Widgets.concat(background, widget), () -> new Matrix3x2f().translate(0, original.getBounds().getMaxY() + 4))); } } } else { @@ -103,7 +103,7 @@ public class ConfigGroupWidget { return Widgets.concatWithBounds( () -> new Rectangle(0, 0, width, groupTitle.getBounds().getMaxY() + contents.getBounds().height), groupTitle, - Widgets.withTranslate(contents, () -> new Matrix4f().translate(0, groupTitle.getBounds().getMaxY(), 0)) + Widgets.withTranslate(contents, () -> new Matrix3x2f().translate(0, groupTitle.getBounds().getMaxY())) ); } @@ -145,23 +145,23 @@ public class ConfigGroupWidget { private record WidgetComposite( Widget widget, Supplier<Rectangle> bounds, - Matrix4f translation + Matrix3x2f translation ) { public static WidgetComposite of(WidgetWithBounds widget) { - Matrix4f translation = new Matrix4f(); + Matrix3x2f translation = new Matrix3x2f(); return new WidgetComposite(Widgets.withTranslate(widget, translation), () -> MatrixUtils.transform(translation, widget.getBounds()), translation); } public static WidgetComposite ofNonAccounting(Widget widget) { - return new WidgetComposite(widget, Rectangle::new, new Matrix4f()); + return new WidgetComposite(widget, Rectangle::new, new Matrix3x2f()); } } private static void recalculateHeight(List<WidgetComposite> widgets, IntConsumer setHeight) { int height = 0; for (WidgetComposite widget : widgets) { - widget.translation().set(new Matrix4f().translate(0, height, 0)); + widget.translation().set(new Matrix3x2f().translate(0, height)); height = Math.max(height, widget.bounds().get().getMaxY()); } setHeight.accept(height); 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 4f9a83e96..a55207541 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 @@ -89,7 +89,7 @@ public class ConfigOptionValueWidget { .color(0xFFE0E0E0) .hoveredColor(0xFFE0E0E0) .onRender((poses, l) -> { - if (MatrixUtils.transform(poses.pose().last().pose(), l.getBounds()).contains(PointHelper.ofMouse())) { + if (MatrixUtils.transform(poses.pose(), l.getBounds()).contains(PointHelper.ofMouse())) { l.setMessage(text[0].copy().withStyle(ChatFormatting.UNDERLINE)); } else { l.setMessage(text[0]); @@ -112,7 +112,7 @@ public class ConfigOptionValueWidget { return Widgets.concatWithBounds(() -> new Rectangle(-label.getBounds().width, 0, label.getBounds().width + 8, 14), label, Widgets.withTranslate(Widgets.createTexturedWidget(ResourceLocation.parse("roughlyenoughitems:textures/gui/config/selector.png"), - new Rectangle(1, 1, 4, 6), 0, 0, 1, 1, 1, 1), 0, 0.5, 0) + new Rectangle(1, 1, 4, 6), 0, 0, 1, 1, 1, 1), 0, 0.5) ); } @@ -121,7 +121,7 @@ public class ConfigOptionValueWidget { BiConsumer<GuiGraphics, Label> render = label.getOnRender(); label.onRender((poses, $) -> { render.accept(poses, $); - bounds.setBounds(MatrixUtils.transform(poses.pose().last().pose(), label.getBounds())); + bounds.setBounds(MatrixUtils.transform(poses.pose(), label.getBounds())); }); int noOfOptions = selection.getOptions().size(); if (noOfOptions == 2) { 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 015dc1c75..94c2bddf3 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 @@ -43,7 +43,7 @@ import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.network.chat.MutableComponent; import net.minecraft.util.FormattedCharSequence; import org.jetbrains.annotations.Nullable; -import org.joml.Matrix4f; +import org.joml.Matrix3x2f; import java.util.ArrayList; import java.util.List; @@ -62,7 +62,7 @@ public class ConfigOptionWidget { .leftAligned() .rainbow(Objects.equals(option.getId(), AllREIConfigOptions.RAINBOW.getId()))); WidgetWithBounds optionValue = ConfigOptionValueWidget.create(access, option, width - 10 - fieldNameLabel.getBounds().width); - widgets.add(Widgets.withTranslate(optionValue, () -> new Matrix4f().translate(width - optionValue.getBounds().width - optionValue.getBounds().x, 0, 0))); + widgets.add(Widgets.withTranslate(optionValue, () -> new Matrix3x2f().translate(width - optionValue.getBounds().width - optionValue.getBounds().x, 0))); widgets.add(new WidgetWithBounds() { final MutableComponent description = Util.make(() -> { MutableComponent description = option.getDescription().copy(); @@ -85,7 +85,7 @@ public class ConfigOptionWidget { @Nullable WidgetWithBounds preview = null; boolean previewVisible = false; - Matrix4f previewTranslation = new Matrix4f(); + Matrix3x2f previewTranslation = new Matrix3x2f(); final NumberAnimator<Float> previewHeight = ValueAnimator.ofFloat() .withConvention(() -> previewVisible ? preview.getBounds().getHeight() : 0f, ValueAnimator.typicalTransitionTime()); boolean nextLinePreview = false; @@ -128,7 +128,7 @@ public class ConfigOptionWidget { if (this.preview != null && this.previewHeight.value() > 0.1f) { Rectangle rectangle = new Rectangle(0, 24 + 12 * split.size() - (nextLinePreview ? 0 : 12), width, this.previewHeight.value()); graphics.enableScissor(rectangle.x, rectangle.y, rectangle.getMaxX(), rectangle.getMaxY()); - this.previewTranslation = new Matrix4f().translate(0, 12 + 12 * split.size(), 100); + this.previewTranslation = new Matrix3x2f().translate(0, 12 + 12 * split.size()); this.preview.render(graphics, mouseX, mouseY, delta); graphics.disableScissor(); } 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 9d811892f..5d31a6206 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 @@ -84,7 +84,7 @@ public class ConfigSearchWidget { return new Rectangle(-1, -1, width.getAsInt() + 2, 21); } }, - Widgets.withTranslate(label, 0, 0.5, 0), + Widgets.withTranslate(label, 0, 0.5), Widgets.createTexturedWidget(ResourceLocation.parse("roughlyenoughitems:textures/gui/config/search_options.png"), new Rectangle(3, 3, 16, 16), 0, 0, 1, 1, 1, 1) ); } @@ -97,8 +97,8 @@ public class ConfigSearchWidget { @Override public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { boolean hovering = containsMouse(mouseX, mouseY); - graphics.pose().pushPose(); - graphics.pose().translate(-0.5, -0.5, 0); + graphics.pose().pushMatrix(); + graphics.pose().translate(-0.5f, -0.5f); 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), @@ -106,7 +106,7 @@ public class ConfigSearchWidget { Widgets.createFilledRectangle(new Rectangle(18, -2, 1, 20), hovering ? 0x90FFFFFF : 0x45FFFFFF))) { widget.render(graphics, mouseX, mouseY, delta); } - graphics.pose().popPose(); + graphics.pose().popMatrix(); } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigCategories.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigCategories.java index 0204516e8..d94623230 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigCategories.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigCategories.java @@ -70,7 +70,7 @@ public interface AllREIConfigCategories { .add(CHEATS_CHEATS) .add(CHEATS_ADVANCED); OptionCategory PERFORMANCE = make("performance") - .add(PERFORMANCE_RENDERING) + /*.add(PERFORMANCE_RENDERING)*/ .add(PERFORMANCE_RELOAD); OptionCategory DEBUG = make("debug") .add(DEBUG_PERFORMANCE); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigGroups.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigGroups.java index bdb5a8168..adac70c7e 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigGroups.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigGroups.java @@ -110,9 +110,8 @@ public interface AllREIConfigGroups { .add(CHEATS_AMOUNT); OptionGroup CHEATS_ADVANCED = make("cheats.advanced") .add(GIVE_COMMAND); - OptionGroup PERFORMANCE_RENDERING = make("performance.rendering") - .add(BATCHED_RENDERING) - /*.add(CACHED_RENDERING)*/; + /*OptionGroup PERFORMANCE_RENDERING = make("performance.rendering") + .add(CACHED_RENDERING);*/ OptionGroup PERFORMANCE_RELOAD = make("performance.reload") .add(RELOAD_THREAD) .add(CACHED_DISPLAY_LOOKUP); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigOptions.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigOptions.java index 30a673e38..8648c0db2 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigOptions.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigOptions.java @@ -248,8 +248,6 @@ public interface AllREIConfigOptions { .enumOptions(); CompositeOption<String> GIVE_COMMAND = make("cheats.give_command", i -> i.advanced.commands.giveCommand, (i, v) -> i.advanced.commands.giveCommand = v) .string(); - CompositeOption<Boolean> BATCHED_RENDERING = make("performance.batched_rendering", i -> i.advanced.miscellaneous.newFastEntryRendering, (i, v) -> i.advanced.miscellaneous.newFastEntryRendering = v) - .enabledDisabled(); CompositeOption<Boolean> CACHED_RENDERING = make("performance.cached_rendering", i -> i.advanced.miscellaneous.cachingFastEntryRendering, (i, v) -> i.advanced.miscellaneous.cachingFastEntryRendering = v) .enabledDisabled(); CompositeOption<Boolean> RELOAD_THREAD = make("performance.reload_thread", i -> i.advanced.miscellaneous.registerRecipesInAnotherThread, (i, v) -> i.advanced.miscellaneous.registerRecipesInAnotherThread = v) diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/preview/InterfacePreviewer.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/preview/InterfacePreviewer.java index e314ba4c0..fc6420d25 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/preview/InterfacePreviewer.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/preview/InterfacePreviewer.java @@ -43,7 +43,7 @@ import me.shedaniel.rei.impl.client.gui.widget.basewidgets.PanelWidget; import net.minecraft.Util; import net.minecraft.world.item.Items; import org.jetbrains.annotations.Nullable; -import org.joml.Matrix4f; +import org.joml.Matrix3x2f; import java.util.ArrayList; import java.util.List; @@ -65,7 +65,7 @@ public class InterfacePreviewer { base.getBounds().setBounds(2, 2, width - 4, height.getAsInt() - 4); return base; }), - Widgets.withTranslate(widget, () -> new Matrix4f().translate(0, (height.getAsInt() - widget.getBounds().height) / 2, 0)) + Widgets.withTranslate(widget, () -> new Matrix3x2f().translate(0, (height.getAsInt() - widget.getBounds().height) / 2)) ); } 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 daadcc968..4c99a4d79 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 @@ -36,7 +36,6 @@ import me.shedaniel.rei.impl.client.gui.config.options.AllREIConfigOptions; import me.shedaniel.rei.impl.client.gui.config.options.ConfigUtils; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.RenderType; import net.minecraft.client.resources.language.I18n; import net.minecraft.util.FormattedCharSequence; import net.minecraft.world.item.ItemStack; @@ -71,35 +70,28 @@ 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); - graphics.pose().pushPose(); - graphics.pose().translate(0, height == null ? 4 : Math.max(0, (height.getAsInt() - (tY + tHeight)) / 2), 400); + graphics.pose().pushMatrix(); + graphics.pose().translate(0, height == null ? 4 : Math.max(0, (height.getAsInt() - (tY + tHeight)) / 2)); bounds.setSize(width, height == null ? tY + tHeight + 12 : height.getAsInt()); stack.getRenderer().render(stack, graphics, new Rectangle(width / 2 - 12, 0, 24, 24), mouseX, mouseY, delta); - graphics.pose().translate(0, 0, -400); int finalTY = tY; - graphics.drawSpecial(source -> { - VertexConsumer buffer = source.getBuffer(RenderType.gui()); - Matrix4f matrix4f = graphics.pose().last().pose(); - fillGradient(matrix4f, buffer, tX - 3, finalTY - 4, tX + tWidth + 3, finalTY - 3, 400, -267386864, -267386864); - fillGradient(matrix4f, buffer, tX - 3, finalTY + tHeight + 3, tX + tWidth + 3, finalTY + tHeight + 4, 400, -267386864, -267386864); - fillGradient(matrix4f, buffer, tX - 3, finalTY - 3, tX + tWidth + 3, finalTY + tHeight + 3, 400, -267386864, -267386864); - fillGradient(matrix4f, buffer, tX - 4, finalTY - 3, tX - 3, finalTY + tHeight + 3, 400, -267386864, -267386864); - fillGradient(matrix4f, buffer, tX + tWidth + 3, finalTY - 3, tX + tWidth + 4, finalTY + tHeight + 3, 400, -267386864, -267386864); - fillGradient(matrix4f, buffer, tX - 3, finalTY - 3 + 1, tX - 3 + 1, finalTY + tHeight + 3 - 1, 400, 1347420415, 1344798847); - fillGradient(matrix4f, buffer, tX + tWidth + 2, finalTY - 3 + 1, tX + tWidth + 3, finalTY + tHeight + 3 - 1, 400, 1347420415, 1344798847); - fillGradient(matrix4f, buffer, tX - 3, finalTY - 3, tX + tWidth + 3, finalTY - 3 + 1, 400, 1347420415, 1347420415); - fillGradient(matrix4f, buffer, tX - 3, finalTY + tHeight + 2, tX + tWidth + 3, finalTY + tHeight + 3, 400, 1344798847, 1344798847); - }); - - graphics.pose().translate(0, 0, 400); + graphics.fillGradient(tX - 3, finalTY - 4, tX + tWidth + 3, finalTY - 3, -267386864, -267386864); + graphics.fillGradient(tX - 3, finalTY + tHeight + 3, tX + tWidth + 3, finalTY + tHeight + 4, -267386864, -267386864); + graphics.fillGradient(tX - 3, finalTY - 3, tX + tWidth + 3, finalTY + tHeight + 3, -267386864, -267386864); + graphics.fillGradient(tX - 4, finalTY - 3, tX - 3, finalTY + tHeight + 3, -267386864, -267386864); + graphics.fillGradient(tX + tWidth + 3, finalTY - 3, tX + tWidth + 4, finalTY + tHeight + 3, -267386864, -267386864); + graphics.fillGradient(tX - 3, finalTY - 3 + 1, tX - 3 + 1, finalTY + tHeight + 3 - 1, 1347420415, 1344798847); + graphics.fillGradient(tX + tWidth + 2, finalTY - 3 + 1, tX + tWidth + 3, finalTY + tHeight + 3 - 1, 1347420415, 1344798847); + graphics.fillGradient(tX - 3, finalTY - 3, tX + tWidth + 3, finalTY - 3 + 1, 1347420415, 1347420415); + graphics.fillGradient(tX - 3, finalTY + tHeight + 2, tX + tWidth + 3, finalTY + tHeight + 3, 1344798847, 1344798847); for (int i = 0; i < components.size(); i++) { graphics.drawString(Minecraft.getInstance().font, components.get(i), tX + 2, tY + 2, -1, false); tY += 10 + (i == 0 ? 2 : 0); } - graphics.pose().popPose(); + graphics.pose().popMatrix(); }), bounds); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsEntryListWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsEntryListWidget.java index a38e17c3a..b198b0b25 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsEntryListWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsEntryListWidget.java @@ -150,7 +150,7 @@ public class CreditsEntryListWidget extends UpdatedListWidget<CreditsEntryListWi public void render(GuiGraphics graphics, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isSelected, float delta) { contains = mouseX >= x && mouseX <= x + entryWidth && mouseY >= y && mouseY <= y + entryHeight; if (contains) { - graphics.renderTooltip(Minecraft.getInstance().font, Component.literal("Click to open link."), mouseX, mouseY); + graphics.setTooltipForNextFrame(Minecraft.getInstance().font, Component.literal("Click to open link."), mouseX, mouseY); int yy = y; for (FormattedCharSequence textSp : textSplit) { FormattedCharSequence underlined = characterVisitor -> { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/dragging/CurrentDraggingStack.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/dragging/CurrentDraggingStack.java index 4d032dfb8..977d977b4 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/dragging/CurrentDraggingStack.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/dragging/CurrentDraggingStack.java @@ -83,8 +83,6 @@ public class CurrentDraggingStack extends Widget implements LateRenderable, Drag } if (entry.dragging) { - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 600); entry.point.update(delta); entry.dimension.update(delta); int width = entry.component.getWidth(); @@ -93,7 +91,6 @@ public class CurrentDraggingStack extends Widget implements LateRenderable, Drag entry.point.setTo(new FloatingPoint(mouseX - mouseStartOffset.x * width, mouseY - mouseStartOffset.y * height), reducedMotion ? 0 : 30); entry.dimension.setTo(new FloatingDimension(width, height), reducedMotion ? 0 : 700); entry.component.render(graphics, getCurrentBounds(), mouseX, mouseY, delta); - graphics.pose().popPose(); VoxelShape shape = entry.getBoundsProvider().bounds(); ShapeBounds shapeBounds = new ShapeBounds(shape); @@ -122,10 +119,7 @@ public class CurrentDraggingStack extends Widget implements LateRenderable, Drag iterator.remove(); } else { bounds.shape.forAllBoxes((x1, y1, z1, x2, y2, z2) -> { - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 500); graphics.fillGradient((int) x1, (int) y1, (int) x2, (int) y2, 0xfdff6b | (bounds.alpha.intValue() << 24), 0xfdff6b | (bounds.alpha.intValue() << 24)); - graphics.pose().popPose(); }); } } @@ -140,10 +134,7 @@ public class CurrentDraggingStack extends Widget implements LateRenderable, Drag if (value.width < 2 || value.height < 2 || (Math.abs(value.x - target.x) <= 1.3 && Math.abs(value.y - target.y) <= 1.3 && Math.abs(value.width - target.width) <= 1 && Math.abs(value.height - target.height) <= 1)) { iterator.remove(); } else { - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 600); renderBackEntry.component.render(graphics, value.getBounds(), mouseX, mouseY, delta); - graphics.pose().popPose(); } } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsEntryListWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsEntryListWidget.java index e7228efa6..3cf51dce1 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsEntryListWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsEntryListWidget.java @@ -35,7 +35,7 @@ import net.minecraft.client.gui.components.events.ContainerEventHandler; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.narration.NarratableEntry; import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.resources.sounds.SimpleSoundInstance; import net.minecraft.network.chat.Component; @@ -47,8 +47,8 @@ import net.minecraft.util.FormattedCharSequence; import net.minecraft.util.Mth; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; -import org.joml.Matrix4f; -import org.joml.Vector4f; +import org.joml.Matrix3x2f; +import org.joml.Vector3f; import java.net.URI; import java.net.URISyntaxException; @@ -181,12 +181,12 @@ public class ErrorsEntryListWidget extends DynamicSmoothScrollingEntryListWidget public static class ScaledEntry extends Entry implements ContainerEventHandler { public final Entry entry; public final float scale; - public final Matrix4f transform; + public final Matrix3x2f transform; public ScaledEntry(Entry entry, float scale) { this.entry = entry; this.scale = scale; - this.transform = new Matrix4f().scale(scale, scale, scale); + this.transform = new Matrix3x2f().scale(scale, scale); } public Entry getEntry() { @@ -194,22 +194,22 @@ public class ErrorsEntryListWidget extends DynamicSmoothScrollingEntryListWidget return entry; } - private Vector4f transformMouse(double mouseX, double mouseY) { - Vector4f mouse = new Vector4f((float) mouseX, (float) mouseY, 0, 1); + private Vector3f transformMouse(double mouseX, double mouseY) { + Vector3f mouse = new Vector3f((float) mouseX, (float) mouseY, 1); transform.transform(mouse); return mouse; } @Override public void render(GuiGraphics graphics, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isSelected, float delta) { - Vector4f mouse = transformMouse(mouseX, mouseY); - graphics.pose().pushPose(); - graphics.pose().last().pose().mul(transform); + Vector3f mouse = transformMouse(mouseX, mouseY); + graphics.pose().pushMatrix(); + graphics.pose().mul(transform); - Vector4f pos = new Vector4f(x, y, 0, 1); - pos.mul(new Matrix4f().scale(1 / scale, 1 / scale, 1 / scale)); + Vector3f pos = new Vector3f(x, y, 1); + pos.mul(new Matrix3x2f().scale(1 / scale, 1 / scale)); getEntry().render(graphics, index, Math.round(pos.y()), Math.round(pos.x()), Math.round(entryWidth / scale), Math.round(entryHeight / scale), (int) mouse.x(), (int) mouse.y(), isSelected, delta); - graphics.pose().popPose(); + graphics.pose().popMatrix(); } @Override @@ -229,31 +229,31 @@ public class ErrorsEntryListWidget extends DynamicSmoothScrollingEntryListWidget @Override public boolean isMouseOver(double mouseX, double mouseY) { - Vector4f mouse = transformMouse(mouseX, mouseY); + Vector3f mouse = transformMouse(mouseX, mouseY); return super.isMouseOver(mouse.x(), mouse.y()); } @Override public boolean mouseClicked(double d, double e, int i) { - Vector4f mouse = transformMouse(d, e); + Vector3f mouse = transformMouse(d, e); return super.mouseClicked(mouse.x(), mouse.y(), i); } @Override public boolean mouseReleased(double d, double e, int i) { - Vector4f mouse = transformMouse(d, e); + Vector3f mouse = transformMouse(d, e); return super.mouseReleased(mouse.x(), mouse.y(), i); } @Override public boolean mouseDragged(double d, double e, int i, double f, double g) { - Vector4f mouse = transformMouse(d, e); + Vector3f mouse = transformMouse(d, e); return super.mouseDragged(mouse.x(), mouse.y(), i, f, g); } @Override public boolean mouseScrolled(double d, double e, double amountX, double amountY) { - Vector4f mouse = transformMouse(d, e); + Vector3f mouse = transformMouse(d, e); return super.mouseScrolled(mouse.x(), mouse.y(), amountX, amountY); } @@ -316,7 +316,7 @@ public class ErrorsEntryListWidget extends DynamicSmoothScrollingEntryListWidget if (style.getHoverEvent() != null) { HoverEvent hoverEvent = style.getHoverEvent(); if (hoverEvent instanceof HoverEvent.ShowText(Component component)) { - graphics.renderTooltip(Minecraft.getInstance().font, Minecraft.getInstance().font.split(component, Math.max(this.width / 2, 200)), x, y); + graphics.setTooltipForNextFrame(Minecraft.getInstance().font, Minecraft.getInstance().font.split(component, Math.max(this.width / 2, 200)), x, y); } } } @@ -400,7 +400,7 @@ public class ErrorsEntryListWidget extends DynamicSmoothScrollingEntryListWidget width = (entryWidth - 6) / 2; this.height = (int) ((double) width * ((double) image.getHeight() / (double) image.getWidth())); graphics.fill(x, y, x + width, y + height + 2, 0xFFFFFFFF); - graphics.innerBlit(RenderType::guiTextured, id, x + 1, x + width - 1, y + 1, y + height + 1, 0, 0, 1, 0, 1); + graphics.innerBlit(RenderPipelines.GUI_TEXTURED, id, x + 1, x + width - 1, y + 1, y + height + 1, 0, 0, 1, 0, 1); } @Override @@ -425,7 +425,7 @@ public class ErrorsEntryListWidget extends DynamicSmoothScrollingEntryListWidget public void render(GuiGraphics graphics, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isSelected, float delta) { contains = mouseX >= x && mouseX <= x + entryWidth && mouseY >= y && mouseY <= y + entryHeight; if (contains) { - graphics.renderTooltip(Minecraft.getInstance().font, Component.literal("Click to open link."), mouseX, mouseY); + graphics.setTooltipForNextFrame(Minecraft.getInstance().font, Component.literal("Click to open link."), mouseX, mouseY); int yy = y; for (FormattedCharSequence textSp : textSplit) { FormattedCharSequence underlined = characterVisitor -> { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsScreen.java index 956d85b02..0084c732b 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsScreen.java @@ -28,8 +28,8 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractButton; import net.minecraft.client.gui.components.Button; -import net.minecraft.client.gui.screens.GenericMessageScreen; import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.network.chat.Component; import org.jetbrains.annotations.ApiStatus; @@ -88,12 +88,12 @@ public class ErrorsScreen extends Screen { private void exit() { boolean localServer = this.minecraft.isLocalServer(); - this.minecraft.level.disconnect(); + this.minecraft.level.disconnect(ClientLevel.DEFAULT_QUIT_MESSAGE); if (localServer) { - this.minecraft.disconnect(new GenericMessageScreen(Component.translatable("menu.savingLevel"))); + this.minecraft.disconnectWithSavingScreen(); } else { - this.minecraft.disconnect(); + this.minecraft.disconnectWithProgressScreen(); } System.exit(-1); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/hints/ImportantWarningsWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/hints/ImportantWarningsWidget.java index 66daf5c3f..8ce9a93a3 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/hints/ImportantWarningsWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/hints/ImportantWarningsWidget.java @@ -24,7 +24,6 @@ package me.shedaniel.rei.impl.client.gui.hints; import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.RoughlyEnoughItemsCoreClient; import me.shedaniel.rei.api.client.ClientHelper; import me.shedaniel.rei.api.client.gui.config.DisplayPanelLocation; import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds; @@ -90,28 +89,27 @@ public class ImportantWarningsWidget extends WidgetWithBounds { public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { if (!visible) return; - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 900); + graphics.pose().pushMatrix(); graphics.fill(bounds.x - 5, bounds.y - 5, bounds.getMaxX() + 5, bounds.getMaxY() + 5, 0x90111111); int y = bounds.y; for (Component text : texts) { - graphics.pose().pushPose(); - graphics.pose().translate(bounds.x, y, 0); - graphics.pose().scale(0.5f, 0.5f, 1); + graphics.pose().pushMatrix(); + graphics.pose().translate(bounds.x, y); + graphics.pose().scale(0.5f, 0.5f); graphics.drawWordWrap(Minecraft.getInstance().font, text, 0, 0, bounds.width * 2, -1); y += Minecraft.getInstance().font.wordWrapHeight(text, bounds.width * 2) / 2 + 5; - graphics.pose().popPose(); + graphics.pose().popMatrix(); } MutableComponent okayText = Component.translatable("text.rei.recipes.not.full.button.okay"); - graphics.pose().pushPose(); - graphics.pose().translate(bounds.x + bounds.width / 2 - Minecraft.getInstance().font.width(okayText) * 0.75 / 2, bounds.getMaxY() - 9, 0); - graphics.pose().scale(0.75f, 0.75f, 1); + graphics.pose().pushMatrix(); + graphics.pose().translate(bounds.x + bounds.width / 2 - Minecraft.getInstance().font.width(okayText) * 0.75f / 2, bounds.getMaxY() - 9); + graphics.pose().scale(0.75f, 0.75f); this.buttonBounds.setBounds(bounds.x, bounds.getMaxY() - 20, bounds.width, 20); graphics.drawString(Minecraft.getInstance().font, okayText, 0, 0, buttonBounds.contains(mouseX, mouseY) ? 0xfffff8de : 0xAAFFFFFF); - graphics.pose().popPose(); - graphics.pose().popPose(); + graphics.pose().popMatrix(); + graphics.pose().popMatrix(); } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/MenuHolder.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/MenuHolder.java index efd93ab7d..e02612794 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/MenuHolder.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/MenuHolder.java @@ -27,7 +27,6 @@ import com.google.common.collect.Lists; import me.shedaniel.math.Point; import me.shedaniel.math.impl.PointHelper; import me.shedaniel.rei.api.client.gui.widgets.Widget; -import me.shedaniel.rei.api.client.gui.widgets.Widgets; import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl; import net.minecraft.client.gui.GuiGraphics; import org.jetbrains.annotations.Nullable; @@ -78,7 +77,7 @@ public class MenuHolder implements MenuAccess { @Override public void open(UUID uuid, Menu menu, Predicate<Point> or, Predicate<Point> and) { - this.menu = new OverlayMenu(uuid, menu, Widgets.withTranslate(menu, 0, 0, 400), or, and); + this.menu = new OverlayMenu(uuid, menu, menu, or, and); } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/SubMenuEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/SubMenuEntry.java index 845e0e1fd..cc73b75fb 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/SubMenuEntry.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/SubMenuEntry.java @@ -24,7 +24,6 @@ package me.shedaniel.rei.impl.client.gui.modules.entries; import com.google.common.base.MoreObjects; -import com.mojang.blaze3d.systems.RenderSystem; import me.shedaniel.math.FloatingRectangle; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; @@ -35,7 +34,7 @@ import me.shedaniel.rei.impl.client.gui.modules.Menu; 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 java.util.Collections; @@ -119,20 +118,17 @@ public class SubMenuEntry extends AbstractMenuEntry { menu.bounds.setAs(new FloatingRectangle(facingRight ? createBounds.x : createBounds.getMaxX(), facingDownwards ? createBounds.y : createBounds.getMaxY(), 0.1, 0.1)); } - RenderSystem.disableScissor(); GuiGraphics.ScissorStack tmp = graphics.scissorStack; graphics.scissorStack = new GuiGraphics.ScissorStack(); menu.render(graphics, mouseX, mouseY, delta); graphics.scissorStack = tmp; - graphics.enableScissor(0, 0, 0, 0); - graphics.disableScissor(); } } else { this.childMenu = null; } - graphics.drawString(font, text, getX() + 2, getY() + 2, isSelected() ? 16777215 : 8947848, false); + graphics.drawString(font, text, getX() + 2, getY() + 2, isSelected() ? 0xFFFFFFFF : 0xFF888888, false); if (!entries.isEmpty()) { - graphics.blit(RenderType::guiTextured, InternalTextures.CHEST_GUI_TEXTURE, getX() + getWidth() - 15, getY() - 2, 0, 28, 18, 18, 256, 256); + graphics.blit(RenderPipelines.GUI_TEXTURED, InternalTextures.CHEST_GUI_TEXTURE, getX() + getWidth() - 15, getY() - 2, 0, 28, 18, 18, 256, 256); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/TextMenuEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/TextMenuEntry.java index 9c01b019b..1d90eabba 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/TextMenuEntry.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/TextMenuEntry.java @@ -64,7 +64,7 @@ public class TextMenuEntry extends AbstractMenuEntry { @Override public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { - graphics.drawString(font, lastText = text.get(), getX() + 2, getY() + 2, 8947848, false); + graphics.drawString(font, lastText = text.get(), getX() + 2, getY() + 2, 0xFF888888, false); this.lastTextWidth = Math.max(0, font.width(lastText)); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/ToggleMenuEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/ToggleMenuEntry.java index 318e4ecca..f866a49a3 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/ToggleMenuEntry.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/ToggleMenuEntry.java @@ -23,7 +23,6 @@ package me.shedaniel.rei.impl.client.gui.modules.entries; -import com.mojang.blaze3d.systems.RenderSystem; import it.unimi.dsi.fastutil.booleans.BooleanConsumer; import me.shedaniel.rei.api.client.REIRuntime; import me.shedaniel.rei.api.client.config.ConfigManager; @@ -112,18 +111,12 @@ public class ToggleMenuEntry extends AbstractMenuEntry { Tooltip tooltip = this.tooltip.get(); if (tooltip != null) { - RenderSystem.disableScissor(); - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, -400); ScreenOverlayImpl.getInstance().renderTooltip(graphics, tooltip); - graphics.pose().popPose(); - graphics.enableScissor(0, 0, 0, 0); - graphics.disableScissor(); } } - graphics.drawString(font, text, getX() + 2, getY() + 2, isSelected() && active.getAsBoolean() ? 16777215 : 8947848, false); + graphics.drawString(font, text, getX() + 2, getY() + 2, isSelected() && active.getAsBoolean() ? 0xFFFFFFFF : 0xFF888888, false); if (supplier.getAsBoolean()) { - graphics.drawString(font, "✔", getX() + getWidth() - 2 - font.width("✔"), getY() + 2, isSelected() && active.getAsBoolean() ? 16777215 : 8947848, false); + graphics.drawString(font, "✔", getX() + getWidth() - 2 - font.width("✔"), getY() + 2, isSelected() && active.getAsBoolean() ? 0xFFFFFFFF : 0xFF888888, false); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/DisplayRegistryInfoScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/DisplayRegistryInfoScreen.java index e05914288..f63ec2dd4 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/DisplayRegistryInfoScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/DisplayRegistryInfoScreen.java @@ -23,7 +23,6 @@ package me.shedaniel.rei.impl.client.gui.performance; -import com.mojang.blaze3d.systems.RenderSystem; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.registry.display.DisplayRegistry; import me.shedaniel.rei.api.common.category.CategoryIdentifier; @@ -145,7 +144,6 @@ public class DisplayRegistryInfoScreen extends ScreenWithMenu { @Override public void render(GuiGraphics graphics, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) { - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); graphics.drawString(Minecraft.getInstance().font, this.component.getVisualOrderText(), x + 4, y + 6, -1); FormattedCharSequence rightText = Component.translatable("text.rei.display_registry_analysis.displays", count).getVisualOrderText(); graphics.drawString(Minecraft.getInstance().font, rightText, x + entryWidth - 6 - 8 - Minecraft.getInstance().font.width(rightText), y + 6, -1); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/entry/PerformanceEntryImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/entry/PerformanceEntryImpl.java index 8d9ad9b4f..7c1a28fff 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/entry/PerformanceEntryImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/entry/PerformanceEntryImpl.java @@ -23,7 +23,6 @@ package me.shedaniel.rei.impl.client.gui.performance.entry; -import com.mojang.blaze3d.systems.RenderSystem; import me.shedaniel.rei.impl.client.gui.performance.PerformanceScreen; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @@ -48,7 +47,6 @@ public class PerformanceEntryImpl extends PerformanceScreen.PerformanceEntry { } public void render(GuiGraphics graphics, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) { - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); graphics.drawString(Minecraft.getInstance().font, this.name.getVisualOrderText(), x, y + 6, -1); FormattedCharSequence timeText = PerformanceScreen.formatTime(time, false); graphics.drawString(Minecraft.getInstance().font, timeText, x + entryWidth - 6 - 4 - Minecraft.getInstance().font.width(timeText), y + 6, -1); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/entry/SubCategoryListEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/entry/SubCategoryListEntry.java index 192a67b4a..749140f5b 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/entry/SubCategoryListEntry.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/entry/SubCategoryListEntry.java @@ -24,7 +24,6 @@ package me.shedaniel.rei.impl.client.gui.performance.entry; import com.google.common.collect.Lists; -import com.mojang.blaze3d.systems.RenderSystem; import me.shedaniel.clothconfig2.api.Expandable; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.impl.client.gui.performance.PerformanceScreen; @@ -34,7 +33,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.narration.NarratableEntry; -import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.client.resources.sounds.SimpleSoundInstance; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -78,12 +77,11 @@ public class SubCategoryListEntry extends PerformanceScreen.PerformanceEntry imp @Override public void render(GuiGraphics graphics, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) { - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); this.widget.rectangle.x = x + 3; this.widget.rectangle.y = y; this.widget.rectangle.width = entryWidth - 6; this.widget.rectangle.height = 24; - graphics.blit(RenderType::guiTextured, CONFIG_TEX, x + 3, y + 5, 24, (this.widget.rectangle.contains(mouseX, mouseY) ? 18 : 0) + (this.expanded ? 9 : 0), 9, 9, 256, 256); + graphics.blit(RenderPipelines.GUI_TEXTURED, CONFIG_TEX, x + 3, y + 5, 24, (this.widget.rectangle.contains(mouseX, mouseY) ? 18 : 0) + (this.expanded ? 9 : 0), 9, 9, 256, 256); graphics.drawString(Minecraft.getInstance().font, this.name.getVisualOrderText(), x + 3 + 15, y + 6, this.widget.rectangle.contains(mouseX, mouseY) ? -1638890 : -1); for (PerformanceScreen.PerformanceEntry performanceEntry : this.entries) { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java index 5005aa93e..3b98b90ce 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java @@ -64,7 +64,6 @@ 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.gui.screens.inventory.tooltip.ClientTooltipComponent; -import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.core.Holder; import net.minecraft.core.HolderSet; import net.minecraft.core.Registry; @@ -75,7 +74,6 @@ import net.minecraft.util.Mth; import net.minecraft.world.inventory.tooltip.TooltipComponent; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.Nullable; -import org.joml.Matrix4f; import java.util.*; import java.util.function.UnaryOperator; @@ -404,38 +402,34 @@ public abstract class AbstractDisplayViewingScreen extends Screen implements Dis int entrySize = EntryListWidget.entrySize(); int w = Math.max(1, MAX_WIDTH / entrySize); int i = 0; - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 50); for (EntryStack<?> entry : widget.getEntries()) { int x1 = x + (i % w) * entrySize; int y1 = y + 13 + (i / w) * entrySize; i++; if (i / w > 5) { Component text = Component.literal("+" + (widget.getEntries().size() - w * 6 + 1)).withStyle(ChatFormatting.GRAY); - graphics.drawSpecial(source -> { - font.drawInBatch(text, x1 + entrySize / 2 - font.width(text) / 2, y1 + entrySize / 2 - 1, -1, true, graphics.pose().last().pose(), source, Font.DisplayMode.NORMAL, 0, 15728880); - }); - graphics.flush(); + graphics.pose().pushMatrix(); + graphics.pose().translate(x1 + entrySize / 2 - font.width(text) / 2, y1 + entrySize / 2 - 1); + graphics.drawString(font, text, 0, 0, -1, true); + graphics.pose().popMatrix(); break; } else { entry.render(graphics, new Rectangle(x1, y1, entrySize, entrySize), -1000, -1000, 0); } } - graphics.pose().popPose(); } @Override - public void renderText(Font font, int x, int y, Matrix4f pose, MultiBufferSource.BufferSource buffers) { - font.drawInBatch(Component.translatable("text.rei.accepts").withStyle(ChatFormatting.GRAY), - x, y + 2, -1, true, pose, buffers, Font.DisplayMode.NORMAL, 0, 15728880); + public void renderText(GuiGraphics graphics, Font font, int x, int y) { + graphics.drawString(font, Component.translatable("text.rei.accepts").withStyle(ChatFormatting.GRAY), x, y + 2, -1); if (widget.tagMatch != null) { int entrySize = EntryListWidget.entrySize(); int w = Math.max(1, MAX_WIDTH / entrySize); - font.drawInBatch(Component.translatable("text.rei.tag_accept", widget.tagMatch.toString()) + graphics.drawString(font, Component.translatable("text.rei.tag_accept", widget.tagMatch.toString()) .withStyle(ChatFormatting.GRAY), x, y + 16 + Math.min(6, Mth.ceil(widget.getEntries().size() / (float) w)) * entrySize, - -1, true, pose, buffers, Font.DisplayMode.NORMAL, 0, 15728880); + -1); } } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java index 18767d4b6..c1ebd57bd 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.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 me.shedaniel.clothconfig2.ClothConfigInitializer; import me.shedaniel.clothconfig2.api.scroll.ScrollingContainer; import me.shedaniel.math.Point; @@ -157,7 +156,7 @@ public class CompositeDisplayViewingScreen extends AbstractDisplayViewingScreen this.widgets.addAll(setupDisplay); Optional<ButtonArea> supplier = CategoryRegistry.getInstance().get(category.getCategoryIdentifier()).getPlusButtonArea(); if (supplier.isPresent() && supplier.get().get(recipeBounds) != null) - this.widgets.add(Widgets.withTranslate(InternalWidgets.createAutoCraftingButtonWidget(recipeBounds, supplier.get().get(recipeBounds), Component.literal(supplier.get().getButtonText()), display::provideInternalDisplay, display::provideInternalDisplayIds, setupDisplay, category), 0, 0, 100)); + this.widgets.add(InternalWidgets.createAutoCraftingButtonWidget(recipeBounds, supplier.get().get(recipeBounds), Component.literal(supplier.get().getButtonText()), display::provideInternalDisplay, display::provideInternalDisplayIds, setupDisplay, category)); this.initTabs(this.bounds.width); this.widgets.addAll(this.tabs.widgets()); @@ -310,7 +309,6 @@ public class CompositeDisplayViewingScreen extends AbstractDisplayViewingScreen super.render(graphics, mouseX, mouseY, delta); getOverlay().render(graphics, mouseX, mouseY, delta); for (Widget widget : widgets) { - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); widget.render(graphics, mouseX, mouseY, delta); } } @@ -377,7 +375,7 @@ public class CompositeDisplayViewingScreen extends AbstractDisplayViewingScreen @Override public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { int yOffset = 0; - graphics.pose().pushPose(); + graphics.pose().pushMatrix(); graphics.enableScissor(scrolling.getBounds().x, scrolling.getBounds().y, scrolling.getBounds().getMaxX(), scrolling.getBounds().getMaxY()); for (Button button : buttonList) { button.getBounds().y = scrollListBounds.y + 1 + yOffset - scrolling.scrollAmountInt(); @@ -394,7 +392,7 @@ public class CompositeDisplayViewingScreen extends AbstractDisplayViewingScreen } scrolling.renderScrollBar(graphics, 0, scrollBarAlpha); graphics.disableScissor(); - graphics.pose().popPose(); + graphics.pose().popMatrix(); } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java index f5d1a8c0e..55f8e7816 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java @@ -26,7 +26,6 @@ package me.shedaniel.rei.impl.client.gui.screen; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import com.mojang.blaze3d.systems.RenderSystem; import it.unimi.dsi.fastutil.Pair; import me.shedaniel.clothconfig2.api.ModifierKeyCode; import me.shedaniel.clothconfig2.api.animator.ValueAnimator; @@ -60,18 +59,16 @@ import me.shedaniel.rei.impl.client.gui.widget.basewidgets.PanelWidget; import me.shedaniel.rei.impl.display.DisplaySpec; 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.components.events.GuiEventListener; import net.minecraft.client.gui.screens.ConfirmScreen; import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.client.resources.language.I18n; import net.minecraft.network.chat.Component; import net.minecraft.util.Mth; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; -import org.joml.Matrix4f; import java.util.*; import java.util.function.Function; @@ -169,20 +166,6 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen { .onClick(button -> nextCategory()).tooltipLine(Component.translatable("text.rei.next_category"))); this.categoryBack.setEnabled(categories.size() > 1); this.categoryNext.setEnabled(categories.size() > 1); - this.widgets.add(Widgets.withTranslate(Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> { - Rectangle recipeBackBounds = recipeBack.getBounds(); - Rectangle recipeNextBounds = recipeNext.getBounds(); - Rectangle categoryBackBounds = categoryBack.getBounds(); - Rectangle categoryNextBounds = categoryNext.getBounds(); - graphics.pose().pushPose(); - graphics.pose().translate(0.5, 0.5, 0); - graphics.blit(RenderType::guiTextured, InternalTextures.ARROW_LEFT_TEXTURE, recipeBackBounds.x + 2, recipeBackBounds.y + 2, 0, 0, 8, 8, 8, 8); - graphics.blit(RenderType::guiTextured, InternalTextures.ARROW_LEFT_TEXTURE, categoryBackBounds.x + 2, categoryBackBounds.y + 2, 0, 0, 8, 8, 8, 8); - graphics.pose().translate(-0.5, 0, 0); - graphics.blit(RenderType::guiTextured, InternalTextures.ARROW_RIGHT_TEXTURE, recipeNextBounds.x + 2, recipeNextBounds.y + 2, 0, 0, 8, 8, 8, 8); - graphics.blit(RenderType::guiTextured, InternalTextures.ARROW_RIGHT_TEXTURE, categoryNextBounds.x + 2, categoryNextBounds.y + 2, 0, 0, 8, 8, 8, 8); - graphics.pose().popPose(); - }), 0, 0, 1)); this.widgets.add(recipeBack = Widgets.createButton(new Rectangle(bounds.getCenterX() - guiWidth / 2 + 5, bounds.getY() + 19, 12, 12), Component.literal("")) .onClick(button -> { @@ -212,15 +195,30 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen { page = 0; DefaultDisplayViewingScreen.this.init(); }).tooltipLine(Component.translatable("text.rei.next_page"))); + + this.widgets.add(Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> { + Rectangle recipeBackBounds = recipeBack.getBounds(); + Rectangle recipeNextBounds = recipeNext.getBounds(); + Rectangle categoryBackBounds = categoryBack.getBounds(); + Rectangle categoryNextBounds = categoryNext.getBounds(); + graphics.pose().pushMatrix(); + graphics.pose().translate(0.5f, 0.5f); + graphics.blit(RenderPipelines.GUI_TEXTURED, InternalTextures.ARROW_LEFT_TEXTURE, recipeBackBounds.x + 2, recipeBackBounds.y + 2, 0, 0, 8, 8, 8, 8); + graphics.blit(RenderPipelines.GUI_TEXTURED, InternalTextures.ARROW_LEFT_TEXTURE, categoryBackBounds.x + 2, categoryBackBounds.y + 2, 0, 0, 8, 8, 8, 8); + graphics.pose().translate(-0.5f, 0); + graphics.blit(RenderPipelines.GUI_TEXTURED, InternalTextures.ARROW_RIGHT_TEXTURE, recipeNextBounds.x + 2, recipeNextBounds.y + 2, 0, 0, 8, 8, 8, 8); + graphics.blit(RenderPipelines.GUI_TEXTURED, InternalTextures.ARROW_RIGHT_TEXTURE, categoryNextBounds.x + 2, categoryNextBounds.y + 2, 0, 0, 8, 8, 8, 8); + graphics.pose().popMatrix(); + })); + this.recipeBack.setEnabled(getCurrentTotalPages() > 1); this.recipeNext.setEnabled(getCurrentTotalPages() > 1); initDisplays(); - widgets = CollectionUtils.map(widgets, widget -> Widgets.withTranslate(widget, 0, 0, 10)); - widgets.add(Widgets.withTranslate(new PanelWidget(bounds), 0, 0, 5)); - widgets.add(Widgets.withTranslate(Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> { + this.widgets.add(0, new PanelWidget(bounds)); + this.widgets.add(1, Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> { graphics.fill(bounds.getCenterX() - guiWidth / 2 + 17, bounds.y + 5, bounds.getCenterX() + guiWidth / 2 - 17, bounds.y + 17, darkStripesColor.value().getColor()); graphics.fill(bounds.getCenterX() - guiWidth / 2 + 17, bounds.y + 19, bounds.getCenterX() + guiWidth / 2 - 17, bounds.y + 31, darkStripesColor.value().getColor()); - }), 0, 0, 6)); + })); initWorkstations(widgets); children().addAll(widgets); @@ -256,7 +254,7 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen { this.recipeBounds.put(displayBounds, Pair.of(display, setupDisplay)); this.widgets.add(new DisplayCompositeWidget(display, setupDisplay, displayBounds)); if (plusButtonArea.isPresent()) { - this.widgets.add(Widgets.withTranslate(InternalWidgets.createAutoCraftingButtonWidget(displayBounds, plusButtonArea.get().get(displayBounds), Component.literal(plusButtonArea.get().getButtonText()), displaySupplier, display::provideInternalDisplayIds, setupDisplay, getCurrentCategory()), 0, 0, 100)); + this.widgets.add(InternalWidgets.createAutoCraftingButtonWidget(displayBounds, plusButtonArea.get().get(displayBounds), Component.literal(plusButtonArea.get().getButtonText()), displaySupplier, display::provideInternalDisplayIds, setupDisplay, getCurrentCategory())); } } } @@ -270,12 +268,13 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen { int innerWidth = Mth.ceil(workstations.size() / ((float) hh)); int xx = bounds.x - (8 + innerWidth * 16) + 6; int yy = bounds.y + 16; - widgets.add(workingStationsBaseWidget = Widgets.createCategoryBase(new Rectangle(xx - 5, yy - 5, 15 + innerWidth * 16, 10 + actualHeight * 16))); - widgets.add(Widgets.createSlotBase(new Rectangle(xx - 1, yy - 1, innerWidth * 16 + 2, actualHeight * 16 + 2))); + List<Widget> toAdd = new ArrayList<>(); + toAdd.add(workingStationsBaseWidget = Widgets.createCategoryBase(new Rectangle(xx - 5, yy - 5, 15 + innerWidth * 16, 10 + actualHeight * 16))); + toAdd.add(Widgets.createSlotBase(new Rectangle(xx - 1, yy - 1, innerWidth * 16 + 2, actualHeight * 16 + 2))); int index = 0; xx += (innerWidth - 1) * 16; for (EntryIngredient workingStation : workstations) { - widgets.add(new WorkstationSlotWidget(xx, yy, workingStation)); + toAdd.add(new WorkstationSlotWidget(xx, yy, workingStation)); index++; yy += 16; if (index >= hh) { @@ -284,6 +283,7 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen { xx -= 16; } } + widgets.addAll(0, toAdd); } } @@ -332,30 +332,22 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen { super.render(graphics, mouseX, mouseY, delta); getOverlay().render(graphics, mouseX, mouseY, delta); for (Widget widget : widgets()) { - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); widget.render(graphics, mouseX, mouseY, delta); } { ModifierKeyCode export = ConfigObject.getInstance().getExportImageKeybind(); if (export.matchesCurrentKey() || export.matchesCurrentMouse()) { for (Rectangle bounds : Iterables.concat(recipeBounds.keySet(), Iterables.transform(getTabs(), TabWidget::getBounds))) { - graphics.pose().pushPose(); - graphics.pose().translate(0.0D, 0.0D, 480.0D); if (bounds.contains(mouseX, mouseY)) { graphics.fillGradient(bounds.x, bounds.y, bounds.getMaxX(), bounds.getMaxY(), 1744822402, 1744822402); Component text = Component.translatable("text.rei.release_export", export.getLocalizedName().plainCopy().getString()); - graphics.pose().pushPose(); - graphics.pose().translate(0.0D, 0.0D, 10.0D); - graphics.drawSpecial(source -> { - Matrix4f matrix4f = graphics.pose().last().pose(); - font.drawInBatch(text.getVisualOrderText(), bounds.getCenterX() - font.width(text) / 2f, bounds.getCenterY() - 4.5f, 0xff000000, false, matrix4f, source, Font.DisplayMode.NORMAL, 0, 15728880); - }); - graphics.flush(); - graphics.pose().popPose(); + graphics.pose().pushMatrix(); + graphics.pose().translate(bounds.getCenterX() - font.width(text) / 2f, bounds.getCenterY() - 4.5f); + graphics.drawString(font, text, 0, 0, 0xff000000, false); + graphics.pose().popMatrix(); } else { graphics.fillGradient(bounds.x, bounds.y, bounds.getMaxX(), bounds.getMaxY(), 1744830463, 1744830463); } - graphics.pose().popPose(); } } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/ScreenWithMenu.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/ScreenWithMenu.java index bfd3379e9..68b2159ef 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/ScreenWithMenu.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/ScreenWithMenu.java @@ -41,10 +41,7 @@ public class ScreenWithMenu extends Screen { public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { super.render(graphics, mouseX, mouseY, delta); if (this.menu != null) { - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 400); this.menu.render(graphics, mouseX, mouseY, delta); - graphics.pose().popPose(); } } 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 97109e633..1dfc645ff 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 @@ -41,7 +41,7 @@ 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.gui.screens.inventory.AbstractContainerScreen; -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.FormattedCharSequence; @@ -144,7 +144,7 @@ public class UncertainDisplayViewingScreen extends Screen { widget.render(graphics, int_1, int_2, float_1); } if (isSet) { - graphics.pose().pushPose(); + graphics.pose().pushMatrix(); updateFramePosition(float_1); int x = (int) (width / 2 - 205 + (200 * frame)) + 10; int y = height / 2 - 112 / 2 - 10; @@ -152,7 +152,7 @@ public class UncertainDisplayViewingScreen extends Screen { graphics.fillGradient(x - 2, y - 4 + 126 - 2, x - 6 + 208- 10, y - 4 + 126, -1778384897, -1778384897); graphics.fillGradient(x - 4, y - 4, x - 4 + 2, y - 4 + 126, -1778384897, -1778384897); graphics.fillGradient(x - 4 + 208 - 2 - 10, y - 4, x - 4 + 208 - 10, y - 4 + 126, -1778384897, -1778384897); - graphics.pose().popPose(); + graphics.pose().popMatrix(); } graphics.disableScissor(); button.render(graphics, int_1, int_2, float_1); @@ -203,7 +203,7 @@ public class UncertainDisplayViewingScreen extends Screen { @Override public void render(GuiGraphics graphics, int i, int i1, float delta) { - graphics.blit(RenderType::guiTextured, type == DisplayScreenType.ORIGINAL ? DEFAULT : COMPOSITE, bounds.x + (type == DisplayScreenType.ORIGINAL ? 8 : 4), bounds.y + 4, bounds.width - 8, bounds.height - 8, 113, type == DisplayScreenType.ORIGINAL ? 16 : 27, 854 - 113 * 2, 480 - 27 * 2, 854, 480); + graphics.blit(RenderPipelines.GUI_TEXTURED, type == DisplayScreenType.ORIGINAL ? DEFAULT : COMPOSITE, bounds.x + (type == DisplayScreenType.ORIGINAL ? 8 : 4), bounds.y + 4, bounds.width - 8, bounds.height - 8, 113, type == DisplayScreenType.ORIGINAL ? 16 : 27, 854 - 113 * 2, 480 - 27 * 2, 854, 480); } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/WarningAndErrorScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/WarningAndErrorScreen.java index 50fc31e78..5c9544352 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/WarningAndErrorScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/WarningAndErrorScreen.java @@ -265,7 +265,7 @@ public class WarningAndErrorScreen extends Screen { public void render(GuiGraphics graphics, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isSelected, float delta) { contains = mouseX >= x && mouseX <= x + entryWidth && mouseY >= y && mouseY <= y + entryHeight; if (contains) { - graphics.renderTooltip(font, Component.literal("Click to open link."), mouseX, mouseY); + graphics.setTooltipForNextFrame(font, Component.literal("Click to open link."), mouseX, mouseY); graphics.drawString(Minecraft.getInstance().font, characterVisitor -> { return text.accept((charIndex, style, codePoint) -> characterVisitor.accept(charIndex, style.applyFormat(ChatFormatting.UNDERLINE), codePoint)); }, x + 5, y, 0xff1fc3ff); 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 54e083248..6323e4d1c 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 @@ -46,14 +46,12 @@ import me.shedaniel.rei.impl.common.entry.type.collapsed.CollapsibleEntryRegistr 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.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; -import org.joml.Matrix4f; import java.util.*; import java.util.function.Consumer; @@ -183,13 +181,9 @@ public class CollapsibleEntriesScreen extends Screen { Component debugText = Component.literal(String.format("%s fps", minecraft.fpsString.split(" ")[0])); int stringWidth = font.width(debugText); graphics.fillGradient(minecraft.screen.width - stringWidth - 2, 32, minecraft.screen.width, 32 + font.lineHeight + 2, -16777216, -16777216); - graphics.pose().pushPose(); - graphics.drawSpecial(source -> { - Matrix4f matrix = graphics.pose().last().pose(); - font.drawInBatch(debugText.getVisualOrderText(), minecraft.screen.width - stringWidth, 32 + 2, -1, false, matrix, source, Font.DisplayMode.NORMAL, 0, 15728880); - }); - graphics.flush(); - graphics.pose().popPose(); + graphics.pose().pushMatrix(); + graphics.drawString(font, debugText.getVisualOrderText(), minecraft.screen.width - stringWidth, 32 + 2, -1, false); + graphics.pose().popMatrix(); } } 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 3054af108..6e5dbc149 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 @@ -23,8 +23,6 @@ package me.shedaniel.rei.impl.client.gui.screen.collapsible; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.*; import me.shedaniel.clothconfig2.ClothConfigInitializer; import me.shedaniel.clothconfig2.api.animator.ProgressValueAnimator; import me.shedaniel.clothconfig2.api.animator.ValueAnimator; @@ -42,19 +40,17 @@ import me.shedaniel.rei.impl.client.config.collapsible.CollapsibleConfigManager; import me.shedaniel.rei.impl.client.gui.InternalTextures; 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.EntryRendererManager; 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; -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.FormattedCharSequence; import net.minecraft.util.Mth; import org.jetbrains.annotations.Nullable; -import org.joml.Matrix4f; import java.util.ArrayList; import java.util.Collection; @@ -122,10 +118,7 @@ public class CollapsibleEntryWidget extends WidgetWithBounds { @Override protected void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float delta) { super.renderWidget(graphics, mouseX, mouseY, delta); - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 1); - graphics.blit(RenderType::guiTextured, InternalTextures.CHEST_GUI_TEXTURE, getX() + 3, getY() + 3, 0, 0, 14, 14, 256, 256); - graphics.pose().popPose(); + graphics.blit(RenderPipelines.GUI_TEXTURED, InternalTextures.CHEST_GUI_TEXTURE, getX() + 3, getY() + 3, 0, 0, 14, 14, 256, 256); } }; } else { @@ -173,38 +166,37 @@ public class CollapsibleEntryWidget extends WidgetWithBounds { 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(graphics, lineBounds)) { - graphics.pose().pushPose(); - graphics.pose().translate(0, -idDrawer.progress() * 10, 0); + graphics.pose().pushMatrix(); + graphics.pose().translate(0, (float) (-idDrawer.progress() * 10)); 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); 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(); + graphics.pose().popMatrix(); } } 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 = graphics.drawString(font, Component.translatable("text.rei.collapsible.entries.source").append(" "), bounds.x + 4, y, 0xFFAAAAAA); + graphics.drawString(font, Component.translatable("text.rei.collapsible.entries.source").append(" "), bounds.x + 4, y, 0xFFAAAAAA); + int xo = bounds.x + 4 + font.width(Component.translatable("text.rei.collapsible.entries.source").append(" ")); try (CloseableScissors scissors = scissor(graphics, lineBounds)) { - graphics.pose().pushPose(); + graphics.pose().pushMatrix(); if (this.custom) { renderTextScrolling(graphics, TextTransformations.applyRainbow(Component.translatable("text.rei.collapsible.entries.source.custom").getVisualOrderText(), xo - 1, y), xo - 1, y, bounds.getWidth() - 8, 0xFFAAAAAA); } else { - graphics.pose().translate(0, -modIdDrawer.progress() * 10, 0); + graphics.pose().translate(0, (float) (-modIdDrawer.progress() * 10)); 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); } - graphics.pose().popPose(); + graphics.pose().popMatrix(); } } renderStacks(graphics, mouseX, mouseY, delta, bounds, y); bounds.y = this.y; - 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(graphics, mouseX, mouseY, delta); @@ -225,17 +217,14 @@ public class CollapsibleEntryWidget extends WidgetWithBounds { ScreenOverlayImpl.getInstance().clearTooltips(); } } - graphics.pose().popPose(); } 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; - graphics.pose().translate(0, 0, 100); - BatchedEntryRendererManager<EntryWidget> manager = new BatchedEntryRendererManager<>(); + EntryRendererManager<EntryWidget> manager = new EntryRendererManager<>(); for (Slot stack : this.stacks) { if (y + 16 >= 30 && y + 16 >= bounds.y + 37) { stack.getBounds().setBounds(x + 16 * xIndex - 1, y - 1, 18, 18); @@ -253,20 +242,11 @@ public class CollapsibleEntryWidget extends WidgetWithBounds { 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); } - graphics.pose().translate(0, 0, 300); if (this.stacks.size() > rowSize * 3) { - graphics.drawSpecial(source -> { - VertexConsumer buffer = source.getBuffer(RenderType.gui()); - Matrix4f matrix = graphics.pose().last().pose(); - buffer.addVertex(matrix, this.x + 1, this.y + this.height - 1, 0.0F).setColor(0xFF000000); - buffer.addVertex(matrix, this.x + this.width - 1, this.y + this.height - 1, 0.0F).setColor(0xFF000000); - buffer.addVertex(matrix, this.x + this.width - 1, this.y + this.height - 40, 0.0F).setColor(0x00000000); - buffer.addVertex(matrix, this.x + 1, this.y + this.height - 40, 0.0F).setColor(0x00000000); - }); + graphics.fillGradient(this.x + 1, this.y + this.height - 40, this.x + this.width - 1, this.y + this.height - 1, 0x00000000, 0xFF000000); } } - graphics.pose().popPose(); } private void renderTextScrolling(GuiGraphics graphics, Component text, int x, int y, int width, int color) { @@ -277,12 +257,12 @@ public class CollapsibleEntryWidget extends WidgetWithBounds { try (CloseableScissors scissors = scissor(graphics, new Rectangle(x, y, width, y + 9))) { int textWidth = this.font.width(text); if (textWidth > width) { - graphics.pose().pushPose(); + graphics.pose().pushMatrix(); float textX = (System.currentTimeMillis() % ((textWidth + 10) * textWidth / 3)) / (float) textWidth * 3; - graphics.pose().translate(-textX, 0, 0); + graphics.pose().translate(-textX, 0); graphics.drawString(font, text, x + width - textWidth - 10, y, color); graphics.drawString(font, text, x + width, y, color); - graphics.pose().popPose(); + graphics.pose().popMatrix(); } else { 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 127fe6bf5..1c1e58606 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 @@ -25,7 +25,6 @@ package me.shedaniel.rei.impl.client.gui.screen.collapsible.selection; import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import com.mojang.blaze3d.vertex.VertexConsumer; import me.shedaniel.clothconfig2.ClothConfigInitializer; import me.shedaniel.clothconfig2.api.scroll.ScrollingContainer; import me.shedaniel.math.Point; @@ -40,7 +39,6 @@ import me.shedaniel.rei.api.client.search.SearchProvider; import me.shedaniel.rei.api.common.entry.EntrySerializer; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl; -import me.shedaniel.rei.impl.client.gui.widget.BatchedEntryRendererManager; import me.shedaniel.rei.impl.client.gui.widget.EntryWidget; import me.shedaniel.rei.impl.client.gui.widget.UpdatedListWidget; import me.shedaniel.rei.impl.client.gui.widget.search.OverlaySearchField; @@ -50,13 +48,11 @@ 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; -import net.minecraft.client.renderer.RenderType; import net.minecraft.network.chat.Component; import net.minecraft.util.Mth; import net.minecraft.world.item.Item; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; -import org.joml.Matrix4f; import java.util.ArrayList; import java.util.Collections; @@ -219,7 +215,6 @@ public class CustomCollapsibleEntrySelectionScreen extends Screen { int skip = Math.max(0, Mth.floor(scrolling.scrollAmount() / (float) entrySize())); int nextIndex = skip * innerBounds.width / entrySize(); int i = nextIndex; - BatchedEntryRendererManager<InnerStackEntry> manager = new BatchedEntryRendererManager<>(); for (; i < entryStacks.size(); i++) { EntryStack<?> stack = entryStacks.get(i); InnerStackEntry entry = entries.get(nextIndex); @@ -227,30 +222,19 @@ public class CustomCollapsibleEntrySelectionScreen extends Screen { if (entry.getBounds().y > bounds.getMaxY()) break; entry.entry(stack); - manager.add(entry); + entry.render(graphics, mouseX, mouseY, delta); nextIndex++; } - manager.render(graphics, mouseX, mouseY, delta); updatePosition(delta); scrolling.renderScrollBar(graphics, 0, 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.render(graphics, mouseX, mouseY, delta); - graphics.pose().popPose(); graphics.disableScissor(); - graphics.drawSpecial(source -> { - VertexConsumer buffer = source.getBuffer(RenderType.gui()); - Matrix4f matrix = graphics.pose().last().pose(); - buffer.addVertex(matrix, 0, bounds.y + 4, 0.0F).setColor(0, 0, 0, 0); - buffer.addVertex(matrix, width, bounds.y + 4, 0.0F).setColor(0, 0, 0, 0); - buffer.addVertex(matrix, width, bounds.y, 0.0F).setColor(0, 0, 0, 255); - buffer.addVertex(matrix, 0, bounds.y, 0.0F).setColor(0, 0, 0, 255); - }); + graphics.fillGradient(0, bounds.y, width, bounds.y + 4, 0xFF000000, 0x00000000); this.backButton.render(graphics, mouseX, mouseY, delta); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/generic/OptionEntriesScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/generic/OptionEntriesScreen.java index c849fe801..3c1c45c92 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/generic/OptionEntriesScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/generic/OptionEntriesScreen.java @@ -23,7 +23,6 @@ package me.shedaniel.rei.impl.client.gui.screen.generic; -import com.mojang.blaze3d.systems.RenderSystem; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.impl.client.gui.widget.UpdatedListWidget; import net.minecraft.client.Minecraft; @@ -35,7 +34,7 @@ import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.narration.NarratableEntry; import net.minecraft.client.gui.navigation.FocusNavigationEvent; import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.client.resources.sounds.SimpleSoundInstance; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.FormattedText; @@ -293,12 +292,11 @@ public abstract class OptionEntriesScreen extends Screen { @Override public void render(GuiGraphics graphics, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) { - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); this.widget.rectangle.x = x + 3; this.widget.rectangle.y = y; this.widget.rectangle.width = entryWidth - 6; this.widget.rectangle.height = 24; - graphics.blit(RenderType::guiTextured, CONFIG_TEX, x + 3, y + 5, 24, (this.widget.rectangle.contains(mouseX, mouseY) ? 18 : 0) + (this.expanded ? 9 : 0), 9, 9, 256, 256); + graphics.blit(RenderPipelines.GUI_TEXTURED, CONFIG_TEX, x + 3, y + 5, 24, (this.widget.rectangle.contains(mouseX, mouseY) ? 18 : 0) + (this.expanded ? 9 : 0), 9, 9, 256, 256); graphics.drawString(Minecraft.getInstance().font, this.name.get().getVisualOrderText(), x + 3 + 15, y + 6, this.widget.rectangle.contains(mouseX, mouseY) ? -1638890 : -1); for (ListEntry performanceEntry : this.rules) { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/toast/CopyRecipeIdentifierToast.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/toast/CopyRecipeIdentifierToast.java index c25332908..900e5c407 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/toast/CopyRecipeIdentifierToast.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/toast/CopyRecipeIdentifierToast.java @@ -23,13 +23,12 @@ package me.shedaniel.rei.impl.client.gui.toast; -import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.toasts.Toast; import net.minecraft.client.gui.components.toasts.ToastManager; -import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; @@ -71,8 +70,7 @@ public class CopyRecipeIdentifierToast implements Toast { @Override public void render(GuiGraphics graphics, Font font, long var2) { - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - graphics.blit(RenderType::guiTextured, TEXTURE, 0, 0, 0, 0, 160, 32, 256, 256); + graphics.blit(RenderPipelines.GUI_TEXTURED, TEXTURE, 0, 0, 0, 0, 160, 32, 256, 256); if (this.subtitle == null) { graphics.drawString(font, this.title, 18, 12, 11141120, false); } else { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/toast/ExportRecipeIdentifierToast.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/toast/ExportRecipeIdentifierToast.java index 16cff4bb3..3172027bc 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/toast/ExportRecipeIdentifierToast.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/toast/ExportRecipeIdentifierToast.java @@ -23,13 +23,12 @@ package me.shedaniel.rei.impl.client.gui.toast; -import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.toasts.Toast; import net.minecraft.client.gui.components.toasts.ToastManager; -import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; @@ -71,8 +70,7 @@ public class ExportRecipeIdentifierToast implements Toast { @Override public void render(GuiGraphics graphics, Font font, long var2) { - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - graphics.blit(RenderType::guiTextured, TEXTURE, 0, 0, 0, 0, 160, 32, 256, 256); + graphics.blit(RenderPipelines.GUI_TEXTURED, TEXTURE, 0, 0, 0, 0, 160, 32, 256, 256); if (this.subtitle == null) { graphics.drawString(font, this.title, 18, 12, 11141120, false); } else { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/BatchedEntryRendererManager.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/BatchedEntryRendererManager.java deleted file mode 100644 index f13ea1311..000000000 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/BatchedEntryRendererManager.java +++ /dev/null @@ -1,285 +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.impl.client.gui.widget; - -import com.google.common.collect.AbstractIterator; -import com.google.common.collect.Iterables; -import com.google.common.collect.Iterators; -import com.mojang.blaze3d.vertex.PoseStack; -import it.unimi.dsi.fastutil.ints.Int2ObjectMap; -import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -import me.shedaniel.rei.api.client.config.ConfigObject; -import me.shedaniel.rei.api.client.entry.renderer.BatchedEntryRenderer; -import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer; -import me.shedaniel.rei.api.common.entry.EntryStack; -import me.shedaniel.rei.api.common.util.CollectionUtils; -import me.shedaniel.rei.impl.client.util.CrashReportUtils; -import net.minecraft.CrashReport; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.renderer.MultiBufferSource; -import org.apache.commons.lang3.mutable.MutableInt; -import org.apache.commons.lang3.mutable.MutableLong; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -public class BatchedEntryRendererManager<T extends EntryWidget> implements Iterable<T> { - private final boolean fastEntryRendering = ConfigObject.getInstance().doesFastEntryRendering(); - private final Int2ObjectMap<List<Object>> grouping = new Int2ObjectOpenHashMap<>(); - private final List<T> toRender = new ArrayList<>(); - - public BatchedEntryRendererManager() { - } - - public BatchedEntryRendererManager(Collection<? extends T> widgets) { - addAll(widgets); - } - - public boolean isFastEntryRendering() { - return fastEntryRendering; - } - - public void addAll(Collection<? extends T> widgets) { - if (fastEntryRendering) { - for (T widget : widgets) { - add(widget); - } - } else { - addAllSlow(widgets); - } - } - - public void add(T widget) { - if (fastEntryRendering) { - EntryStack<?> currentEntry = widget.getCurrentEntry(); - try { - EntryRenderer<?> renderer = currentEntry.getRenderer(); - if (renderer instanceof BatchedEntryRenderer) { - BatchedEntryRenderer<Object, Object> batchedRenderer = (BatchedEntryRenderer<Object, Object>) renderer; - EntryStack<Object> cast = currentEntry.cast(); - if (batchedRenderer.isBatched(cast)) { - Object extraData = batchedRenderer.getExtraData(cast); - int hash = batchedRenderer.getBatchIdentifier(cast, widget.getBounds(), extraData) - ^ widget.getCurrentEntry().getType().hashCode(); - List<Object> entries = grouping.get(hash); - if (entries == null) { - grouping.put(hash, entries = new ArrayList<>()); - } - entries.add(widget); - entries.add(extraData); - return; - } - } - } catch (Throwable throwable) { - CrashReport report = CrashReportUtils.essential(throwable, "Adding entry"); - CrashReportUtils.renderer(report, currentEntry); - CrashReportUtils.catchReport(report); - return; - } - } - - addSlow(widget); - } - - public void addAllSlow(Collection<? extends T> widgets) { - toRender.addAll(widgets); - } - - public void addSlow(T widget) { - toRender.add(widget); - } - - public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { - render(false, null, null, graphics, mouseX, mouseY, delta); - } - - public void render(boolean debugTime, MutableInt size, MutableLong time, GuiGraphics graphics, int mouseX, int mouseY, float delta) { - if (fastEntryRendering) { - for (List<Object> entries : grouping.values()) { - Object[] extraData = new Object[entries.size() / 2]; - for (int i = 0; i < extraData.length; i++) { - extraData[i] = entries.get(i * 2 + 1); - } - renderBatched(debugTime, size, time, graphics, mouseX, mouseY, delta, () -> new AbstractIterator<T>() { - public int i = 0; - - @Override - protected T computeNext() { - if (i >= entries.size()) { - return endOfData(); - } - T widget = (T) entries.get(i); - i += 2; - return widget; - } - }, extraData); - } - } - if (!toRender.isEmpty()) { - renderSlow(debugTime, size, time, graphics, mouseX, mouseY, delta, toRender); - } - } - - public static <T extends EntryWidget> void renderEntries(boolean debugTime, MutableInt size, MutableLong time, boolean fastEntryRendering, GuiGraphics graphics, int mouseX, int mouseY, float delta, Collection<T> entries) { - if (fastEntryRendering) { - T firstWidget = Iterables.getFirst(entries, null); - if (firstWidget == null) return; - EntryRenderer<?> renderer = firstWidget.getCurrentEntry().getRenderer(); - if (renderer instanceof BatchedEntryRenderer) { - BatchedEntryRenderer<?, Object> firstRenderer = (BatchedEntryRenderer<?, Object>) renderer; - Object[] extraData = new Object[entries.size()]; - int i = 0; - for (T entry : entries) { - EntryStack<?> currentEntry = entry.getCurrentEntry(); - extraData[i++] = ((BatchedEntryRenderer<Object, Object>) currentEntry.getRenderer()).getExtraData(currentEntry.cast()); - } - renderBatched(debugTime, size, time, graphics, mouseX, mouseY, delta, entries, extraData); - return; - } - } - renderSlow(debugTime, size, time, graphics, mouseX, mouseY, delta, entries); - } - - private static <T extends EntryWidget> void renderBatched(boolean debugTime, MutableInt size, MutableLong time, GuiGraphics graphics, int mouseX, int mouseY, float delta, Iterable<T> entries, Object[] extraData) { - T firstWidget = Iterables.getFirst(entries, null); - if (firstWidget == null) return; - @SuppressWarnings("rawtypes") - EntryStack first = firstWidget.getCurrentEntry(); - EntryRenderer<?> renderer = first.getRenderer(); - BatchedEntryRenderer<?, Object> firstRenderer = (BatchedEntryRenderer<?, Object>) renderer; - PoseStack newStack = firstRenderer.batchModifyMatrices(graphics.pose()); - graphics.pose().pushPose(); - graphics.pose().last().pose().set(newStack.last().pose()); - graphics.pose().last().normal().set(newStack.last().normal()); - long l = debugTime ? System.nanoTime() : 0; - MultiBufferSource.BufferSource immediate = graphics.bufferSource; - int i = 0; - for (T entry : entries) { - try { - entry.drawBackground(graphics, mouseX, mouseY, delta); - } catch (Throwable throwable) { - CrashReport report = CrashReportUtils.essential(throwable, "Rendering entry background"); - CrashReportUtils.renderer(report, entry); - CrashReportUtils.catchReport(report); - return; - } - } - firstRenderer.startBatch(first, extraData[0], graphics, delta); - for (T entry : entries) { - try { - @SuppressWarnings("rawtypes") - EntryStack currentEntry = entry.getCurrentEntry(); - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, entry.getBounds().contains(mouseX, mouseY) ? 150 : 100); - firstRenderer.renderBase(currentEntry, extraData[i++], graphics, immediate, entry.getInnerBounds(), mouseX, mouseY, delta); - graphics.pose().popPose(); - if (debugTime && !currentEntry.isEmpty()) size.increment(); - } catch (Throwable throwable) { - CrashReport report = CrashReportUtils.essential(throwable, "Rendering entry base"); - CrashReportUtils.renderer(report, entry); - CrashReportUtils.catchReport(report); - return; - } - } - immediate.endBatch(); - firstRenderer.afterBase(first, extraData[0], graphics, delta); - i = 0; - for (T entry : entries) { - try { - @SuppressWarnings("rawtypes") - EntryStack currentEntry = entry.getCurrentEntry(); - firstRenderer.renderOverlay(currentEntry, extraData[i++], graphics, immediate, entry.getInnerBounds(), mouseX, mouseY, delta); - } catch (Throwable throwable) { - CrashReport report = CrashReportUtils.essential(throwable, "Rendering entry base"); - CrashReportUtils.renderer(report, entry); - CrashReportUtils.catchReport(report); - return; - } - } - immediate.endBatch(); - for (T entry : entries) { - try { - if (entry.containsMouse(mouseX, mouseY)) { - entry.queueTooltip(graphics, mouseX, mouseY, delta); - - if (entry.hasHighlight()) { - entry.drawHighlighted(graphics, mouseX, mouseY, delta); - } - } - entry.drawExtra(graphics, mouseX, mouseY, delta); - } catch (Throwable throwable) { - CrashReport report = CrashReportUtils.essential(throwable, "Rendering entry extra"); - CrashReportUtils.renderer(report, entry); - CrashReportUtils.catchReport(report); - return; - } - } - if (debugTime) time.add(System.nanoTime() - l); - firstRenderer.endBatch(first, extraData[0], graphics, delta); - graphics.pose().popPose(); - } - - public static <T extends EntryWidget> void renderSlow(boolean debugTime, MutableInt size, MutableLong time, GuiGraphics graphics, int mouseX, int mouseY, float delta, Iterable<T> entries) { - for (T entry : entries) { - if (entry.getCurrentEntry().isEmpty()) - continue; - try { - if (debugTime) { - size.increment(); - long l = System.nanoTime(); - entry.render(graphics, mouseX, mouseY, delta); - time.add(System.nanoTime() - l); - } else entry.render(graphics, mouseX, mouseY, delta); - } catch (Throwable throwable) { - CrashReport report = CrashReportUtils.essential(throwable, "Rendering entry"); - CrashReportUtils.renderer(report, entry); - CrashReportUtils.catchReport(report); - return; - } - } - } - - @NotNull - @Override - public Iterator<T> iterator() { - return Iterators.concat(toRender.iterator(), Iterators.concat( - CollectionUtils.<List<Object>, Iterator<T>>map(grouping.values(), entries -> new AbstractIterator<>() { - public int i = 0; - - @Override - protected T computeNext() { - if (i >= entries.size()) { - return endOfData(); - } - T widget = (T) entries.get(i); - i += 2; - return widget; - } - }).iterator() - )); - } -} diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/ConfigButtonWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/ConfigButtonWidget.java index 3e37d497d..1d7bcb475 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/ConfigButtonWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/ConfigButtonWidget.java @@ -46,7 +46,7 @@ import me.shedaniel.rei.impl.client.gui.modules.MenuAccess; import me.shedaniel.rei.impl.client.gui.modules.entries.*; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.network.chat.Component; import java.util.Collection; @@ -87,10 +87,7 @@ public class ConfigButtonWidget { .focusable(false) .containsMousePredicate((button, point) -> button.getBounds().contains(point) && overlay.isNotInExclusionZones(point.x, point.y)); Widget overlayWidget = Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> { - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 1); - graphics.blit(RenderType::guiTextured, InternalTextures.CHEST_GUI_TEXTURE, bounds.x + 3, bounds.y + 3, 0, 0, 14, 14, 256, 256); - graphics.pose().popPose(); + graphics.blit(RenderPipelines.GUI_TEXTURED, InternalTextures.CHEST_GUI_TEXTURE, bounds.x + 3, bounds.y + 3, 0, 0, 14, 14, 256, 256); }); return Widgets.concat(configButton, overlayWidget); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CraftableFilterButtonWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CraftableFilterButtonWidget.java index d2adbccc4..a020a5116 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CraftableFilterButtonWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CraftableFilterButtonWidget.java @@ -87,10 +87,10 @@ public class CraftableFilterButtonWidget { .containsMousePredicate((button, point) -> button.getBounds().contains(point) && overlay.isNotInExclusionZones(point.x, point.y)) .tooltipLineSupplier(button -> Component.translatable(ConfigManager.getInstance().isCraftableOnlyEnabled() ? "text.rei.showing_craftable" : "text.rei.showing_all")); Widget overlayWidget = Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> { - graphics.pose().pushPose(); - graphics.pose().translate(bounds.x + 2, bounds.y + 2, 10); + graphics.pose().pushMatrix(); + graphics.pose().translate(bounds.x + 2, bounds.y + 2); graphics.renderItem(icon, 0, 0); - graphics.pose().popPose(); + graphics.pose().popMatrix(); }); return Widgets.concat(filterButton, overlayWidget); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DefaultDisplayChoosePageWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DefaultDisplayChoosePageWidget.java index 6e3e918f6..b7fdb3031 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DefaultDisplayChoosePageWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DefaultDisplayChoosePageWidget.java @@ -163,12 +163,9 @@ public class DefaultDisplayChoosePageWidget extends DraggableWidget { @Override public void render(GuiGraphics graphics, int i, int i1, float v) { - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 800); for (Widget widget : widgets) { widget.render(graphics, i, i1, v); } - graphics.pose().popPose(); } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DelegateWidgetWithTranslate.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DelegateWidgetWithTranslate.java index 87ad675bc..da929b06b 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DelegateWidgetWithTranslate.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DelegateWidgetWithTranslate.java @@ -23,76 +23,75 @@ package me.shedaniel.rei.impl.client.gui.widget; -import com.mojang.math.Transformation; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.widgets.DelegateWidget; import me.shedaniel.rei.api.client.gui.widgets.Widget; import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds; import me.shedaniel.rei.api.client.util.MatrixUtils; import net.minecraft.client.gui.GuiGraphics; -import org.joml.Matrix4f; -import org.joml.Vector4f; +import org.joml.Matrix3x2f; +import org.joml.Vector3f; import java.util.function.Supplier; public class DelegateWidgetWithTranslate extends DelegateWidget { - private final Supplier<Matrix4f> translate; + private final Supplier<Matrix3x2f> translate; - public DelegateWidgetWithTranslate(WidgetWithBounds widget, Supplier<Matrix4f> translate) { + public DelegateWidgetWithTranslate(WidgetWithBounds widget, Supplier<Matrix3x2f> translate) { super(widget); this.translate = translate; } - protected Matrix4f translate() { + protected Matrix3x2f translate() { return translate.get(); } - protected final Matrix4f inverseTranslate() { + protected final Matrix3x2f inverseTranslate() { return MatrixUtils.inverse(translate()); } @Override public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { - graphics.pose().pushPose(); - graphics.pose().last().pose().mul(translate()); - Vector4f mouse = transformMouse(mouseX, mouseY); + graphics.pose().pushMatrix(); + graphics.pose().mul(translate()); + Vector3f mouse = transformMouse(mouseX, mouseY); super.render(graphics, (int) mouse.x(), (int) mouse.y(), delta); - graphics.pose().popPose(); + graphics.pose().popMatrix(); } - private Vector4f transformMouse(double mouseX, double mouseY) { - Vector4f mouse = new Vector4f((float) mouseX, (float) mouseY, 0, 1); + private Vector3f transformMouse(double mouseX, double mouseY) { + Vector3f mouse = new Vector3f((float) mouseX, (float) mouseY, 1); inverseTranslate().transform(mouse); return mouse; } @Override public boolean containsMouse(double mouseX, double mouseY) { - Vector4f mouse = transformMouse(mouseX, mouseY); + Vector3f mouse = transformMouse(mouseX, mouseY); return super.containsMouse(mouse.x(), mouse.y()); } @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { - Vector4f mouse = transformMouse(mouseX, mouseY); + Vector3f mouse = transformMouse(mouseX, mouseY); return super.mouseClicked(mouse.x(), mouse.y(), button); } @Override public boolean mouseReleased(double mouseX, double mouseY, int button) { - Vector4f mouse = transformMouse(mouseX, mouseY); + Vector3f mouse = transformMouse(mouseX, mouseY); return super.mouseReleased(mouse.x(), mouse.y(), button); } @Override public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) { - Vector4f mouse = transformMouse(mouseX, mouseY); + Vector3f mouse = transformMouse(mouseX, mouseY); return super.mouseDragged(mouse.x(), mouse.y(), button, deltaX, deltaY); } @Override public boolean mouseScrolled(double mouseX, double mouseY, double amountX, double amountY) { - Vector4f mouse = transformMouse(mouseX, mouseY); + Vector3f mouse = transformMouse(mouseX, mouseY); return super.mouseScrolled(mouse.x(), mouse.y(), amountX, amountY); } @@ -127,12 +126,6 @@ public class DelegateWidgetWithTranslate extends DelegateWidget { } @Override - public double getZRenderingPriority() { - Transformation transformation = new Transformation(translate()); - return transformation.getTranslation().z() + super.getZRenderingPriority(); - } - - @Override public Rectangle getBounds() { return MatrixUtils.transform(translate(), super.getBounds()); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DisplayCompositeWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DisplayCompositeWidget.java index 73c0b1b80..d4e7acfe7 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DisplayCompositeWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DisplayCompositeWidget.java @@ -186,31 +186,31 @@ public class DisplayCompositeWidget extends DelegateWidgetWithBounds implements this.onFavoritesRegion = false; } - graphics.pose().pushPose(); + graphics.pose().pushMatrix(); if (bounds.width <= Math.max(18, this.bounds.width / 2 - 6) && bounds.height <= Math.max(18, this.bounds.height / 2 - 6) && this.onFavoritesRegion) { this.panel.texture(PanelTextures.LIGHTER); this.panel.getBounds().setBounds(bounds); this.panel.render(graphics, mouseX, mouseY, delta); - graphics.pose().pushPose(); - graphics.pose().translate(0, 0.5, 0); + graphics.pose().pushMatrix(); + graphics.pose().translate(0, 0.5f); this.slot.getBounds().setBounds(bounds.getCenterX() - 7, bounds.getCenterY() - 7, 14, 14); this.slot.render(graphics, mouseX, mouseY, delta); - graphics.pose().popPose(); + graphics.pose().popMatrix(); } else { this.panel.texture(ConfigObject.getInstance().getRecipeBorderType()); - graphics.pose().pushPose(); - graphics.pose().translate(bounds.getX(), bounds.getY(), 1); - graphics.pose().scale(bounds.width / (float) this.bounds.getWidth(), bounds.height / (float) this.bounds.getHeight(), 1); - graphics.pose().translate(-this.bounds.getX(), -this.bounds.getY(), 0); + graphics.pose().pushMatrix(); + graphics.pose().translate(bounds.getX(), bounds.getY()); + graphics.pose().scale(bounds.width / (float) this.bounds.getWidth(), bounds.height / (float) this.bounds.getHeight()); + graphics.pose().translate(-this.bounds.getX(), -this.bounds.getY()); this.panel.getBounds().setBounds(this.bounds); this.panel.render(graphics, mouseX, mouseY, delta); - graphics.pose().popPose(); - graphics.pose().translate(bounds.getX(), bounds.getY(), 1); - graphics.pose().scale(bounds.width / (float) this.bounds.getWidth(), bounds.height / (float) this.bounds.getHeight(), 1); - graphics.pose().translate(-this.bounds.getX(), -this.bounds.getY(), 0); + graphics.pose().popMatrix(); + graphics.pose().translate(bounds.getX(), bounds.getY()); + graphics.pose().scale(bounds.width / (float) this.bounds.getWidth(), bounds.height / (float) this.bounds.getHeight()); + graphics.pose().translate(-this.bounds.getX(), -this.bounds.getY()); widget.render(graphics, -1000, -1000, delta); } - graphics.pose().popPose(); + graphics.pose().popMatrix(); } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DisplayTooltipComponent.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DisplayTooltipComponent.java index fd3c2edcc..067f1f3ee 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DisplayTooltipComponent.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DisplayTooltipComponent.java @@ -89,21 +89,21 @@ public class DisplayTooltipComponent implements TooltipComponent, ClientTooltipC @Override public void renderImage(Font font, int x, int y, int width, int height, GuiGraphics graphics) { - graphics.pose().pushPose(); - graphics.pose().translate(x + 2, y + 2, 0); - graphics.pose().translate(-this.bounds.getX(), -this.bounds.getY(), 0); + graphics.pose().pushMatrix(); + graphics.pose().translate(x + 2, y + 2); + graphics.pose().translate(-this.bounds.getX(), -this.bounds.getY()); widget.render(graphics, -1000, -1000, 0); AutoCraftingEvaluator.AutoCraftingResult craftingResult = autoCraftingResult.get(); if (craftingResult.hasApplicable && craftingResult.renderer != null) { - graphics.pose().pushPose(); - Rectangle transformedBounds = MatrixUtils.transform(MatrixUtils.inverse(graphics.pose().last().pose()), new Rectangle(x + 2, y + 2, bounds.width, bounds.height)); - Point mouse = MatrixUtils.transform(graphics.pose().last().pose(), PointHelper.ofMouse()); + graphics.pose().pushMatrix(); + Rectangle transformedBounds = MatrixUtils.transform(MatrixUtils.inverse(graphics.pose()), new Rectangle(x + 2, y + 2, bounds.width, bounds.height)); + Point mouse = MatrixUtils.transform(graphics.pose(), PointHelper.ofMouse()); craftingResult.renderer.render(graphics, mouse.x, mouse.y, Minecraft.getInstance().getDeltaTracker().getRealtimeDeltaTicks(), widgets, transformedBounds, display.provideInternalDisplay()); - graphics.pose().popPose(); + graphics.pose().popMatrix(); } - graphics.pose().popPose(); + graphics.pose().popMatrix(); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DynamicErrorFreeEntryListWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DynamicErrorFreeEntryListWidget.java index b5f076059..1576d638b 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DynamicErrorFreeEntryListWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DynamicErrorFreeEntryListWidget.java @@ -24,7 +24,6 @@ package me.shedaniel.rei.impl.client.gui.widget; import com.google.common.collect.Lists; -import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.blaze3d.vertex.VertexConsumer; import me.shedaniel.rei.api.client.gui.AbstractContainerEventHandler; @@ -38,6 +37,7 @@ import net.minecraft.client.gui.narration.NarratableEntry; import net.minecraft.client.gui.narration.NarratedElementType; import net.minecraft.client.gui.narration.NarrationElementOutput; import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.client.renderer.RenderType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -221,15 +221,14 @@ public abstract class DynamicErrorFreeEntryListWidget<E extends DynamicErrorFree public static void renderBackBackground(GuiGraphics graphics, ResourceLocation backgroundLocation, int left, int top, int right, int bottom, int yOffset, int color) { - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - graphics.drawSpecial(source -> { + /*graphics.drawSpecial(source -> { VertexConsumer buffer = source.getBuffer(RenderType.guiTextured(backgroundLocation)); Matrix4f matrix = graphics.pose().last().pose(); buffer.addVertex(matrix, left, bottom, 0.0F).setUv(left / 32.0F, ((bottom + yOffset) / 32.0F)).setColor(color, color, color, 255); buffer.addVertex(matrix, right, bottom, 0.0F).setUv(right / 32.0F, ((bottom + yOffset) / 32.0F)).setColor(color, color, color, 255); buffer.addVertex(matrix, right, top, 0.0F).setUv(right / 32.0F, ((top + yOffset) / 32.0F)).setColor(color, color, color, 255); buffer.addVertex(matrix, left, top, 0.0F).setUv(left / 32.0F, ((top + yOffset) / 32.0F)).setColor(color, color, color, 255); - }); + });*/ } protected void drawBackground() { @@ -260,9 +259,8 @@ public abstract class DynamicErrorFreeEntryListWidget<E extends DynamicErrorFree this.renderList(graphics, rowLeft, startY, mouseX, mouseY, delta); this.renderHoleBackground(graphics, 0, this.top, 255, 255); this.renderHoleBackground(graphics, this.bottom, this.height, 255, 255); - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - graphics.blit(RenderType::guiTextured, Screen.HEADER_SEPARATOR, this.left, this.top - 2, 0.0F, 0.0F, this.width, 2, 32, 2); - graphics.blit(RenderType::guiTextured, Screen.FOOTER_SEPARATOR, this.left, this.bottom, 0.0F, 0.0F, this.width, 2, 32, 2); + graphics.blit(RenderPipelines.GUI_TEXTURED, Screen.HEADER_SEPARATOR, this.left, this.top - 2, 0.0F, 0.0F, this.width, 2, 32, 2); + graphics.blit(RenderPipelines.GUI_TEXTURED, Screen.FOOTER_SEPARATOR, this.left, this.bottom, 0.0F, 0.0F, this.width, 2, 32, 2); int maxScroll = this.getMaxScroll(); this.renderScrollBar(graphics, maxScroll, scrollbarPosition, int_4); this.renderDecorations(graphics, mouseX, mouseY); @@ -279,7 +277,7 @@ public abstract class DynamicErrorFreeEntryListWidget<E extends DynamicErrorFree int finalY = y; int finalHeight = height; - graphics.drawSpecial(source -> { + /*graphics.drawSpecial(source -> { VertexConsumer buffer = source.getBuffer(RenderType.gui()); Matrix4f matrix = graphics.pose().last().pose(); buffer.addVertex(matrix, scrollbarPositionMinX, this.bottom, 0.0F).setColor(0, 0, 0, 255); @@ -294,7 +292,7 @@ public abstract class DynamicErrorFreeEntryListWidget<E extends DynamicErrorFree buffer.addVertex((scrollbarPositionMaxX - 1), (finalY + finalHeight - 1), 0.0F).setColor(192, 192, 192, 255); buffer.addVertex((scrollbarPositionMaxX - 1), finalY, 0.0F).setColor(192, 192, 192, 255); buffer.addVertex(scrollbarPositionMinX, finalY, 0.0F).setColor(192, 192, 192, 255); - }); + });*/ } } @@ -452,8 +450,7 @@ public abstract class DynamicErrorFreeEntryListWidget<E extends DynamicErrorFree itemMinX = this.left + this.width / 2 - itemWidth / 2; itemMaxX = itemMinX + itemWidth; float float_2 = this.isFocused() ? 1.0F : 0.5F; - Matrix4f matrix = graphics.pose().last().pose(); - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + /*Matrix4f matrix = graphics.pose().last().pose(); int finalItemY = itemY; graphics.drawSpecial(source -> { @@ -466,7 +463,7 @@ public abstract class DynamicErrorFreeEntryListWidget<E extends DynamicErrorFree buffer.addVertex(matrix, itemMaxX - 1, finalItemY + itemHeight + 1, 0.0F).setColor(0.0F, 0.0F, 0.0F, 1.0F); buffer.addVertex(matrix, itemMaxX - 1, finalItemY - 1, 0.0F).setColor(0.0F, 0.0F, 0.0F, 1.0F); buffer.addVertex(matrix, itemMinX + 1, finalItemY - 1, 0.0F).setColor(0.0F, 0.0F, 0.0F, 1.0F); - }); + });*/ } int y = this.getRowTop(renderIndex); @@ -496,7 +493,7 @@ public abstract class DynamicErrorFreeEntryListWidget<E extends DynamicErrorFree } protected void renderHoleBackground(GuiGraphics graphics, int y1, int y2, int alpha1, int alpha2) { - Matrix4f matrix = graphics.pose().last().pose(); + /*Matrix4f matrix = graphics.pose().last().pose(); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); graphics.drawSpecial(source -> { VertexConsumer buffer = source.getBuffer(RenderType.guiTextured(backgroundLocation)); @@ -504,7 +501,7 @@ public abstract class DynamicErrorFreeEntryListWidget<E extends DynamicErrorFree buffer.addVertex(matrix, this.left + this.width, y2, 0.0F).setUv(((float) this.width / 32.0F), ((float) y2 / 32.0F)).setColor(64, 64, 64, alpha2); buffer.addVertex(matrix, this.left + this.width, y1, 0.0F).setUv(((float) this.width / 32.0F), ((float) y1 / 32.0F)).setColor(64, 64, 64, alpha1); buffer.addVertex(matrix, this.left, y1, 0.0F).setUv(0, ((float) y1 / 32.0F)).setColor(64, 64, 64, alpha1); - }); + });*/ } protected E remove(int int_1) { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryHighlighter.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryHighlighter.java index 255630fef..954af357e 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryHighlighter.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryHighlighter.java @@ -30,7 +30,6 @@ import me.shedaniel.rei.impl.client.gui.widget.entrylist.EntryListSearchManager; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; -import net.minecraft.client.renderer.RenderType; import net.minecraft.world.inventory.Slot; public class EntryHighlighter { @@ -44,18 +43,14 @@ public class EntryHighlighter { int x = containerScreen.leftPos, y = containerScreen.topPos; for (Slot slot : containerScreen.getMenu().slots) { if (!slot.hasItem() || !EntryListSearchManager.INSTANCE.matches(EntryStacks.of(slot.getItem()))) { - graphics.fillGradient(RenderType.guiOverlay(), x + slot.x, y + slot.y, x + slot.x + 16, y + slot.y + 16, dimColor, dimColor, 0); + graphics.fillGradient(x + slot.x, y + slot.y, x + slot.x + 16, y + slot.y + 16, dimColor, dimColor); } else { - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 200f); graphics.fillGradient(x + slot.x, y + slot.y, x + slot.x + 16, y + slot.y + 16, color, color); graphics.fillGradient(x + slot.x - 1, y + slot.y - 1, x + slot.x, y + slot.y + 16 + 1, borderColor, borderColor); graphics.fillGradient(x + slot.x + 16, y + slot.y - 1, x + slot.x + 16 + 1, y + slot.y + 16 + 1, borderColor, borderColor); graphics.fillGradient(x + slot.x - 1, y + slot.y - 1, x + slot.x + 16, y + slot.y, borderColor, borderColor); graphics.fillGradient(x + slot.x - 1, y + slot.y + 16, x + slot.x + 16, y + slot.y + 16 + 1, borderColor, borderColor); - - graphics.pose().popPose(); } } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryRendererManager.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryRendererManager.java new file mode 100644 index 000000000..0fabe0a7a --- /dev/null +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryRendererManager.java @@ -0,0 +1,111 @@ +/* + * 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.impl.client.gui.widget; + +import com.google.common.collect.AbstractIterator; +import com.google.common.collect.Iterators; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; +import me.shedaniel.rei.api.common.util.CollectionUtils; +import me.shedaniel.rei.impl.client.util.CrashReportUtils; +import net.minecraft.CrashReport; +import net.minecraft.client.gui.GuiGraphics; +import org.apache.commons.lang3.mutable.MutableInt; +import org.apache.commons.lang3.mutable.MutableLong; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +public class EntryRendererManager<T extends EntryWidget> implements Iterable<T> { + private final Int2ObjectMap<List<Object>> grouping = new Int2ObjectOpenHashMap<>(); + private final List<T> toRender = new ArrayList<>(); + + public EntryRendererManager() { + } + + public EntryRendererManager(Collection<? extends T> widgets) { + addAll(widgets); + } + + public void addAll(Collection<? extends T> widgets) { + toRender.addAll(widgets); + } + + public void add(T widget) { + toRender.add(widget); + } + + public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { + render(false, null, null, graphics, mouseX, mouseY, delta); + } + + public void render(boolean debugTime, MutableInt size, MutableLong time, GuiGraphics graphics, int mouseX, int mouseY, float delta) { + if (!toRender.isEmpty()) { + renderEntries(debugTime, size, time, graphics, mouseX, mouseY, delta, toRender); + } + } + + public static <T extends EntryWidget> void renderEntries(boolean debugTime, MutableInt size, MutableLong time, GuiGraphics graphics, int mouseX, int mouseY, float delta, Iterable<T> entries) { + for (T entry : entries) { + if (entry.getCurrentEntry().isEmpty()) + continue; + try { + if (debugTime) { + size.increment(); + long l = System.nanoTime(); + entry.render(graphics, mouseX, mouseY, delta); + time.add(System.nanoTime() - l); + } else entry.render(graphics, mouseX, mouseY, delta); + } catch (Throwable throwable) { + CrashReport report = CrashReportUtils.essential(throwable, "Rendering entry"); + CrashReportUtils.renderer(report, entry); + CrashReportUtils.catchReport(report); + return; + } + } + } + + @NotNull + @Override + public Iterator<T> iterator() { + return Iterators.concat(toRender.iterator(), Iterators.concat( + CollectionUtils.<List<Object>, Iterator<T>>map(grouping.values(), entries -> new AbstractIterator<>() { + public int i = 0; + + @Override + protected T computeNext() { + if (i >= entries.size()) { + return endOfData(); + } + T widget = (T) entries.get(i); + i += 2; + return widget; + } + }).iterator() + )); + } +} diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryWidget.java index 7d7135373..05b2f5fb0 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryWidget.java @@ -70,6 +70,7 @@ 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.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.resources.language.I18n; import net.minecraft.client.resources.sounds.SimpleSoundInstance; @@ -421,19 +422,16 @@ public class EntryWidget extends Slot implements DraggableStackProviderWidget { protected void drawBackground(GuiGraphics graphics, int mouseX, int mouseY, float delta) { if (background) { darkBackgroundAlpha.update(delta); - graphics.blit(RenderType::guiTextured, InternalTextures.CHEST_GUI_TEXTURE, bounds.x, bounds.y, 0, 222, bounds.width, bounds.height, 256, 256); + graphics.blit(RenderPipelines.GUI_TEXTURED, InternalTextures.CHEST_GUI_TEXTURE, bounds.x, bounds.y, 0, 222, bounds.width, bounds.height, 256, 256); if (darkBackgroundAlpha.value() > 0.0F) { - graphics.blit(RenderType::guiTextured, InternalTextures.CHEST_GUI_TEXTURE_DARK, bounds.x, bounds.y, 0, 222, bounds.width, bounds.height, 256, 256, ARGB.white(darkBackgroundAlpha.value())); + graphics.blit(RenderPipelines.GUI_TEXTURED, InternalTextures.CHEST_GUI_TEXTURE_DARK, bounds.x, bounds.y, 0, 222, bounds.width, bounds.height, 256, 256, ARGB.white(darkBackgroundAlpha.value())); } } } protected void drawCurrentEntry(GuiGraphics graphics, int mouseX, int mouseY, float delta) { EntryStack<?> entry = getCurrentEntry(); - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 100); entry.render(graphics, getInnerBounds(), mouseX, mouseY, delta); - graphics.pose().popPose(); } protected void queueTooltip(GuiGraphics graphics, int mouseX, int mouseY, float delta) { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/HoleWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/HoleWidget.java index 109646a1c..5505a8591 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/HoleWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/HoleWidget.java @@ -27,7 +27,7 @@ import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.widgets.Widget; import me.shedaniel.rei.api.client.gui.widgets.Widgets; import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen; -import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.resources.ResourceLocation; public class HoleWidget { @@ -43,14 +43,14 @@ public class HoleWidget { public static Widget createMenuBackground(Rectangle bounds) { return Widgets.withBounds(Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> { - graphics.blit(RenderType::guiTextured, ResourceLocation.withDefaultNamespace("textures/gui/menu_list_background.png"), bounds.x, bounds.y, bounds.getMaxX(), bounds.getMaxY(), bounds.width, bounds.height, 32, 32); + graphics.blit(RenderPipelines.GUI_TEXTURED, ResourceLocation.withDefaultNamespace("textures/gui/menu_list_background.png"), bounds.x, bounds.y, bounds.getMaxX(), bounds.getMaxY(), bounds.width, bounds.height, 32, 32); }), bounds); } public static Widget createListBorders(Rectangle bounds) { return Widgets.withBounds(Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> { - graphics.blit(RenderType::guiTextured, CreateWorldScreen.HEADER_SEPARATOR, bounds.x, bounds.y - 2, 0.0F, 0.0F, bounds.width, 2, 32, 2); - graphics.blit(RenderType::guiTextured, CreateWorldScreen.FOOTER_SEPARATOR, bounds.x, bounds.getMaxY(), 0.0F, 0.0F, bounds.width, 2, 32, 2); + graphics.blit(RenderPipelines.GUI_TEXTURED, CreateWorldScreen.HEADER_SEPARATOR, bounds.x, bounds.y - 2, 0.0F, 0.0F, bounds.width, 2, 32, 2); + graphics.blit(RenderPipelines.GUI_TEXTURED, CreateWorldScreen.FOOTER_SEPARATOR, bounds.x, bounds.getMaxY(), 0.0F, 0.0F, bounds.width, 2, 32, 2); }), bounds); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/InternalWidgets.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/InternalWidgets.java index 0094b2c05..d89824a65 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/InternalWidgets.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/InternalWidgets.java @@ -49,7 +49,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.network.chat.FormattedText; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.ApiStatus; -import org.joml.Matrix4f; +import org.joml.Matrix3x2f; import java.util.Collection; import java.util.List; @@ -188,7 +188,7 @@ public final class InternalWidgets { } @Override - public WidgetWithBounds withTranslate(WidgetWithBounds widget, Supplier<Matrix4f> translate) { + public WidgetWithBounds withTranslate(WidgetWithBounds widget, Supplier<Matrix3x2f> translate) { return new DelegateWidgetWithTranslate(widget, translate); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/ListWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/ListWidget.java index 3121a5d95..0a7dcdd18 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/ListWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/ListWidget.java @@ -30,7 +30,7 @@ import me.shedaniel.rei.api.client.gui.widgets.Widget; import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds; import me.shedaniel.rei.api.client.gui.widgets.Widgets; import me.shedaniel.rei.api.common.util.CollectionUtils; -import org.joml.Matrix4f; +import org.joml.Matrix3x2f; import java.util.ArrayList; import java.util.List; @@ -191,7 +191,7 @@ public class ListWidget { private final ListEntryPredicate<T> isSelectable; public CellWidget(Rectangle bounds, int index, WidgetWithBounds widget, IntValue selected, List<T> list, ListEntryPredicate<T> isSelectable) { - super(widget, Matrix4f::new); + super(widget, Matrix3x2f::new); this.bounds = bounds; this.index = index; this.height = widget.getBounds().getHeight(); @@ -229,9 +229,9 @@ public class ListWidget { } @Override - protected Matrix4f translate() { + protected Matrix3x2f translate() { Rectangle bounds = delegate().getBounds(); - return new Matrix4f().translate(position.x - bounds.x, position.y - bounds.y, 0); + return new Matrix3x2f().translate(position.x - bounds.x, position.y - bounds.y); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/OverflowWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/OverflowWidget.java index 1998bd82e..0b88206c9 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/OverflowWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/OverflowWidget.java @@ -33,7 +33,7 @@ import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.gui.widgets.CloseableScissors; import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds; import net.minecraft.client.gui.GuiGraphics; -import org.joml.Matrix4f; +import org.joml.Matrix3x2f; @SuppressWarnings("UnstableApiUsage") public class OverflowWidget extends DelegateWidgetWithTranslate { @@ -44,7 +44,7 @@ public class OverflowWidget extends DelegateWidgetWithTranslate { private boolean dragging; public OverflowWidget(Rectangle bounds, WidgetWithBounds widget) { - super(widget, Matrix4f::new); + super(widget, Matrix3x2f::new); this.bounds = bounds; this.scale = ValueAnimator.ofFloat() .setAs(1f); @@ -55,11 +55,11 @@ public class OverflowWidget extends DelegateWidgetWithTranslate { } @Override - protected Matrix4f translate() { + protected Matrix3x2f translate() { FloatingPoint translate = this.translate.value(); float scale = 1 / Math.max(this.scale.floatValue(), 0.001f); - Matrix4f matrix = new Matrix4f().translate(bounds.getCenterX() + (float) translate.x * scale, bounds.getCenterY() + (float) translate.y * scale, 0); - matrix.mul(new Matrix4f().scale(scale, scale, 1)); + Matrix3x2f matrix = new Matrix3x2f().translate(bounds.getCenterX() + (float) translate.x * scale, bounds.getCenterY() + (float) translate.y * scale); + matrix.mul(new Matrix3x2f().scale(scale, scale)); return matrix; } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/PaddedCenterWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/PaddedCenterWidget.java index 09bac9a6b..064530318 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/PaddedCenterWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/PaddedCenterWidget.java @@ -25,18 +25,18 @@ package me.shedaniel.rei.impl.client.gui.widget; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds; -import org.joml.Matrix4f; +import org.joml.Matrix3x2f; public class PaddedCenterWidget extends DelegateWidgetWithTranslate { private final Rectangle bounds; public PaddedCenterWidget(Rectangle bounds, WidgetWithBounds widget) { - super(widget, Matrix4f::new); + super(widget, Matrix3x2f::new); this.bounds = bounds; } @Override - protected Matrix4f translate() { + protected Matrix3x2f translate() { Rectangle widgetBounds = ((WidgetWithBounds) delegate()).getBounds(); float xTranslate = 0, yTranslate = 0; if (widgetBounds.width < bounds.width) { @@ -45,7 +45,7 @@ public class PaddedCenterWidget extends DelegateWidgetWithTranslate { if (widgetBounds.height < bounds.height) { yTranslate = (bounds.height - widgetBounds.height) / 2f; } - return new Matrix4f().translate(xTranslate, yTranslate, 0); + return new Matrix3x2f().translate(xTranslate, yTranslate); } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/PaddedWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/PaddedWidget.java index b1ecd3d1e..fc7a1d8ee 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/PaddedWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/PaddedWidget.java @@ -25,13 +25,13 @@ package me.shedaniel.rei.impl.client.gui.widget; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds; -import org.joml.Matrix4f; +import org.joml.Matrix3x2f; public class PaddedWidget extends DelegateWidgetWithTranslate { private final int padLeft, padRight, padTop, padBottom; public PaddedWidget(int padLeft, int padRight, int padTop, int padBottom, WidgetWithBounds widget) { - super(widget, Matrix4f::new); + super(widget, Matrix3x2f::new); this.padLeft = padLeft; this.padRight = padRight; this.padTop = padTop; @@ -39,8 +39,8 @@ public class PaddedWidget extends DelegateWidgetWithTranslate { } @Override - protected Matrix4f translate() { - return new Matrix4f().translate(padLeft, padRight, 0); + protected Matrix3x2f translate() { + return new Matrix3x2f().translate(padLeft, padRight); } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/ScrollableViewWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/ScrollableViewWidget.java index ec8147b87..3ba32e202 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/ScrollableViewWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/ScrollableViewWidget.java @@ -31,7 +31,7 @@ import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds; import me.shedaniel.rei.api.client.gui.widgets.Widgets; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; -import org.joml.Matrix4f; +import org.joml.Matrix3x2f; import java.util.ArrayList; import java.util.Collections; @@ -62,7 +62,7 @@ public class ScrollableViewWidget { } widgets.add(Widgets.scissored(scrollingRef[0].getScissorBounds(), Widgets.withTranslate(inner, - () -> new Matrix4f().translate(0, -scrollingRef[0].scrollAmountInt(), 0)))); + () -> new Matrix3x2f().translate(0, -scrollingRef[0].scrollAmountInt())))); widgets.add(Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> { scrollingRef[0].updatePosition(delta); scrollingRef[0].renderScrollBar(graphics); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/TabContainerWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/TabContainerWidget.java index cb7d28d86..f21a7e682 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/TabContainerWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/TabContainerWidget.java @@ -33,7 +33,7 @@ import me.shedaniel.rei.api.client.registry.display.DisplayCategory; import me.shedaniel.rei.impl.client.gui.InternalTextures; 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.util.Mth; @@ -213,20 +213,20 @@ public class TabContainerWidget { .onClick(button -> rightAction.run()) .tooltipLine(Component.translatable("text.rei.next_page"))); - widgets.add(Widgets.withTranslate(Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> { + widgets.add(Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> { Rectangle tabLeftBounds = tabLeft.getBounds(); Rectangle tabRightBounds = tabRight.getBounds(); if (isCompactTabButtons) { - graphics.pose().pushPose(); - graphics.pose().translate(0, 0.5, 0); - graphics.blit(RenderType::guiTextured, InternalTextures.ARROW_LEFT_SMALL_TEXTURE, tabLeftBounds.x + 2, tabLeftBounds.y + 2, 0, 0, 6, 6, 6, 6); - graphics.blit(RenderType::guiTextured, InternalTextures.ARROW_RIGHT_SMALL_TEXTURE, tabRightBounds.x + 2, tabRightBounds.y + 2, 0, 0, 6, 6, 6, 6); - graphics.pose().popPose(); + graphics.pose().pushMatrix(); + graphics.pose().translate(0, 0.5f); + graphics.blit(RenderPipelines.GUI_TEXTURED, InternalTextures.ARROW_LEFT_SMALL_TEXTURE, tabLeftBounds.x + 2, tabLeftBounds.y + 2, 0, 0, 6, 6, 6, 6); + graphics.blit(RenderPipelines.GUI_TEXTURED, InternalTextures.ARROW_RIGHT_SMALL_TEXTURE, tabRightBounds.x + 2, tabRightBounds.y + 2, 0, 0, 6, 6, 6, 6); + graphics.pose().popMatrix(); } else { - graphics.blit(RenderType::guiTextured, InternalTextures.ARROW_LEFT_TEXTURE, tabLeftBounds.x + 4, tabLeftBounds.y + 4, 0, 0, 8, 8, 8, 8); - graphics.blit(RenderType::guiTextured, InternalTextures.ARROW_RIGHT_TEXTURE, tabRightBounds.x + 4, tabRightBounds.y + 4, 0, 0, 8, 8, 8, 8); + graphics.blit(RenderPipelines.GUI_TEXTURED, InternalTextures.ARROW_LEFT_TEXTURE, tabLeftBounds.x + 4, tabLeftBounds.y + 4, 0, 0, 8, 8, 8, 8); + graphics.blit(RenderPipelines.GUI_TEXTURED, InternalTextures.ARROW_RIGHT_TEXTURE, tabRightBounds.x + 4, tabRightBounds.y + 4, 0, 0, 8, 8, 8, 8); } - }), 0, 0, 1)); + })); return widgets; } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/TabWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/TabWidget.java index 607ba4874..0bb87510e 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/TabWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/TabWidget.java @@ -23,7 +23,6 @@ package me.shedaniel.rei.impl.client.gui.widget; -import com.mojang.blaze3d.systems.RenderSystem; import me.shedaniel.clothconfig2.api.animator.NumberAnimator; import me.shedaniel.clothconfig2.api.animator.ValueAnimator; import me.shedaniel.math.Point; @@ -46,7 +45,7 @@ import me.shedaniel.rei.impl.client.gui.InternalTextures; import net.minecraft.ChatFormatting; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.network.chat.Component; import net.minecraft.util.ARGB; import org.jetbrains.annotations.ApiStatus; @@ -114,13 +113,9 @@ public class TabWidget extends WidgetWithBounds implements DraggableStackProvide if (renderer != null) { try (CloseableScissors scissors = Widget.scissor(graphics, new Rectangle(bounds.x, bounds.y + 2, bounds.width, (selected ? bounds.height + 2 : bounds.height - 2)))) { darkBackgroundAlpha.update(delta); - graphics.blit(RenderType::guiTextured, InternalTextures.CHEST_GUI_TEXTURE, bounds.x, bounds.y + 2, u + (selected ? bounds.width : 0), v, bounds.width, (selected ? bounds.height + 2 : bounds.height - 2), 256, 256, ARGB.white(opacity)); - graphics.blit(RenderType::guiTextured, InternalTextures.CHEST_GUI_TEXTURE_DARK, bounds.x, bounds.y + 2, u + (selected ? bounds.width : 0), v, bounds.width, (selected ? bounds.height + 2 : bounds.height - 2), 256, 256, ARGB.white(darkBackgroundAlpha.value() * opacity)); - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, opacity); - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 100); + graphics.blit(RenderPipelines.GUI_TEXTURED, InternalTextures.CHEST_GUI_TEXTURE, bounds.x, bounds.y + 2, u + (selected ? bounds.width : 0), v, bounds.width, (selected ? bounds.height + 2 : bounds.height - 2), 256, 256, ARGB.white(opacity)); + graphics.blit(RenderPipelines.GUI_TEXTURED, InternalTextures.CHEST_GUI_TEXTURE_DARK, bounds.x, bounds.y + 2, u + (selected ? bounds.width : 0), v, bounds.width, (selected ? bounds.height + 2 : bounds.height - 2), 256, 256, ARGB.white(darkBackgroundAlpha.value() * opacity)); renderer.render(graphics, new Rectangle(bounds.getCenterX() - 8, bounds.getCenterY() - 5, 16, 16), mouseX, mouseY, delta); - graphics.pose().popPose(); } if (containsMouse(mouseX, mouseY) && category != null) { drawTooltip(); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/VStackWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/VStackWidget.java index 21d06b542..da6d28186 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/VStackWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/VStackWidget.java @@ -30,7 +30,7 @@ import me.shedaniel.rei.api.client.gui.widgets.Widget; import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds; import me.shedaniel.rei.api.client.gui.widgets.Widgets; import me.shedaniel.rei.api.common.util.CollectionUtils; -import org.joml.Matrix4f; +import org.joml.Matrix3x2f; import java.util.ArrayList; import java.util.List; @@ -113,7 +113,7 @@ public class VStackWidget { private final int height; public CellWidget(WidgetWithBounds widget) { - super(widget, Matrix4f::new); + super(widget, Matrix3x2f::new); this.height = widget.getBounds().getHeight(); } @@ -123,9 +123,9 @@ public class VStackWidget { } @Override - protected Matrix4f translate() { + protected Matrix3x2f translate() { Rectangle bounds = delegate().getBounds(); - return new Matrix4f().translate(position.x - bounds.x, position.y - bounds.y, 0); + return new Matrix3x2f().translate(position.x - bounds.x, position.y - bounds.y); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/VanillaWrappedWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/VanillaWrappedWidget.java index 5d9383242..39c48f327 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/VanillaWrappedWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/VanillaWrappedWidget.java @@ -47,10 +47,10 @@ public class VanillaWrappedWidget extends Widget { if (element instanceof Widget widget) { widget.render(graphics, mouseX, mouseY, delta); } else { - graphics.pose().pushPose(); + graphics.pose().pushMatrix(); if (element instanceof Renderable widget) widget.render(graphics, mouseX, mouseY, delta); - graphics.pose().popPose(); + graphics.pose().popMatrix(); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/ArrowWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/ArrowWidget.java index 0b6678d3a..af3ec41f1 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/ArrowWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/ArrowWidget.java @@ -30,7 +30,7 @@ import me.shedaniel.rei.api.client.REIRuntime; import me.shedaniel.rei.api.client.gui.widgets.Arrow; 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; @@ -85,10 +85,10 @@ public final class ArrowWidget extends Arrow { ResourceLocation texture = REIRuntime.getInstance().getDefaultDisplayTexture(dark); if (getAnimationDuration() > 0) { int width = Mth.ceil((System.currentTimeMillis() / (animationDuration / 24) % 24d)); - graphics.blit(RenderType::guiTextured, texture, getX() + width, getY(), 106 + width, 91, 24 - width, 17, 256, 256, 0xFFFFFF | (int) (alpha * 255) << 24); - graphics.blit(RenderType::guiTextured, texture, getX(), getY(), 82, 91, width, 17, 256, 256, 0xFFFFFF | (int) (alpha * 255) << 24); + graphics.blit(RenderPipelines.GUI_TEXTURED, texture, getX() + width, getY(), 106 + width, 91, 24 - width, 17, 256, 256, 0xFFFFFF | (int) (alpha * 255) << 24); + graphics.blit(RenderPipelines.GUI_TEXTURED, texture, getX(), getY(), 82, 91, width, 17, 256, 256, 0xFFFFFF | (int) (alpha * 255) << 24); } else { - graphics.blit(RenderType::guiTextured, texture, getX(), getY(), 106, 91, 24, 17, 256, 256, 0xFFFFFF | (int) (alpha * 255) << 24); + graphics.blit(RenderPipelines.GUI_TEXTURED, texture, getX(), getY(), 106, 91, 24, 17, 256, 256, 0xFFFFFF | (int) (alpha * 255) << 24); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/BurningFireWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/BurningFireWidget.java index e43927d85..eba8e3308 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/BurningFireWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/BurningFireWidget.java @@ -30,7 +30,7 @@ import me.shedaniel.rei.api.client.REIRuntime; import me.shedaniel.rei.api.client.gui.widgets.BurningFire; 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; @@ -79,10 +79,10 @@ public final class BurningFireWidget extends BurningFire { ResourceLocation texture = REIRuntime.getInstance().getDefaultDisplayTexture(dark); if (getAnimationDuration() > 0) { int height = 14 - Mth.ceil((System.currentTimeMillis() / (animationDuration / 14) % 14d)); - graphics.blit(RenderType::guiTextured, texture, getX(), getY(), 1, 74, 14, 14 - height, 256, 256, 0xFFFFFF | (int) (alpha * 255) << 24); - graphics.blit(RenderType::guiTextured, texture, getX(), getY() + 14 - height, 82, 77 + (14 - height), 14, height, 256, 256, 0xFFFFFF | (int) (alpha * 255) << 24); + graphics.blit(RenderPipelines.GUI_TEXTURED, texture, getX(), getY(), 1, 74, 14, 14 - height, 256, 256, 0xFFFFFF | (int) (alpha * 255) << 24); + graphics.blit(RenderPipelines.GUI_TEXTURED, texture, getX(), getY() + 14 - height, 82, 77 + (14 - height), 14, height, 256, 256, 0xFFFFFF | (int) (alpha * 255) << 24); } else { - graphics.blit(RenderType::guiTextured, texture, getX(), getY(), 1, 74, 14, 14, 256, 256, 0xFFFFFF | (int) (alpha * 255) << 24); + graphics.blit(RenderPipelines.GUI_TEXTURED, texture, getX(), getY(), 1, 74, 14, 14, 256, 256, 0xFFFFFF | (int) (alpha * 255) << 24); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/ButtonWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/ButtonWidget.java index 2b961dc4e..709e3df81 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/ButtonWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/ButtonWidget.java @@ -36,7 +36,7 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.WidgetSprites; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.navigation.FocusNavigationEvent; -import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.client.resources.sounds.SimpleSoundInstance; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -286,6 +286,6 @@ public class ButtonWidget extends Button { protected void renderBackground(GuiGraphics graphics, int x, int y, int width, int height, boolean focused, boolean dark, Color color) { WidgetSprites sprites = dark ? DARK_SPRITES : SPRITES; ResourceLocation texture = sprites.get(this.isEnabled(), focused); - graphics.blitSprite(RenderType::guiTextured, texture, x, y, width, height, color.getColor()); + graphics.blitSprite(RenderPipelines.GUI_TEXTURED, texture, x, y, width, height, color.getColor()); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/FillRectangleDrawableConsumer.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/FillRectangleDrawableConsumer.java index 50998b8e1..c46405687 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/FillRectangleDrawableConsumer.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/FillRectangleDrawableConsumer.java @@ -23,12 +23,9 @@ package me.shedaniel.rei.impl.client.gui.widget.basewidgets; -import com.mojang.blaze3d.vertex.VertexConsumer; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.DrawableConsumer; import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.renderer.RenderType; -import org.joml.Matrix4f; public final class FillRectangleDrawableConsumer implements DrawableConsumer { private Rectangle rectangle; @@ -41,17 +38,6 @@ public final class FillRectangleDrawableConsumer implements DrawableConsumer { @Override public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { - float a = (color >> 24 & 255) / 255.0F; - float r = (color >> 16 & 255) / 255.0F; - float g = (color >> 8 & 255) / 255.0F; - float b = (color & 255) / 255.0F; - graphics.drawSpecial(source -> { - Matrix4f pose = graphics.pose().last().pose(); - VertexConsumer buffer = source.getBuffer(RenderType.gui()); - buffer.addVertex(pose, rectangle.getMaxX(), rectangle.getMinY(), 0).setColor(r, g, b, a); - buffer.addVertex(pose, rectangle.getMinX(), rectangle.getMinY(), 0).setColor(r, g, b, a); - buffer.addVertex(pose, rectangle.getMinX(), rectangle.getMaxY(), 0).setColor(r, g, b, a); - buffer.addVertex(pose, rectangle.getMaxX(), rectangle.getMaxY(), 0).setColor(r, g, b, a); - }); + graphics.fillGradient(rectangle.x, rectangle.y, rectangle.getMaxX(), rectangle.getMaxY(), color, color); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/PanelWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/PanelWidget.java index fd2165ee6..b82691cb4 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/PanelWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/PanelWidget.java @@ -33,7 +33,7 @@ import me.shedaniel.rei.api.client.gui.widgets.utils.PanelTextures; import me.shedaniel.rei.impl.client.gui.config.options.ConfigUtils; 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.ARGB; import org.jetbrains.annotations.ApiStatus; @@ -114,7 +114,7 @@ public final class PanelWidget extends Panel { public void renderBackground(GuiGraphics graphics, int x, int y, int width, int height, boolean dark, float alpha, float red, float green, float blue) { ResourceLocation texture = dark ? this.darkTexture : this.texture; - graphics.blitSprite(RenderType::guiTextured, texture, x, y, width, height, ARGB.colorFromFloat(alpha, red, green, blue)); + graphics.blitSprite(RenderPipelines.GUI_TEXTURED, texture, x, y, width, height, ARGB.colorFromFloat(alpha, red, green, blue)); } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/TextFieldWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/TextFieldWidget.java index 3d4f0b9dc..8fb1c6e63 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/TextFieldWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/TextFieldWidget.java @@ -23,7 +23,6 @@ package me.shedaniel.rei.impl.client.gui.widget.basewidgets; -import com.mojang.blaze3d.vertex.VertexConsumer; import me.shedaniel.clothconfig2.api.TickableWidget; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.widgets.TextField; @@ -34,14 +33,13 @@ import net.minecraft.client.gui.ComponentPath; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.navigation.FocusNavigationEvent; import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.renderer.RenderType; import net.minecraft.network.chat.Style; +import net.minecraft.util.ARGB; import net.minecraft.util.FormattedCharSequence; import net.minecraft.util.Mth; import net.minecraft.util.StringUtil; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; -import org.joml.Matrix4f; import java.util.Collections; import java.util.List; @@ -57,8 +55,8 @@ public class TextFieldWidget extends WidgetWithBounds implements TickableWidget, protected int firstCharacterIndex; protected int cursorPos; protected int highlightPos; - protected int editableColor = 0xe0e0e0; - protected int notEditableColor = 0x707070; + protected int editableColor = 0xffe0e0e0; + protected int notEditableColor = 0xff707070; protected TextFormatter formatter = TextFormatter.DEFAULT; private Rectangle bounds; private String text = ""; @@ -425,7 +423,9 @@ public class TextFieldWidget extends WidgetWithBounds implements TickableWidget, if (!textClipped.isEmpty()) { String string_2 = boolean_1 ? textClipped.substring(0, int_4) : textClipped; - int_8 = graphics.drawString(this.font, this.formatter.format(this, string_2, this.firstCharacterIndex), x, y, color); + FormattedCharSequence sequence = this.formatter.format(this, string_2, this.firstCharacterIndex); + graphics.drawString(this.font, sequence, x, y, color); + int_8 = x + this.font.width(sequence); } boolean isCursorInsideText = this.cursorPos < this.text.length() || this.text.length() >= this.getMaxLength(); @@ -485,18 +485,7 @@ public class TextFieldWidget extends WidgetWithBounds implements TickableWidget, } int finalX1 = x1, finalX2 = x2, finalY1 = y1, finalY2 = y2; - graphics.drawSpecial(source -> { - int r = (color >> 16 & 255); - int g = (color >> 8 & 255); - int b = (color & 255); - - VertexConsumer buffer = source.getBuffer(RenderType.gui()); - Matrix4f matrix = graphics.pose().last().pose(); - buffer.addVertex(matrix, finalX1, finalY2, 50f).setColor(r, g, b, 120); - buffer.addVertex(matrix, finalX2, finalY2, 50f).setColor(r, g, b, 120); - buffer.addVertex(matrix, finalX2, finalY1, 50f).setColor(r, g, b, 120); - buffer.addVertex(matrix, finalX1, finalY1, 50f).setColor(r, g, b, 120); - }); + graphics.fillGradient(x1, y1, x2, y2, ARGB.color(120, color), ARGB.color(120, color)); } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/TexturedDrawableConsumer.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/TexturedDrawableConsumer.java index 22edcd41f..5accd1cec 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/TexturedDrawableConsumer.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/TexturedDrawableConsumer.java @@ -23,13 +23,11 @@ package me.shedaniel.rei.impl.client.gui.widget.basewidgets; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.VertexConsumer; +import com.mojang.blaze3d.pipeline.RenderPipeline; import me.shedaniel.rei.api.client.gui.DrawableConsumer; import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.resources.ResourceLocation; -import org.joml.Matrix4f; public final class TexturedDrawableConsumer implements DrawableConsumer { private ResourceLocation identifier; @@ -52,19 +50,10 @@ public final class TexturedDrawableConsumer implements DrawableConsumer { @Override public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { - graphics.drawSpecial(source -> { - innerBlit(source.getBuffer(RenderType.guiTextured(identifier)), graphics.pose().last().pose(), x, x + width, y, y + height, 0, uWidth, vHeight, u, v, textureWidth, textureHeight); - }); + innerBlit(graphics, RenderPipelines.GUI_TEXTURED, identifier, x, x + width, y, y + height, uWidth, vHeight, u, v, textureWidth, textureHeight); } - private static void innerBlit(VertexConsumer consumer, Matrix4f matrix, int xStart, int xEnd, int yStart, int yEnd, int z, int width, int height, float u, float v, int texWidth, int texHeight) { - innerBlit(consumer, matrix, xStart, xEnd, yStart, yEnd, z, u / texWidth, (u + width) / texWidth, v / texHeight, (v + height) / texHeight); - } - - private static void innerBlit(VertexConsumer consumer, Matrix4f matrix, int xStart, int xEnd, int yStart, int yEnd, int z, float uStart, float uEnd, float vStart, float vEnd) { - consumer.addVertex(matrix, xStart, yEnd, z).setUv(uStart, vEnd).setColor(-1); - consumer.addVertex(matrix, xEnd, yEnd, z).setUv(uEnd, vEnd).setColor(-1); - consumer.addVertex(matrix, xEnd, yStart, z).setUv(uEnd, vStart).setColor(-1); - consumer.addVertex(matrix, xStart, yStart, z).setUv(uStart, vStart).setColor(-1); + private static void innerBlit(GuiGraphics graphics, RenderPipeline pipeline, ResourceLocation location, int xStart, int xEnd, int yStart, int yEnd, int width, int height, float u, float v, int texWidth, int texHeight) { + graphics.innerBlit(pipeline, location, xStart, xEnd, yStart, yEnd, u / texWidth, (u + width) / texWidth, v / texHeight, (v + height) / texHeight, -1); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/CachingEntryRenderer.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/CachingEntryRenderer.java index da2d7a245..c2dc66c6b 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/CachingEntryRenderer.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/CachingEntryRenderer.java @@ -23,20 +23,17 @@ package me.shedaniel.rei.impl.client.gui.widget.entrylist; -import com.mojang.blaze3d.vertex.VertexConsumer; import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.client.entry.renderer.BatchedEntryRenderer; +import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; import me.shedaniel.rei.api.client.gui.widgets.TooltipContext; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.impl.client.gui.widget.CachedEntryListRender; import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderPipelines; import org.jetbrains.annotations.Nullable; -import org.joml.Matrix4f; -public class CachingEntryRenderer implements BatchedEntryRenderer<Object, CachedEntryListRender.Sprite> { +public class CachingEntryRenderer implements EntryRenderer<Object> { private final CachedEntryListRender.Sprite sprite; public CachingEntryRenderer(CachedEntryListRender.Sprite sprite) { @@ -44,44 +41,8 @@ public class CachingEntryRenderer implements BatchedEntryRenderer<Object, Cached } @Override - public CachedEntryListRender.Sprite getExtraData(EntryStack<Object> entry) { - return sprite; - } - - @Override - public int getBatchIdentifier(EntryStack<Object> entry, Rectangle bounds, CachedEntryListRender.Sprite extraData) { - return 0; - } - - @Override - public void startBatch(EntryStack<Object> entry, CachedEntryListRender.Sprite extraData, GuiGraphics graphics, float delta) { - } - - @Override - public void renderBase(EntryStack<Object> entry, CachedEntryListRender.Sprite extraData, GuiGraphics graphics, MultiBufferSource.BufferSource immediate, Rectangle bounds, int mouseX, int mouseY, float delta) { - VertexConsumer consumer = immediate.getBuffer(CachedEntryListRender.renderType.get()); - Matrix4f pose = graphics.pose().last().pose(); - consumer.addVertex(pose, bounds.x, bounds.getMaxY(), 0).setUv(extraData.u0, extraData.v1); - consumer.addVertex(pose, bounds.getMaxX(), bounds.getMaxY(), 0).setUv(extraData.u1, extraData.v1); - consumer.addVertex(pose, bounds.getMaxX(), bounds.y, 0).setUv(extraData.u1, extraData.v0); - consumer.addVertex(pose, bounds.x, bounds.y, 0).setUv(extraData.u0, extraData.v0); - } - - @Override - public void afterBase(EntryStack<Object> entry, CachedEntryListRender.Sprite extraData, GuiGraphics graphics, float delta) { - } - - @Override - public void renderOverlay(EntryStack<Object> entry, CachedEntryListRender.Sprite extraData, GuiGraphics graphics, MultiBufferSource.BufferSource immediate, Rectangle bounds, int mouseX, int mouseY, float delta) { - } - - @Override - public void endBatch(EntryStack<Object> entry, CachedEntryListRender.Sprite extraData, GuiGraphics graphics, float delta) { - } - - @Override public void render(EntryStack<Object> entry, GuiGraphics graphics, Rectangle bounds, int mouseX, int mouseY, float delta) { - graphics.innerBlit(RenderType::guiTextured, CachedEntryListRender.cachedTextureLocation, bounds.x, bounds.getMaxX(), bounds.y, bounds.getMaxY(), sprite.u0, sprite.u1, sprite.v0, sprite.v1, -1); + graphics.innerBlit(RenderPipelines.GUI_TEXTURED, CachedEntryListRender.cachedTextureLocation, bounds.x, bounds.getMaxX(), bounds.y, bounds.getMaxY(), sprite.u0, sprite.u1, sprite.v0, sprite.v1, -1); } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/CollapsedEntriesBorderRenderer.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/CollapsedEntriesBorderRenderer.java index e129d95db..644be613d 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/CollapsedEntriesBorderRenderer.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/CollapsedEntriesBorderRenderer.java @@ -97,8 +97,8 @@ public class CollapsedEntriesBorderRenderer { } edgeSet.removeAll(toRemove); - graphics.pose().pushPose(); - graphics.pose().translate(-100, -100, 0); + graphics.pose().pushMatrix(); + graphics.pose().translate(-100, -100); iterator = edgeSet.iterator(); while (iterator.hasNext()) { @@ -143,7 +143,7 @@ public class CollapsedEntriesBorderRenderer { } } - graphics.pose().popPose(); + graphics.pose().popMatrix(); } private static long getPackedLong(int x, int y, int collapsedStackIndices, int direction, boolean occupied) { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/CollapsedEntriesTooltip.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/CollapsedEntriesTooltip.java index 049d77c68..ac1519e16 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/CollapsedEntriesTooltip.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/CollapsedEntriesTooltip.java @@ -62,24 +62,20 @@ public class CollapsedEntriesTooltip implements ClientTooltipComponent, TooltipC int entrySize = EntryListWidget.entrySize(); int w = Math.max(1, MAX_WIDTH / entrySize); int i = 0; - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 50); for (EntryStack<?> entry : stack.getIngredient()) { int x1 = x + (i % w) * entrySize; int y1 = y + (i / w) * entrySize; i++; if (i / w > 3 - 1) { - graphics.pose().translate(0, 0, 200); Component text = Component.literal("+" + (stack.getIngredient().size() - w * 3 + 1)).withStyle(ChatFormatting.GRAY); - graphics.drawSpecial(source -> { - font.drawInBatch(text, x1 + entrySize / 2 - font.width(text) / 2, y1 + entrySize / 2 - 1, -1, true, graphics.pose().last().pose(), source, Font.DisplayMode.NORMAL, 0, 15728880); - }); - graphics.flush(); + graphics.pose().pushMatrix(); + graphics.pose().translate(x1 + entrySize / 2 - font.width(text) / 2, y1 + entrySize / 2 - 1); + graphics.drawString(font, text, 0, 0, -1); + graphics.pose().popMatrix(); break; } else { entry.render(graphics, new Rectangle(x1, y1, entrySize, entrySize), -1000, -1000, 0); } } - graphics.pose().popPose(); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListStackEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListStackEntry.java index c5827e408..38aad1187 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListStackEntry.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListStackEntry.java @@ -131,8 +131,6 @@ public class EntryListStackEntry extends DisplayedEntryWidget { List<EntryStack<?>> stacks = collapsedStack.getIngredient(); float fullSize = bounds.getWidth(); - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 10); for (int i = stacks.size() - 1; i >= 0; i--) { EntryStack<?> stack = stacks.get(i); @@ -148,11 +146,7 @@ public class EntryListStackEntry extends DisplayedEntryWidget { double scaledSize = value.width * fullSize; stack.render(graphics, new Rectangle(x - scaledSize / 2, y - scaledSize / 2, scaledSize, scaledSize), mouseX, mouseY, delta); - - graphics.pose().translate(0, 0, 10); } - - graphics.pose().popPose(); } else { super.drawCurrentEntry(graphics, mouseX, mouseY, delta); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListWidget.java index 831fa2cda..37c70d1c2 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListWidget.java @@ -192,8 +192,7 @@ public abstract class EntryListWidget extends WidgetWithBounds implements Overla public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { if (!hasSpace()) return; - boolean fastEntryRendering = ConfigObject.getInstance().doesFastEntryRendering(); - renderEntries(fastEntryRendering, graphics, mouseX, mouseY, delta); + renderEntries(graphics, mouseX, mouseY, delta); debugger.render(graphics, bounds.x, bounds.y, delta); @@ -215,19 +214,16 @@ public abstract class EntryListWidget extends WidgetWithBounds implements Overla scaleIndicator.update(delta); if (scaleIndicator.value() > 0.04) { - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 500); Component component = Component.literal(Math.round(ConfigObject.getInstance().getEntrySize() * 100) + "%"); int width = font.width(component); int backgroundColor = ((int) Math.round(0xa0 * Mth.clamp(scaleIndicator.value(), 0.0, 1.0))) << 24; int textColor = ((int) Math.round(0xdd * Mth.clamp(scaleIndicator.value(), 0.0, 1.0))) << 24; graphics.fillGradient(bounds.getCenterX() - width / 2 - 2, bounds.getCenterY() - 6, bounds.getCenterX() + width / 2 + 2, bounds.getCenterY() + 6, backgroundColor, backgroundColor); graphics.drawString(font, component, bounds.getCenterX() - width / 2, bounds.getCenterY() - 4, 0xFFFFFF | textColor, false); - graphics.pose().popPose(); } } - protected abstract void renderEntries(boolean fastEntryRendering, GuiGraphics graphics, int mouseX, int mouseY, float delta); + protected abstract void renderEntries(GuiGraphics graphics, int mouseX, int mouseY, float delta); @Override public boolean keyPressed(int keyCode, int scanCode, int modifiers) { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/PaginatedEntryListWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/PaginatedEntryListWidget.java index 00374c47f..66facb832 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/PaginatedEntryListWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/PaginatedEntryListWidget.java @@ -40,15 +40,15 @@ import me.shedaniel.rei.impl.client.ClientHelperImpl; import me.shedaniel.rei.impl.client.config.ConfigManagerImpl; import me.shedaniel.rei.impl.client.gui.InternalTextures; import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl; -import me.shedaniel.rei.impl.client.gui.widget.BatchedEntryRendererManager; import me.shedaniel.rei.impl.client.gui.widget.CachedEntryListRender; import me.shedaniel.rei.impl.client.gui.widget.DefaultDisplayChoosePageWidget; +import me.shedaniel.rei.impl.client.gui.widget.EntryRendererManager; import me.shedaniel.rei.impl.client.gui.widget.EntryWidget; import me.shedaniel.rei.impl.common.entry.type.collapsed.CollapsedStack; import net.minecraft.ChatFormatting; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.network.chat.Component; import net.minecraft.util.Mth; @@ -72,7 +72,7 @@ public class PaginatedEntryListWidget extends CollapsingEntryListWidget { } @Override - protected void renderEntries(boolean fastEntryRendering, GuiGraphics graphics, int mouseX, int mouseY, float delta) { + protected void renderEntries(GuiGraphics graphics, int mouseX, int mouseY, float delta) { this.leftButton.setEnabled(getTotalPages() > 1); this.rightButton.setEnabled(getTotalPages() > 1); @@ -93,19 +93,7 @@ public class PaginatedEntryListWidget extends CollapsingEntryListWidget { } } - BatchedEntryRendererManager<EntryListStackEntry> manager = new BatchedEntryRendererManager<>(); - if (manager.isFastEntryRendering()) { - for (EntryListStackEntry entry : entries) { - CollapsedStack collapsedStack = entry.getCollapsedStack(); - if (collapsedStack != null && !collapsedStack.isExpanded()) { - manager.addSlow(entry); - } else { - manager.add(entry); - } - } - } else { - manager.addAllSlow(entries); - } + EntryRendererManager<EntryListStackEntry> manager = new EntryRendererManager<>(entries); manager.render(debugger.debugTime, debugger.size, debugger.time, graphics, mouseX, mouseY, delta); new CollapsedEntriesBorderRenderer().render(graphics, entries, collapsedStackIndices); @@ -212,10 +200,7 @@ public class PaginatedEntryListWidget extends CollapsingEntryListWidget { this.additionalWidgets.add(leftButton); this.additionalWidgets.add(Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> { Rectangle bounds = leftButton.getBounds(); - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 1); - graphics.blit(RenderType::guiTextured, InternalTextures.ARROW_LEFT_TEXTURE, bounds.x + 4, bounds.y + 4, 0, 0, 8, 8, 8, 8); - graphics.pose().popPose(); + graphics.blit(RenderPipelines.GUI_TEXTURED, InternalTextures.ARROW_LEFT_TEXTURE, bounds.x + 4, bounds.y + 4, 0, 0, 8, 8, 8, 8); })); this.rightButton = Widgets.createButton(new Rectangle(overlayBounds.getMaxX() - 18, overlayBounds.y + (ConfigObject.getInstance().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + 5, 16, 16), Component.translatable("")) .onClick(button -> { @@ -230,10 +215,7 @@ public class PaginatedEntryListWidget extends CollapsingEntryListWidget { this.additionalWidgets.add(rightButton); this.additionalWidgets.add(Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> { Rectangle bounds = rightButton.getBounds(); - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 1); - graphics.blit(RenderType::guiTextured, InternalTextures.ARROW_RIGHT_TEXTURE, bounds.x + 4, bounds.y + 4, 0, 0, 8, 8, 8, 8); - graphics.pose().popPose(); + graphics.blit(RenderPipelines.GUI_TEXTURED, InternalTextures.ARROW_RIGHT_TEXTURE, bounds.x + 4, bounds.y + 4, 0, 0, 8, 8, 8, 8); })); this.additionalWidgets.add(Widgets.createClickableLabel(new Point(overlayBounds.x + (overlayBounds.width / 2), overlayBounds.y + (ConfigObject.getInstance().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + 10), Component.empty(), label -> { if (!Screen.hasShiftDown()) { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/ScrolledEntryListWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/ScrolledEntryListWidget.java index c521a36d9..d771fa6bb 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/ScrolledEntryListWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/ScrolledEntryListWidget.java @@ -33,7 +33,7 @@ import me.shedaniel.clothconfig2.api.scroll.ScrollingContainer; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.REIRuntime; import me.shedaniel.rei.api.common.entry.EntryStack; -import me.shedaniel.rei.impl.client.gui.widget.BatchedEntryRendererManager; +import me.shedaniel.rei.impl.client.gui.widget.EntryRendererManager; import me.shedaniel.rei.impl.client.gui.widget.EntryWidget; import me.shedaniel.rei.impl.common.entry.type.collapsed.CollapsedStack; import net.minecraft.client.gui.GuiGraphics; @@ -62,14 +62,14 @@ public class ScrolledEntryListWidget extends CollapsingEntryListWidget { }; @Override - protected void renderEntries(boolean fastEntryRendering, GuiGraphics graphics, int mouseX, int mouseY, float delta) { + protected void renderEntries(GuiGraphics graphics, int mouseX, int mouseY, float delta) { graphics.enableScissor(bounds.x, bounds.y, bounds.getMaxX(), bounds.getMaxY()); int entrySize = entrySize(); int skip = Math.max(0, Mth.floor(scrolling.scrollAmount() / (float) entrySize)); int nextIndex = skip * innerBounds.width / entrySize; this.blockedCount = 0; - BatchedEntryRendererManager<EntryListStackEntry> helper = new BatchedEntryRendererManager<>(); + EntryRendererManager<EntryListStackEntry> helper = new EntryRendererManager<>(); Int2ObjectMap<CollapsedStack> indexedCollapsedStack = getCollapsedStackIndexed(); int collapsedStacksIndex = 0; Object2IntMap<CollapsedStack> collapsedStackIndices = new Object2IntOpenHashMap<>(); @@ -97,7 +97,7 @@ public class ScrolledEntryListWidget extends CollapsingEntryListWidget { List<EntryStack<?>> ingredient = (List<EntryStack<?>>) stack; if (!ingredient.isEmpty()) { entry.entries(ingredient); - helper.addSlow(entry); + helper.add(entry); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayEntry.java index d9ea0710b..de188e00d 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayEntry.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayEntry.java @@ -44,7 +44,7 @@ import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; import org.jetbrains.annotations.Nullable; -import org.joml.Vector4f; +import org.joml.Vector3f; import java.util.*; import java.util.concurrent.TimeUnit; @@ -171,27 +171,22 @@ public class DisplayEntry extends WidgetWithBounds { return; } - graphics.pose().pushPose(); - if (!stable || !target.equals(bounds)) { - graphics.pose().translate(0, 0, 600); - } - graphics.pose().translate(xOffset(), yOffset(), 0); - graphics.pose().scale(xScale(), yScale(), 1.0F); + graphics.pose().pushMatrix(); + graphics.pose().translate(xOffset(), yOffset()); + graphics.pose().scale(xScale(), yScale()); for (Widget widget : widgets.get()) { widget.render(graphics, transformMouseX(mouseX), transformMouseY(mouseY), delta); } - graphics.pose().popPose(); + graphics.pose().popMatrix(); { - graphics.pose().pushPose(); + graphics.pose().pushMatrix(); if (stable && target.equals(bounds)) { - graphics.pose().translate(this.xOffset, 0, 200); - } else { - graphics.pose().translate(0, 0, 800); + graphics.pose().translate((float) this.xOffset, 0); } - Vector4f mouse = new Vector4f((float) mouseX, (float) mouseY, 0, 1); - graphics.pose().last().pose().transform(mouse); + Vector3f mouse = new Vector3f((float) mouseX, (float) mouseY, 1); + graphics.pose().transform(mouse); AutoCraftingEvaluator.AutoCraftingResult result = this.autoCraftingResult.get(); @@ -202,26 +197,23 @@ public class DisplayEntry extends WidgetWithBounds { if (result.hasApplicable) { plusButton.setText(Component.literal("+")); plusButton.render(graphics, Math.round(mouse.x()), Math.round(mouse.y()), delta); - graphics.pose().popPose(); + graphics.pose().popMatrix(); if (plusButton.containsMouse(Math.round(mouse.x()), Math.round(mouse.y()))) { result.tooltipRenderer.accept(new Point(mouseX, mouseY), Tooltip::queue); } if (result.renderer != null) { - graphics.pose().pushPose(); - if (!stable || !target.equals(bounds)) { - graphics.pose().translate(0, 0, 600); - } - graphics.pose().translate(xOffset(), yOffset(), 0); - graphics.pose().scale(xScale(), yScale(), 1.0F); + graphics.pose().pushMatrix(); + graphics.pose().translate(xOffset(), yOffset()); + graphics.pose().scale(xScale(), yScale()); - Rectangle transformedBounds = MatrixUtils.transform(MatrixUtils.inverse(graphics.pose().last().pose()), getBounds()); + Rectangle transformedBounds = MatrixUtils.transform(MatrixUtils.inverse(graphics.pose()), getBounds()); result.renderer.render(graphics, mouseX, mouseY, delta, widgets.get(), transformedBounds, display); - graphics.pose().popPose(); + graphics.pose().popMatrix(); } } else { - graphics.pose().popPose(); + graphics.pose().popMatrix(); } } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayHistoryWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayHistoryWidget.java index fd7e1d8c9..c5c3a09f6 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayHistoryWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayHistoryWidget.java @@ -23,7 +23,6 @@ package me.shedaniel.rei.impl.client.gui.widget.favorites.history; -import com.mojang.blaze3d.vertex.VertexConsumer; import me.shedaniel.clothconfig2.ClothConfigInitializer; import me.shedaniel.clothconfig2.api.animator.NumberAnimator; import me.shedaniel.clothconfig2.api.animator.ValueAnimator; @@ -45,10 +44,8 @@ import me.shedaniel.rei.impl.client.gui.widget.favorites.FavoritesListWidget; 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.renderer.RenderType; import net.minecraft.util.Mth; import org.jetbrains.annotations.Nullable; -import org.joml.Matrix4f; import java.util.ArrayList; import java.util.Collection; @@ -133,22 +130,12 @@ public class DisplayHistoryWidget extends WidgetWithBounds implements DraggableC if (ConfigObject.getInstance().isReducedMotion()) offset[0] = 0; if (!reverse) offset[0] = 7 - offset[0]; - graphics.drawSpecial(source -> { - VertexConsumer buffer = source.getBuffer(RenderType.gui()); - - float a = (float) (color >> 24 & 255) / 255.0F; - float r = (float) (color >> 16 & 255) / 255.0F; - float g = (float) (color >> 8 & 255) / 255.0F; - float b = (float) (color & 255) / 255.0F; - Matrix4f pose = graphics.pose().last().pose(); - - for (float x = x1 - offset[0]; x < x2; x += 7) { - buffer.addVertex(pose, Mth.clamp(x + 4, x1, x2), y, 0).setColor(r, g, b, a); - buffer.addVertex(pose, Mth.clamp(x, x1, x2), y, 0).setColor(r, g, b, a); - buffer.addVertex(pose, Mth.clamp(x, x1, x2), y + 1, 0).setColor(r, g, b, a); - buffer.addVertex(pose, Mth.clamp(x + 4, x1, x2), y + 1, 0).setColor(r, g, b, a); - } - }); + for (float x = x1 - offset[0]; x < x2; x += 7) { + graphics.pose().pushMatrix(); + graphics.pose().translate(Mth.clamp(x, x1, x2), 0); + graphics.fillGradient(0, y, 4, y + 1, color, color); + graphics.pose().popMatrix(); + } } private void drawVerticalDashedLine(GuiGraphics graphics, int x, int y1, int y2, int color, boolean reverse) { @@ -156,22 +143,12 @@ public class DisplayHistoryWidget extends WidgetWithBounds implements DraggableC if (ConfigObject.getInstance().isReducedMotion()) offset[0] = 0; if (!reverse) offset[0] = 7 - offset[0]; - graphics.drawSpecial(source -> { - VertexConsumer buffer = source.getBuffer(RenderType.gui()); - - float a = (float) (color >> 24 & 255) / 255.0F; - float r = (float) (color >> 16 & 255) / 255.0F; - float g = (float) (color >> 8 & 255) / 255.0F; - float b = (float) (color & 255) / 255.0F; - Matrix4f pose = graphics.pose().last().pose(); - - for (float y = y1 - offset[0]; y < y2; y += 7) { - buffer.addVertex(pose, x + 1, Mth.clamp(y, y1, y2), 0).setColor(r, g, b, a); - buffer.addVertex(pose, x, Mth.clamp(y, y1, y2), 0).setColor(r, g, b, a); - buffer.addVertex(pose, x, Mth.clamp(y + 4, y1, y2), 0).setColor(r, g, b, a); - buffer.addVertex(pose, x + 1, Mth.clamp(y + 4, y1, y2), 0).setColor(r, g, b, a); - } - }); + for (float y = y1 - offset[0]; y < y2; y += 7) { + graphics.pose().pushMatrix(); + graphics.pose().translate(0, Mth.clamp(y, y1, y2)); + graphics.fillGradient(x, 0, x + 1, 4, color, color); + graphics.pose().popMatrix(); + } } private boolean updateBounds(Rectangle fullBounds) { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/FadingFavoritesPanelButton.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/FadingFavoritesPanelButton.java index 0dd9caf7e..1051dc75d 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/FadingFavoritesPanelButton.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/FadingFavoritesPanelButton.java @@ -31,7 +31,6 @@ import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds; import me.shedaniel.rei.impl.client.gui.widget.favorites.FavoritesListWidget; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; -import net.minecraft.client.renderer.MultiBufferSource; import java.util.Collections; import java.util.List; @@ -67,10 +66,7 @@ public abstract class FadingFavoritesPanelButton extends WidgetWithBounds { int buttonColor = 0xFFFFFF | (Math.round(0x74 * alpha.floatValue()) << 24); graphics.fillGradient(bounds.x, bounds.y, bounds.getMaxX(), bounds.getMaxY(), buttonColor, buttonColor); if (isVisible()) { - graphics.drawSpecial(source -> { - renderButtonText(graphics, source); - }); - graphics.flush(); + renderButtonText(graphics); } if (hovered) { queueTooltip(); @@ -79,7 +75,7 @@ public abstract class FadingFavoritesPanelButton extends WidgetWithBounds { protected abstract boolean isAvailable(int mouseX, int mouseY); - protected abstract void renderButtonText(GuiGraphics graphics, MultiBufferSource bufferSource); + protected abstract void renderButtonText(GuiGraphics graphics); @Override public Rectangle getBounds() { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/FavoritesPanel.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/FavoritesPanel.java index 7c276285b..6dbbfcf85 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/FavoritesPanel.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/FavoritesPanel.java @@ -93,14 +93,14 @@ public class FavoritesPanel extends WidgetWithBounds { if (expendState.value()) { graphics.enableScissor(innerBounds.x, innerBounds.y, innerBounds.getMaxX(), innerBounds.getMaxY()); - graphics.pose().pushPose(); - graphics.pose().translate(0, -scroller.scrollAmount(), 0); + graphics.pose().pushMatrix(); + graphics.pose().translate(0, (float) -scroller.scrollAmount()); int y = innerBounds.y; for (FavoritesPanelRow row : rows.get()) { row.render(graphics, innerBounds, innerBounds.x, y, innerBounds.width, row.getRowHeight(), mouseX, mouseY + scroller.scrollAmountInt(), delta); y += row.getRowHeight(); } - graphics.pose().popPose(); + graphics.pose().popMatrix(); graphics.disableScissor(); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/FavoritesTogglePanelButton.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/FavoritesTogglePanelButton.java index 02f1da7d9..db59b7f24 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/FavoritesTogglePanelButton.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/FavoritesTogglePanelButton.java @@ -29,9 +29,7 @@ import me.shedaniel.rei.api.client.REIRuntime; import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; import me.shedaniel.rei.impl.client.gui.widget.favorites.FavoritesListWidget; -import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.network.chat.Component; @SuppressWarnings("UnstableApiUsage") @@ -63,15 +61,21 @@ public class FavoritesTogglePanelButton extends FadingFavoritesPanelButton { } @Override - protected void renderButtonText(GuiGraphics graphics, MultiBufferSource bufferSource) { + protected void renderButtonText(GuiGraphics graphics) { float expendProgress = (float) parent.favoritePanel.expendState.progress(); if (expendProgress < .9f) { int textColor = 0xFFFFFF | (Math.round(0xFF * alpha.floatValue() * (1 - expendProgress)) << 24); - font.drawInBatch("+", bounds.getCenterX() - 2.5f, bounds.getCenterY() - 3, textColor, false, graphics.pose().last().pose(), bufferSource, Font.DisplayMode.NORMAL, 0, 15728880); + graphics.pose().pushMatrix(); + graphics.pose().translate(bounds.getCenterX() - 2.5f, bounds.getCenterY() - 3); + graphics.drawString(font, "+", 0, 0, textColor, false); + graphics.pose().popMatrix(); } if (expendProgress > .1f) { int textColor = 0xFFFFFF | (Math.round(0xFF * alpha.floatValue() * expendProgress) << 24); - font.drawInBatch("+", bounds.getCenterX() - 2.5f, bounds.getCenterY() - 3, textColor, false, graphics.pose().last().pose(), bufferSource, Font.DisplayMode.NORMAL, 0, 15728880); + graphics.pose().pushMatrix(); + graphics.pose().translate(bounds.getCenterX() - 2.5f, bounds.getCenterY() - 3); + graphics.drawString(font, "+", 0, 0, textColor, false); + graphics.pose().popMatrix(); } } }
\ No newline at end of file diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelEntriesRow.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelEntriesRow.java index 3e05d53f5..d2a7bb14a 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelEntriesRow.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelEntriesRow.java @@ -23,7 +23,6 @@ package me.shedaniel.rei.impl.client.gui.widget.favorites.panel.rows; -import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.clothconfig2.api.animator.NumberAnimator; import me.shedaniel.clothconfig2.api.animator.ValueAnimator; import me.shedaniel.math.FloatingPoint; @@ -86,7 +85,6 @@ public class FavoritesPanelEntriesRow extends FavoritesPanelRow { public void render(GuiGraphics graphics, Rectangle innerBounds, int x, int y, int rowWidth, int rowHeight, int mouseX, int mouseY, float delta) { this.lastY = y; int entrySize = entrySize(); - boolean fastEntryRendering = ConfigObject.getInstance().doesFastEntryRendering(); updateEntriesPosition(entry -> !ConfigObject.getInstance().isReducedMotion()); for (SectionFavoriteWidget widget : widgets) { widget.update(delta); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/hint/HintWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/hint/HintWidget.java index 6d0edac41..6e10ab94e 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/hint/HintWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/hint/HintWidget.java @@ -23,7 +23,6 @@ package me.shedaniel.rei.impl.client.gui.widget.hint; -import com.mojang.blaze3d.systems.RenderSystem; import me.shedaniel.clothconfig2.ClothConfigInitializer; import me.shedaniel.clothconfig2.api.animator.NumberAnimator; import me.shedaniel.clothconfig2.api.animator.ValueAnimator; @@ -116,23 +115,19 @@ public class HintWidget extends WidgetWithBounds { this.scroll.setTarget(ScrollingContainer.handleBounceBack(scroll.target(), this.contentHeight - (this.bounds.height - 8 - 9) - 9, delta, .08)); this.scroll.update(delta); - graphics.pose().pushPose(); int background = 0xf0100010; int color1 = 0x505000ff; int color2 = color1; int x = this.bounds.x, y = this.bounds.y, width = this.bounds.width, height = this.bounds.height; - graphics.fillGradient(x, y - 1, x + width, y, 400, background, background); - graphics.fillGradient(x, y + height, x + width, y + height + 1, 400, background, background); - graphics.fillGradient(x, y, x + width, y + height, 400, background, background); - graphics.fillGradient(x - 1, y, x, y + height, 400, background, background); - graphics.fillGradient(x + width, y, x + width + 1, y + height, 400, background, background); - graphics.fillGradient(x, y + 1, x + 1, y + height - 1, 400, color1, color2); - graphics.fillGradient(x + width - 1, y + 1, x + width, y + height - 1, 400, color1, color2); - graphics.fillGradient(x, y, x + width, y + 1, 400, color1, color1); - graphics.fillGradient(x, y + height - 1, x + width, y + height, 400, color2, color2); - graphics.pose().popPose(); - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 450); + graphics.fillGradient(x, y - 1, x + width, y, background, background); + graphics.fillGradient(x, y + height, x + width, y + height + 1, background, background); + graphics.fillGradient(x, y, x + width, y + height, background, background); + graphics.fillGradient(x - 1, y, x, y + height, background, background); + graphics.fillGradient(x + width, y, x + width + 1, y + height, background, background); + graphics.fillGradient(x, y + 1, x + 1, y + height - 1, color1, color2); + graphics.fillGradient(x + width - 1, y + 1, x + width, y + height - 1, color1, color2); + graphics.fillGradient(x, y, x + width, y + 1, color1, color1); + graphics.fillGradient(x, y + height - 1, x + width, y + height, color2, color2); int lineY = y + 4; try (CloseableScissors scissors = Widget.scissor(graphics, new Rectangle(x + 4, y + 4, width - 8, height - 8 - 9 - 2))) { @@ -155,8 +150,6 @@ public class HintWidget extends WidgetWithBounds { } graphics.drawString(font, okay, this.okayBounds.x, this.okayBounds.y, 0xFF999999); - graphics.pose().popPose(); - if (this.bounds.contains(mouseX, mouseY)) { ScreenOverlayImpl.getInstance().clearTooltips(); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/region/EntryStacksRegionWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/region/EntryStacksRegionWidget.java index 1efa977a5..7ce7f5aba 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/region/EntryStacksRegionWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/region/EntryStacksRegionWidget.java @@ -46,7 +46,7 @@ import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds; import me.shedaniel.rei.api.common.entry.EntrySerializer; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.util.CollectionUtils; -import me.shedaniel.rei.impl.client.gui.widget.BatchedEntryRendererManager; +import me.shedaniel.rei.impl.client.gui.widget.EntryRendererManager; import me.shedaniel.rei.impl.client.gui.widget.EntryWidget; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; @@ -108,7 +108,6 @@ public class EntryStacksRegionWidget<T extends RegionEntry<T>> extends WidgetWit if (bounds.isEmpty()) return; int entrySize = entrySize(); - boolean fastEntryRendering = ConfigObject.getInstance().doesFastEntryRendering(); updateEntriesPosition(entry -> true); for (RealRegionEntry<T> entry : entries.values()) { entry.update(delta); @@ -130,7 +129,7 @@ public class EntryStacksRegionWidget<T extends RegionEntry<T>> extends WidgetWit Stream<RegionEntryWidget<T>> entryStream = this.entriesList.stream() .filter(entry -> entry.getBounds().getMaxY() >= this.bounds.getY() && entry.getBounds().y <= this.bounds.getMaxY()); - new BatchedEntryRendererManager<>(entryStream.collect(Collectors.toList())) + new EntryRendererManager<>(entryStream.collect(Collectors.toList())) .render(graphics, mouseX, mouseY, delta); updatePosition(delta); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/region/RegionEntryWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/region/RegionEntryWidget.java index 8d0732c07..42d5b08cb 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/region/RegionEntryWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/region/RegionEntryWidget.java @@ -23,7 +23,6 @@ package me.shedaniel.rei.impl.client.gui.widget.region; -import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.math.FloatingPoint; import me.shedaniel.math.Point; import me.shedaniel.rei.api.client.REIRuntime; @@ -35,7 +34,7 @@ import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl; import me.shedaniel.rei.impl.client.gui.modules.MenuAccess; import me.shedaniel.rei.impl.client.gui.widget.DisplayedEntryWidget; import net.minecraft.client.gui.GuiGraphics; -import org.joml.Vector4f; +import org.joml.Vector3f; import java.util.Collection; import java.util.Optional; @@ -79,9 +78,9 @@ public class RegionEntryWidget<T extends RegionEntry<T>> extends DisplayedEntryW access.openOrClose(uuid, getBounds(), menuEntries.get()); } - Vector4f vector4f = new Vector4f(mouseX, mouseY, 0, 1.0F); - graphics.pose().last().pose().transform(vector4f); - super.render(graphics, (int) vector4f.x(), (int) vector4f.y(), delta); + Vector3f vector3f = new Vector3f(mouseX, mouseY, 1); + graphics.pose().transform(vector3f); + super.render(graphics, (int) vector3f.x(), (int) vector3f.y(), delta); } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/region/RegionRenderingDebugger.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/region/RegionRenderingDebugger.java index fd542353e..b74fe259f 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/region/RegionRenderingDebugger.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/region/RegionRenderingDebugger.java @@ -29,7 +29,6 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.mutable.MutableLong; -import org.joml.Matrix4f; public class RegionRenderingDebugger { public boolean debugTime; @@ -60,13 +59,7 @@ public class RegionRenderingDebugger { Component debugText = Component.literal(String.format("%d entries, avg. %.0fns, ttl. %.2fms, %s fps", size.getValue(), lastAverageDebugTime, lastTotalDebugTime, minecraft.fpsString.split(" ")[0])); int stringWidth = font.width(debugText); graphics.fillGradient(Math.min(x, minecraft.screen.width - stringWidth - 2), y, x + stringWidth + 2, y + font.lineHeight + 2, -16777216, -16777216); - graphics.pose().pushPose(); - graphics.pose().translate(0.0D, 0.0D, 500.0D); - graphics.drawSpecial(source -> { - Matrix4f matrix = graphics.pose().last().pose(); - font.drawInBatch(debugText.getVisualOrderText(), Math.min(x + 2, minecraft.screen.width - stringWidth), y + 2, -1, false, matrix, source, Font.DisplayMode.NORMAL, 0, 15728880); - }); - graphics.pose().popPose(); + graphics.drawString(font, debugText, Math.min(x + 2, minecraft.screen.width - stringWidth), y + 2, -1, false); } this.size.setValue(0); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/search/OverlaySearchField.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/search/OverlaySearchField.java index 5758109fe..fb15fcfb5 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/search/OverlaySearchField.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/search/OverlaySearchField.java @@ -194,27 +194,26 @@ public class OverlaySearchField extends TextFieldWidget implements TextFieldWidg int background = 0xf0100010; int color1 = color.getColor(); int color2 = color.darker(2).getColor(); - if (!top) graphics.fillGradient(x, y - 1, x + width, y, 400, background, background); + if (!top) graphics.fillGradient(x, y - 1, x + width, y, background, background); if (top) - graphics.fillGradient(x, y + height, x + width, y + height + 1, 400, background, background); - graphics.fillGradient(x, y, x + width, y + height, 400, background, background); - graphics.fillGradient(x - 1, y, x, y + height, 400, background, background); - graphics.fillGradient(x + width, y, x + width + 1, y + height, 400, background, background); - graphics.fillGradient(x, y + 1, x + 1, y + height - 1, 400, color1, color2); - graphics.fillGradient(x + width - 1, y + 1, x + width, y + height - 1, 400, color1, color2); - if (!top) graphics.fillGradient(x, y, x + width, y + 1, 400, color1, color1); - if (top) graphics.fillGradient(x, y + height - 1, x + width, y + height, 400, color2, color2); + graphics.fillGradient(x, y + height, x + width, y + height + 1, background, background); + graphics.fillGradient(x, y, x + width, y + height, background, background); + graphics.fillGradient(x - 1, y, x, y + height, background, background); + graphics.fillGradient(x + width, y, x + width + 1, y + height, background, background); + graphics.fillGradient(x, y + 1, x + 1, y + height - 1, color1, color2); + graphics.fillGradient(x + width - 1, y + 1, x + width, y + height - 1, color1, color2); + if (!top) graphics.fillGradient(x, y, x + width, y + 1, color1, color1); + if (top) graphics.fillGradient(x, y + height - 1, x + width, y + height, color2, color2); if (hasProgress) { int progressWidth = (int) Math.round(width * this.progress.doubleValue()); - graphics.fillGradient(x + 1, y + height - 3, x + progressWidth - 1, y + height - 1, 400, 0xffffffff, 0xffffffff); + graphics.fillGradient(x + 1, y + height - 3, x + progressWidth - 1, y + height - 1, 0xffffffff, 0xffffffff); } - graphics.pose().pushPose(); - graphics.pose().translate(0.0D, 0.0D, 450.0D); for (int i = 0; i < sequences.size(); i++) { Pair<HintProvider, FormattedCharSequence> pair = sequences.get(i); - int lineWidth = graphics.drawString(font, pair.getSecond(), x + 3, y + 3 + font.lineHeight * i, -1); + graphics.drawString(font, pair.getSecond(), x + 3, y + 3 + font.lineHeight * i, -1); + int lineWidth = font.width(pair.getSecond()); if (new Rectangle(x + 3, y + 3 + font.lineHeight * i, lineWidth, font.lineHeight).contains(mouseX, mouseY)) { Tooltip tooltip = pair.getFirst().provideTooltip(new Point(mouseX, mouseY)); if (tooltip != null) { @@ -240,8 +239,6 @@ public class OverlaySearchField extends TextFieldWidget implements TextFieldWidg button.action().accept(bounds); } } - - graphics.pose().popPose(); } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/screen/DefaultScreenOverlayRenderer.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/screen/DefaultScreenOverlayRenderer.java index e6117c148..b9d04965d 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/screen/DefaultScreenOverlayRenderer.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/screen/DefaultScreenOverlayRenderer.java @@ -23,8 +23,6 @@ package me.shedaniel.rei.impl.client.registry.screen; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; import dev.architectury.event.EventResult; import dev.architectury.event.events.client.ClientGuiEvent; import me.shedaniel.rei.api.client.gui.screen.DisplayScreen; @@ -97,20 +95,15 @@ public enum DefaultScreenOverlayRenderer implements OverlayRendererProvider { return; rendered[0] = 2; resetFocused(screen); - graphics.pose().pushPose(); - graphics.pose().translate(-screen.leftPos, -screen.topPos, 0.0); - sink.lateRender(graphics, mouseX, mouseY, delta); - graphics.pose().popPose(); - resetFocused(screen); }; this.renderPost = (screen, graphics, mouseX, mouseY, delta) -> { - if (shouldReturn(screen) || rendered[0] == 2) + if (shouldReturn(screen)) return; - if (screen instanceof AbstractContainerScreen) { + if (screen instanceof AbstractContainerScreen && rendered[0] < 2) { InternalLogger.getInstance().warn("Screen " + screen.getClass().getName() + " did not render background and foreground! This might cause rendering issues!"); } resetFocused(screen); - if (rendered[0] == 0 && !(screen instanceof DisplayScreen)) { + if (rendered[0] == 0 && !(screen instanceof DisplayScreen) && (!(screen instanceof AbstractContainerScreen) || rendered[0] < 2)) { sink.render(graphics, mouseX, mouseY, delta.getRealtimeDeltaTicks()); } rendered[0] = 1; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/transfer/MissingStacksTooltip.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/transfer/MissingStacksTooltip.java index 76b8949b6..238127e81 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/transfer/MissingStacksTooltip.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/transfer/MissingStacksTooltip.java @@ -32,11 +32,9 @@ import net.minecraft.ChatFormatting; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; -import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.network.chat.Component; import net.minecraft.util.Mth; import net.minecraft.world.inventory.tooltip.TooltipComponent; -import org.joml.Matrix4f; import java.util.List; @@ -72,17 +70,13 @@ public class MissingStacksTooltip implements ClientTooltipComponent, TooltipComp int entrySize = EntryListWidget.entrySize(); int w = Math.max(1, MAX_WIDTH / entrySize); int i = 0; - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 50); for (EntryIngredient entry : stacks) { int x1 = x + (i % w) * entrySize; int y1 = y + 13 + (i / w) * entrySize; i++; if (i / w > 5) { Component text = Component.literal("+" + (stacks.size() - w * 6 + 1)).withStyle(ChatFormatting.GRAY); - graphics.drawSpecial(source -> { - font.drawInBatch(text, x1 + entrySize / 2 - font.width(text) / 2, y1 + entrySize / 2 - 1, -1, true, graphics.pose().last().pose(), source, Font.DisplayMode.NORMAL, 0, 15728880); - }); + graphics.drawString(font, text, x1 + entrySize / 2 - font.width(text) / 2, y1 + entrySize / 2 - 1, -1); break; } else { EntryStack<?> stack; @@ -92,12 +86,10 @@ public class MissingStacksTooltip implements ClientTooltipComponent, TooltipComp stack.render(graphics, new Rectangle(x1, y1, entrySize, entrySize), -1000, -1000, 0); } } - graphics.pose().popPose(); } @Override - public void renderText(Font font, int x, int y, Matrix4f pose, MultiBufferSource.BufferSource buffers) { - font.drawInBatch(Component.translatable("text.rei.missing").withStyle(ChatFormatting.GRAY), - x, y + 2, -1, true, pose, buffers, Font.DisplayMode.NORMAL, 0, 15728880); + public void renderText(GuiGraphics graphics, Font font, int x, int y) { + graphics.drawString(font, Component.translatable("text.rei.missing").withStyle(ChatFormatting.GRAY), x, y + 2, -1); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/FluidEntryDefinition.java b/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/FluidEntryDefinition.java index d217e1000..4b0ec51d3 100644 --- a/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/FluidEntryDefinition.java +++ b/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/FluidEntryDefinition.java @@ -32,11 +32,9 @@ import dev.architectury.platform.Platform; import dev.architectury.utils.Env; import dev.architectury.utils.EnvExecutor; import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.client.entry.renderer.BatchedEntryRenderer; import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; import me.shedaniel.rei.api.client.gui.widgets.TooltipContext; -import me.shedaniel.rei.api.client.util.SpriteRenderer; import me.shedaniel.rei.api.common.display.basic.BasicDisplay; import me.shedaniel.rei.api.common.entry.EntrySerializer; import me.shedaniel.rei.api.common.entry.EntryStack; @@ -52,10 +50,7 @@ import net.minecraft.CrashReport; import net.minecraft.CrashReportCategory; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite; -import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.language.I18n; @@ -68,7 +63,6 @@ import net.minecraft.network.chat.Component; import net.minecraft.network.codec.StreamCodec; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; -import net.minecraft.util.Mth; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.material.FlowingFluid; @@ -213,56 +207,17 @@ public class FluidEntryDefinition implements EntryDefinition<FluidStack>, EntryS } @Environment(EnvType.CLIENT) - public static class FluidEntryRenderer implements BatchedEntryRenderer<FluidStack, TextureAtlasSprite> { + public static class FluidEntryRenderer implements EntryRenderer<FluidStack> { private static final Supplier<TextureAtlasSprite> MISSING_SPRITE = Suppliers.memoize(() -> { TextureAtlas atlas = Minecraft.getInstance().getModelManager().getAtlas(TextureAtlas.LOCATION_BLOCKS); return atlas.getSprite(MissingTextureAtlasSprite.getLocation()); }); - @Override - public TextureAtlasSprite getExtraData(EntryStack<FluidStack> entry) { - FluidStack stack = entry.getValue(); - if (stack.isEmpty()) return null; - return FluidStackHooks.getStillTexture(stack); - } - private TextureAtlasSprite missingTexture() { return MISSING_SPRITE.get(); } @Override - public int getBatchIdentifier(EntryStack<FluidStack> entry, Rectangle bounds, TextureAtlasSprite extraData) { - return 0; - } - - @Override - public void startBatch(EntryStack<FluidStack> entry, TextureAtlasSprite extraData, GuiGraphics graphics, float delta) {} - - @Override - public void renderBase(EntryStack<FluidStack> entry, TextureAtlasSprite sprite, GuiGraphics graphics, MultiBufferSource.BufferSource immediate, Rectangle bounds, int mouseX, int mouseY, float delta) { - TextureAtlasSprite s = sprite == null ? missingTexture() : sprite; - SpriteRenderer.beginPass() - .setup(immediate, RenderType.solid()) - .sprite(s) - .color(sprite == null ? 0xFFFFFF : FluidStackHooks.getColor(entry.getValue())) - .light(0x00f000f0) - .overlay(OverlayTexture.NO_OVERLAY) - .alpha(0xff) - .normal(graphics.pose().last().normal(), 0, 0, 0) - .position(graphics.pose().last().pose(), bounds.x, bounds.getMaxY() - bounds.height * Mth.clamp(entry.get(EntryStack.Settings.FLUID_RENDER_RATIO), 0, 1), bounds.getMaxX(), bounds.getMaxY(), 0) - .next(s.atlasLocation()); - } - - @Override - public void afterBase(EntryStack<FluidStack> entry, TextureAtlasSprite extraData, GuiGraphics graphics, float delta) {} - - @Override - public void renderOverlay(EntryStack<FluidStack> entry, TextureAtlasSprite extraData, GuiGraphics graphics, MultiBufferSource.BufferSource immediate, Rectangle bounds, int mouseX, int mouseY, float delta) {} - - @Override - public void endBatch(EntryStack<FluidStack> entry, TextureAtlasSprite extraData, GuiGraphics graphics, float delta) {} - - @Override public void render(EntryStack<FluidStack> entry, GuiGraphics graphics, Rectangle bounds, int mouseX, int mouseY, float delta) { FluidStack stack = entry.getValue(); if (stack.isEmpty()) return; @@ -270,20 +225,16 @@ public class FluidEntryDefinition implements EntryDefinition<FluidStack>, EntryS if (sprite == null) return; int color = FluidStackHooks.getColor(stack); - MultiBufferSource.BufferSource immediate = graphics.bufferSource; - - SpriteRenderer.beginPass() + /*SpriteRenderer.beginPass() .setup(immediate, RenderType.solid()) .sprite(sprite) .color(color) .light(0x00f000f0) .overlay(OverlayTexture.NO_OVERLAY) .alpha(0xff) - .normal(graphics.pose().last().normal(), 0, 0, 0) - .position(graphics.pose().last().pose(), bounds.x, bounds.getMaxY() - bounds.height * Mth.clamp(entry.get(EntryStack.Settings.FLUID_RENDER_RATIO), 0, 1), bounds.getMaxX(), bounds.getMaxY(), 0) - .next(TextureAtlas.LOCATION_BLOCKS); - - immediate.endBatch(); + .normal(graphics.pose(), 0, 0, 0) + .position(graphics.pose(), bounds.x, bounds.getMaxY() - bounds.height * Mth.clamp(entry.get(EntryStack.Settings.FLUID_RENDER_RATIO), 0, 1), bounds.getMaxX(), bounds.getMaxY(), 0) + .next(TextureAtlas.LOCATION_BLOCKS);*/ } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/ItemEntryDefinition.java b/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/ItemEntryDefinition.java index 74e2f7870..b046e6e86 100644 --- a/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/ItemEntryDefinition.java +++ b/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/ItemEntryDefinition.java @@ -24,8 +24,6 @@ package me.shedaniel.rei.plugin.client.entry; import com.google.common.collect.Lists; -import com.mojang.blaze3d.platform.Lighting; -import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.serialization.Codec; import dev.architectury.hooks.item.ItemStackHooks; import dev.architectury.utils.Env; @@ -33,7 +31,6 @@ import dev.architectury.utils.EnvExecutor; import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; import it.unimi.dsi.fastutil.objects.ReferenceSet; import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.client.entry.renderer.BatchedEntryRenderer; import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; import me.shedaniel.rei.api.client.gui.widgets.TooltipContext; @@ -51,9 +48,6 @@ import net.minecraft.CrashReport; import net.minecraft.CrashReportCategory; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.item.ItemStackRenderState; -import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.resources.language.I18n; import net.minecraft.core.component.DataComponentPatch; import net.minecraft.core.component.DataComponents; @@ -68,11 +62,9 @@ import net.minecraft.tags.TagKey; import net.minecraft.world.inventory.tooltip.TooltipComponent; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemDisplayContext; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.Nullable; -import org.joml.Matrix4f; -import org.joml.Matrix4fStack; +import org.joml.Matrix3x2f; import java.util.List; import java.util.Optional; @@ -243,112 +235,26 @@ public class ItemEntryDefinition implements EntryDefinition<ItemStack>, EntrySer } @Environment(EnvType.CLIENT) - public class ItemEntryRenderer implements BatchedEntryRenderer<ItemStack, ItemStackRenderState> { + public class ItemEntryRenderer implements EntryRenderer<ItemStack> { private static final float SCALE = 20.0F; public static final int ITEM_LIGHT = 0xf000f0; @Override - public ItemStackRenderState getExtraData(EntryStack<ItemStack> entry) { - Minecraft minecraft = Minecraft.getInstance(); - ItemStackRenderState renderState = new ItemStackRenderState(); - minecraft.getItemModelResolver().updateForTopItem(renderState, entry.getValue(), ItemDisplayContext.GUI, minecraft.level, minecraft.player, 0); - return renderState; - } - - @Override public void render(EntryStack<ItemStack> entry, GuiGraphics graphics, Rectangle bounds, int mouseX, int mouseY, float delta) { if (!entry.isEmpty()) { ItemStack value = entry.getValue(); - ItemStackRenderState renderState = getExtraData(entry); - setupGL(entry, renderState); - graphics.pose().pushPose(); - graphics.pose().translate(bounds.getCenterX(), bounds.getCenterY(), 0); - graphics.pose().mulPose(new Matrix4f().scaling(1.0F, -1.0F, 1.0F)); - graphics.pose().scale(bounds.getWidth(), bounds.getHeight(), (bounds.getWidth() + bounds.getHeight()) / 2.0F); - MultiBufferSource.BufferSource immediate = graphics.bufferSource; - renderState.render(graphics.pose(), immediate, ITEM_LIGHT, OverlayTexture.NO_OVERLAY); - immediate.endBatch(); - graphics.pose().popPose(); - - Matrix4fStack modelViewStack = RenderSystem.getModelViewStack(); - modelViewStack.pushMatrix(); - modelViewStack.mul(graphics.pose().last().pose()); - modelViewStack.translate(bounds.x, bounds.y, 0); - modelViewStack.scale(bounds.width / 16f, (bounds.getWidth() + bounds.getHeight()) / 2f / 16f, 1.0F); - graphics.drawSpecial(source -> { - if (source instanceof MultiBufferSource.BufferSource multiBufferSource) { - renderOverlay(new GuiGraphics(Minecraft.getInstance(), multiBufferSource), entry, bounds); - } - }); - modelViewStack.popMatrix(); - endGL(entry, renderState); - } - } - - @Override - public int getBatchIdentifier(EntryStack<ItemStack> entry, Rectangle bounds, ItemStackRenderState renderState) { - return 1738923 + (renderState.usesBlockLight() ? 1 : 0); - } - - @Override - public void startBatch(EntryStack<ItemStack> entry, ItemStackRenderState renderState, GuiGraphics graphics, float delta) { - setupGL(entry, renderState); - } - - public void setupGL(EntryStack<ItemStack> entry, ItemStackRenderState renderState) { - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - boolean sideLit = renderState.usesBlockLight(); - if (!sideLit) Lighting.setupForFlatItems(); - } - - @Override - public void renderBase(EntryStack<ItemStack> entry, ItemStackRenderState renderState, GuiGraphics graphics, MultiBufferSource.BufferSource immediate, Rectangle bounds, int mouseX, int mouseY, float delta) { - if (!entry.isEmpty()) { - ItemStack value = entry.getValue(); - graphics.pose().pushPose(); - graphics.pose().translate(bounds.getCenterX(), bounds.getCenterY(), 0); - graphics.pose().scale(bounds.getWidth(), (bounds.getWidth() + bounds.getHeight()) / -2f, (bounds.getWidth() + bounds.getHeight()) / 2f); - renderState.render(graphics.pose(), immediate, ITEM_LIGHT, OverlayTexture.NO_OVERLAY); - graphics.pose().popPose(); - } - } - - @Override - public void afterBase(EntryStack<ItemStack> entry, ItemStackRenderState renderState, GuiGraphics graphics, float delta) { - endGL(entry, renderState); - } - - @Override - public void renderOverlay(EntryStack<ItemStack> entry, ItemStackRenderState renderState, GuiGraphics graphics, MultiBufferSource.BufferSource immediate, Rectangle bounds, int mouseX, int mouseY, float delta) { - Matrix4fStack modelViewStack = RenderSystem.getModelViewStack(); - modelViewStack.pushMatrix(); - modelViewStack.mul(graphics.pose().last().pose()); - modelViewStack.translate(bounds.x, bounds.y, 0); - modelViewStack.scale(bounds.width / 16f, (bounds.getWidth() + bounds.getHeight()) / 2f / 16f, 1.0F); - graphics.drawSpecial(source -> { - if (source instanceof MultiBufferSource.BufferSource multiBufferSource) { - renderOverlay(new GuiGraphics(Minecraft.getInstance(), multiBufferSource), entry, bounds); + graphics.pose().pushMatrix(); + graphics.pose().translate(bounds.x, bounds.y); + graphics.pose().scale(bounds.getWidth() / 16f, bounds.getHeight() / 16f); + graphics.renderItem(value, 0, 0); + if (!value.isEmpty()) { + graphics.renderItemDecorations(Minecraft.getInstance().font, value, 0, 0); } - }); - modelViewStack.popMatrix(); - } - - public void renderOverlay(GuiGraphics graphics, EntryStack<ItemStack> entry, Rectangle bounds) { - if (!entry.isEmpty()) { - graphics.renderItemDecorations(Minecraft.getInstance().font, entry.getValue(), 0, 0, null); + graphics.pose().popMatrix(); } } @Override - public void endBatch(EntryStack<ItemStack> entry, ItemStackRenderState renderState, GuiGraphics graphics, float delta) { - } - - public void endGL(EntryStack<ItemStack> entry, ItemStackRenderState renderState) { - boolean sideLit = renderState.usesBlockLight(); - if (!sideLit) Lighting.setupFor3DItems(); - } - - @Override @Nullable public Tooltip getTooltip(EntryStack<ItemStack> entry, TooltipContext context) { if (entry.isEmpty()) diff --git a/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/DefaultClientRuntimePlugin.java b/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/DefaultClientRuntimePlugin.java index a066e7afa..8a3cb8db5 100644 --- a/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/DefaultClientRuntimePlugin.java +++ b/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/DefaultClientRuntimePlugin.java @@ -79,7 +79,7 @@ import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.Tag; @@ -118,7 +118,7 @@ public class DefaultClientRuntimePlugin implements REIClientPlugin { @Override public void render(GuiGraphics graphics, Rectangle bounds, int mouseX, int mouseY, float delta) { - graphics.innerBlit(RenderType::guiTextured, id, bounds.x, bounds.getMaxX(), bounds.y, bounds.getMaxY(), 0, 0, 1, 0, 1); + graphics.innerBlit(RenderPipelines.GUI_TEXTURED, id, bounds.x, bounds.getMaxX(), bounds.y, bounds.getMaxY(), 0, 0, 1, 0, 1); } @Override @@ -361,17 +361,17 @@ public class DefaultClientRuntimePlugin implements REIClientPlugin { return new Renderer() { @Override public void render(GuiGraphics graphics, Rectangle bounds, int mouseX, int mouseY, float delta) { - graphics.pose().pushPose(); - graphics.pose().translate(bounds.getX(), bounds.getY(), 1); - graphics.pose().scale(bounds.width / (float) panel.getBounds().getWidth(), bounds.height / (float) panel.getBounds().getHeight(), 1); + graphics.pose().pushMatrix(); + graphics.pose().translate(bounds.getX(), bounds.getY()); + graphics.pose().scale(bounds.width / (float) panel.getBounds().getWidth(), bounds.height / (float) panel.getBounds().getHeight()); panel.render(graphics, mouseX, mouseY, delta); - graphics.pose().popPose(); + graphics.pose().popMatrix(); if (bounds.width > 4 && bounds.height > 4) { - graphics.pose().pushPose(); - graphics.pose().translate(0, 0.5, 0); + graphics.pose().pushMatrix(); + graphics.pose().translate(0, 0.5f); slot.getBounds().setBounds(bounds.x + 2, bounds.y + 2, bounds.width - 4, bounds.height - 4); slot.render(graphics, mouseX, mouseY, delta); - graphics.pose().popPose(); + graphics.pose().popMatrix(); } } |
