Skip to content

Commit bbf4c43

Browse files
authored
Port to 1.21.6 (#1907)
* Port to 1.21.6 * Fix tooltip Z-rendering * Fix config screen * Add workflow
1 parent 3224ded commit bbf4c43

File tree

126 files changed

+681
-1506
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+681
-1506
lines changed

.github/workflows/curseforge.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ on:
2323
- 17.x-1.21.2
2424
- 18.x-1.21.4
2525
- 19.x-1.21.5
26+
- 20.x-1.21.6
2627

2728
jobs:
2829
build:

api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,6 @@ static ConfigObject getInstance() {
115115
*/
116116
boolean isGrabbingItems();
117117

118-
/**
119-
* Returns whether favorites motions are animated.
120-
*
121-
* @return whether favorites motions are animated
122-
*/
123-
@Deprecated(forRemoval = true)
124-
boolean isFavoritesAnimated();
125-
126118
/**
127119
* Returns whether motions are reduced.
128120
*
@@ -281,8 +273,6 @@ default boolean isLeftHandSidePanel() {
281273
@ApiStatus.Experimental
282274
boolean doDisplayIMEHints();
283275

284-
boolean doesFastEntryRendering();
285-
286276
boolean doesCacheEntryRendering();
287277

288278
@ApiStatus.Experimental

api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/BatchedEntryRenderer.java

Lines changed: 0 additions & 117 deletions
This file was deleted.

api/src/main/java/me/shedaniel/rei/api/client/favorites/CompoundFavoriteRenderer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,13 @@ public CompoundFavoriteRenderer(boolean showcase, int count, IntFunction<Rendere
9090
public void render(GuiGraphics graphics, Rectangle bounds, int mouseX, int mouseY, float delta) {
9191
updateAnimator(delta);
9292
graphics.enableScissor(bounds.x, bounds.y, bounds.getMaxX(), bounds.getMaxY());
93-
graphics.pose().pushPose();
94-
graphics.pose().translate(0, this.offset.floatValue() * -bounds.getHeight(), 0);
93+
graphics.pose().pushMatrix();
94+
graphics.pose().translate(0, this.offset.floatValue() * -bounds.getHeight());
9595
for (int i = 0; i < count; i++) {
9696
renderers.apply(i).render(graphics, bounds, mouseX, mouseY, delta);
97-
graphics.pose().translate(0, bounds.height, 0);
97+
graphics.pose().translate(0, bounds.height);
9898
}
99-
graphics.pose().popPose();
99+
graphics.pose().popMatrix();
100100
graphics.disableScissor();
101101
}
102102

api/src/main/java/me/shedaniel/rei/api/client/gui/SimpleDisplayRenderer.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import me.shedaniel.rei.api.common.util.EntryStacks;
3737
import net.minecraft.client.gui.GuiGraphics;
3838
import net.minecraft.client.gui.components.events.GuiEventListener;
39-
import net.minecraft.client.renderer.RenderType;
39+
import net.minecraft.client.renderer.RenderPipelines;
4040
import net.minecraft.resources.ResourceLocation;
4141
import net.minecraft.util.Mth;
4242
import org.jetbrains.annotations.ApiStatus;
@@ -120,8 +120,6 @@ public void render(GuiGraphics graphics, Rectangle bounds, int mouseX, int mouse
120120
int xx = bounds.x + 4, yy = bounds.y + 2;
121121
int j = 0;
122122
int itemsPerLine = getItemsPerLine();
123-
graphics.pose().pushPose();
124-
graphics.pose().translate(0, 0, 50);
125123
for (Slot entryWidget : inputWidgets) {
126124
entryWidget.getBounds().setLocation(xx, yy);
127125
entryWidget.render(graphics, mouseX, mouseY, delta);
@@ -133,20 +131,16 @@ public void render(GuiGraphics graphics, Rectangle bounds, int mouseX, int mouse
133131
j = 0;
134132
}
135133
}
136-
graphics.pose().popPose();
137134
xx = bounds.x + 4 + 18 * (getItemsPerLine() - 2);
138135
yy = bounds.y + getHeight() / 2 - 8;
139-
graphics.blit(RenderType::guiTextured, CHEST_GUI_TEXTURE, xx, yy, 0, 28, 18, 18, 256, 256);
136+
graphics.blit(RenderPipelines.GUI_TEXTURED, CHEST_GUI_TEXTURE, xx, yy, 0, 28, 18, 18, 256, 256);
140137
xx += 18;
141138
yy += outputWidgets.size() * -9 + 9;
142-
graphics.pose().pushPose();
143-
graphics.pose().translate(0, 0, 50);
144139
for (Slot outputWidget : outputWidgets) {
145140
outputWidget.getBounds().setLocation(xx, yy);
146141
outputWidget.render(graphics, mouseX, mouseY, delta);
147142
yy += 18;
148143
}
149-
graphics.pose().popPose();
150144
}
151145

152146
@Nullable

api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widget.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
package me.shedaniel.rei.api.client.gui.widgets;
2525

26-
import com.mojang.blaze3d.vertex.PoseStack;
2726
import me.shedaniel.math.Point;
2827
import me.shedaniel.math.Rectangle;
2928
import me.shedaniel.math.impl.PointHelper;
@@ -36,8 +35,8 @@
3635
import net.minecraft.client.gui.GuiGraphics;
3736
import net.minecraft.client.gui.components.Renderable;
3837
import org.jetbrains.annotations.ApiStatus;
39-
import org.joml.Matrix4f;
40-
import org.joml.Vector4f;
38+
import org.joml.Matrix3x2f;
39+
import org.joml.Vector3f;
4140

4241
import java.util.Stack;
4342

@@ -71,17 +70,13 @@ public static Point popMouse() {
7170
return mouseStack.pop();
7271
}
7372

74-
public static Point translateMouse(PoseStack poses) {
75-
return translateMouse(poses.last().pose());
73+
public static Point translateMouse(double x, double y) {
74+
return translateMouse(new Matrix3x2f().translate((float) x, (float) y));
7675
}
7776

78-
public static Point translateMouse(double x, double y, double z) {
79-
return translateMouse(new Matrix4f().translate((float) x, (float) y, (float) z));
80-
}
81-
82-
public static Point translateMouse(Matrix4f pose) {
77+
public static Point translateMouse(Matrix3x2f pose) {
8378
Point mouse = mouse();
84-
Vector4f mouseVec = new Vector4f(mouse.x, mouse.y, 0, 1);
79+
Vector3f mouseVec = new Vector3f(mouse.x, mouse.y, 1);
8580
pose.transform(mouseVec);
8681
return pushMouse(new Point(mouseVec.x(), mouseVec.y()));
8782
}

api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import net.minecraft.world.item.Item;
4545
import org.jetbrains.annotations.ApiStatus;
4646
import org.jetbrains.annotations.Nullable;
47-
import org.joml.Matrix4f;
47+
import org.joml.Matrix3x2f;
4848

4949
import java.util.*;
5050
import java.util.function.Consumer;
@@ -110,19 +110,19 @@ public static Widget wrapVanillaWidget(GuiEventListener element) {
110110
return ClientInternals.getWidgetsProvider().wrapVanillaWidget(element);
111111
}
112112

113-
public static WidgetWithBounds withTranslate(Widget widget, double x, double y, double z) {
114-
return withTranslate(widget, new Matrix4f().translate((float) x, (float) y, (float) z));
113+
public static WidgetWithBounds withTranslate(Widget widget, double x, double y) {
114+
return withTranslate(widget, new Matrix3x2f().translate((float) x, (float) y));
115115
}
116116

117-
public static WidgetWithBounds withTranslate(Widget widget, Matrix4f translate) {
117+
public static WidgetWithBounds withTranslate(Widget widget, Matrix3x2f translate) {
118118
return withTranslate(widget, () -> translate);
119119
}
120120

121-
public static <T extends Widget> WidgetWithBounds withTranslate(T widget, Function<T, Matrix4f> translate) {
121+
public static <T extends Widget> WidgetWithBounds withTranslate(T widget, Function<T, Matrix3x2f> translate) {
122122
return withTranslate(widget, () -> translate.apply(widget));
123123
}
124124

125-
public static WidgetWithBounds withTranslate(Widget widget, Supplier<Matrix4f> translate) {
125+
public static WidgetWithBounds withTranslate(Widget widget, Supplier<Matrix3x2f> translate) {
126126
WidgetWithBounds widgetWithBounds = wrapWidgetWithBounds(widget);
127127
return ClientInternals.getWidgetsProvider().withTranslate(widgetWithBounds, translate);
128128
}

api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/simple/SimpleTransferHandler.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,8 @@ default void renderMissingInput(Context context, List<InputIngredient<ItemStack>
174174
for (Widget widget : widgets) {
175175
if (widget instanceof Slot && ((Slot) widget).getNoticeMark() == Slot.INPUT) {
176176
if (missingIndices.contains(i++)) {
177-
graphics.pose().pushPose();
178-
graphics.pose().translate(0, 0, 50);
179177
Rectangle innerBounds = ((Slot) widget).getInnerBounds();
180178
graphics.fill(innerBounds.x, innerBounds.y, innerBounds.getMaxX(), innerBounds.getMaxY(), 0x40ff0000);
181-
graphics.pose().popPose();
182179
}
183180
}
184181
}

api/src/main/java/me/shedaniel/rei/api/client/util/MatrixUtils.java

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,53 @@
2323

2424
package me.shedaniel.rei.api.client.util;
2525

26-
import com.mojang.math.Transformation;
2726
import me.shedaniel.math.Point;
2827
import me.shedaniel.math.Rectangle;
2928
import org.jetbrains.annotations.ApiStatus;
30-
import org.joml.Matrix4f;
31-
import org.joml.Vector4f;
29+
import org.joml.Matrix3x2f;
30+
import org.joml.Vector3f;
3231

3332
@ApiStatus.Experimental
3433
public class MatrixUtils {
35-
public static Matrix4f inverse(Matrix4f matrix) {
36-
Transformation transformation = new Transformation(matrix);
37-
Transformation inverse = transformation.inverse();
38-
if (inverse != null) inverse.getScale(); // This has a side effect
39-
return inverse == null ? Transformation.identity().getMatrixCopy() : inverse.getMatrixCopy();
34+
public static Matrix3x2f inverse(Matrix3x2f matrix) {
35+
float m00 = matrix.m00;
36+
float m01 = matrix.m01;
37+
float m10 = matrix.m10;
38+
float m11 = matrix.m11;
39+
float m20 = matrix.m20; // Translation X
40+
float m21 = matrix.m21; // Translation Y
41+
42+
// Calculate determinant of the 2x2 rotation/scale part
43+
float det = m00 * m11 - m10 * m01;
44+
45+
if (Math.abs(det) < 0.00001f) { // Check for singularity (e.g., zero scale)
46+
System.err.println("Warning: Matrix is singular (determinant near zero), cannot be accurately inverted.");
47+
return null;
48+
}
49+
50+
float invDet = 1.0f / det;
51+
float invM00 = m11 * invDet;
52+
float invM01 = -m01 * invDet;
53+
float invM10 = -m10 * invDet;
54+
float invM11 = m00 * invDet;
55+
56+
// Apply inverse 2x2 part to translation
57+
// T_inv = -M_inv * T
58+
float invM20 = -(invM00 * m20 + invM10 * m21);
59+
float invM21 = -(invM01 * m20 + invM11 * m21);
60+
61+
// Create the inverse matrix
62+
return new Matrix3x2f(
63+
invM00, invM01, // First column (x-axis transformation)
64+
invM10, invM11, // Second column (y-axis transformation)
65+
invM20, invM21 // Third column (translation)
66+
);
4067
}
4168

42-
public static Rectangle transform(Matrix4f matrix, Rectangle rectangle) {
43-
Vector4f vec1 = new Vector4f((float) rectangle.x, (float) rectangle.y, 0, 1);
69+
public static Rectangle transform(Matrix3x2f matrix, Rectangle rectangle) {
70+
Vector3f vec1 = new Vector3f((float) rectangle.x, (float) rectangle.y, 1);
4471
matrix.transform(vec1);
45-
Vector4f vec2 = new Vector4f((float) rectangle.getMaxX(), (float) rectangle.getMaxY(), 0, 1);
72+
Vector3f vec2 = new Vector3f((float) rectangle.getMaxX(), (float) rectangle.getMaxY(), 1);
4673
matrix.transform(vec2);
4774
int x1 = Math.round(vec1.x());
4875
int x2 = Math.round(vec2.x());
@@ -51,8 +78,8 @@ public static Rectangle transform(Matrix4f matrix, Rectangle rectangle) {
5178
return new Rectangle(Math.min(x1, x2), Math.min(y1, y2), Math.abs(x2 - x1), Math.abs(y2 - y1));
5279
}
5380

54-
public static Point transform(Matrix4f matrix, Point point) {
55-
Vector4f mouse = new Vector4f((float) point.x, (float) point.y, 0, 1);
81+
public static Point transform(Matrix3x2f matrix, Point point) {
82+
Vector3f mouse = new Vector3f((float) point.x, (float) point.y, 1);
5683
matrix.transform(mouse);
5784
return new Point(mouse.x(), mouse.y());
5885
}

0 commit comments

Comments
 (0)