Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit 24fda57

Browse files
committed
feat: 1.20 update
1 parent 18adedf commit 24fda57

37 files changed

+209
-206
lines changed

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
push:
66
branches:
7-
- '1.19.4'
7+
- '1.20'
88
paths-ignore:
99
- 'README.md'
1010
- 'LICENSE'

common/src/main/java/com/github/franckyi/guapi/api/GuapiExceptionHandler.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import com.github.franckyi.guapi.api.event.ScreenEvent;
44
import com.github.franckyi.guapi.api.node.Scene;
55
import com.github.franckyi.guapi.api.util.ScreenEventType;
6-
import com.mojang.blaze3d.vertex.PoseStack;
6+
import net.minecraft.client.gui.GuiGraphics;
77

88
public interface GuapiExceptionHandler {
99
GuapiExceptionHandler NONE = new GuapiExceptionHandler() {
@@ -16,13 +16,13 @@ public void handleTickException(Exception e, Scene currentScene) {
1616
}
1717

1818
@Override
19-
public void handleRenderException(Exception e, PoseStack matrices, int mouseX, int mouseY, float delta, Scene currentScene) {
19+
public void handleRenderException(Exception e, GuiGraphics guiGraphics, int mouseX, int mouseY, float delta, Scene currentScene) {
2020
}
2121
};
2222

2323
<E extends ScreenEvent> void handleEventException(Exception e, ScreenEventType<E> type, E event, Scene currentScene);
2424

2525
void handleTickException(Exception e, Scene currentScene);
2626

27-
void handleRenderException(Exception e, PoseStack matrices, int mouseX, int mouseY, float delta, Scene currentScene);
27+
void handleRenderException(Exception e, GuiGraphics guiGraphics, int mouseX, int mouseY, float delta, Scene currentScene);
2828
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package com.github.franckyi.guapi.api;
22

33
import com.mojang.blaze3d.systems.RenderSystem;
4-
import com.mojang.blaze3d.vertex.PoseStack;
54
import net.minecraft.client.Minecraft;
65
import net.minecraft.client.gui.Font;
7-
import net.minecraft.client.gui.GuiComponent;
6+
import net.minecraft.client.gui.GuiGraphics;
87
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
98
import net.minecraft.network.chat.Component;
109
import net.minecraft.resources.ResourceLocation;
@@ -30,62 +29,58 @@ public static int getFontWidth(Component text) {
3029
return font().width(text);
3130
}
3231

33-
public static void drawString(PoseStack matrices, Component text, float x, float y, int color, boolean shadow) {
34-
if (shadow) {
35-
font().drawShadow(matrices, text, x, y, color);
36-
} else {
37-
font().draw(matrices, text, x, y, color);
38-
}
32+
public static void drawString(GuiGraphics guiGraphics, Component text, float x, float y, int color, boolean shadow) {
33+
guiGraphics.drawString(font(), text, (int) x, (int) y, color, shadow);
3934
}
4035

41-
public static void fillRectangle(PoseStack matrices, int x0, int y0, int x1, int y1, int color) {
42-
GuiComponent.fill(matrices, x0, y0, x1, y1, color);
36+
public static void fillRectangle(GuiGraphics guiGraphics, int x0, int y0, int x1, int y1, int color) {
37+
guiGraphics.fill(x0, y0, x1, y1, color);
4338
}
4439

45-
public static void drawVLine(PoseStack matrices, int x, int y0, int y1, int color) {
46-
fillRectangle(matrices, x, y0, x + 1, y1, color);
40+
public static void drawVLine(GuiGraphics guiGraphics, int x, int y0, int y1, int color) {
41+
fillRectangle(guiGraphics, x, y0, x + 1, y1, color);
4742
}
4843

49-
public static void drawHLine(PoseStack matrices, int y, int x0, int x1, int color) {
50-
fillRectangle(matrices, x0, y, x1, y + 1, color);
44+
public static void drawHLine(GuiGraphics guiGraphics, int y, int x0, int x1, int color) {
45+
fillRectangle(guiGraphics, x0, y, x1, y + 1, color);
5146
}
5247

53-
public static void drawRectangle(PoseStack matrices, int x0, int y0, int x1, int y1, int color) {
54-
drawHLine(matrices, y0, x0, x1 - 1, color);
55-
drawVLine(matrices, x1 - 1, y0, y1 - 1, color);
56-
drawHLine(matrices, y1 - 1, x1, x0 + 1, color);
57-
drawVLine(matrices, x0, y1, y0 + 1, color);
48+
public static void drawRectangle(GuiGraphics guiGraphics, int x0, int y0, int x1, int y1, int color) {
49+
drawHLine(guiGraphics, y0, x0, x1 - 1, color);
50+
drawVLine(guiGraphics, x1 - 1, y0, y1 - 1, color);
51+
drawHLine(guiGraphics, y1 - 1, x1, x0 + 1, color);
52+
drawVLine(guiGraphics, x0, y1, y0 + 1, color);
5853
}
5954

60-
public static void drawTexture(PoseStack matrices, ResourceLocation id, int x, int y, int width, int height, int imageX, int imageY, int imageWidth, int imageHeight) {
55+
public static void drawTexture(GuiGraphics guiGraphics, ResourceLocation id, int x, int y, int width, int height, int imageX, int imageY, int imageWidth, int imageHeight) {
6156
RenderSystem.setShaderTexture(0, id);
6257
RenderSystem.enableBlend();
6358
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
6459
RenderSystem.defaultBlendFunc();
6560
RenderSystem.enableDepthTest();
66-
GuiComponent.blit(matrices, x, y, 0, imageX, imageY, width, height, imageWidth, imageHeight);
61+
guiGraphics.blit(id, x, y, 0, imageX, imageY, width, height, imageWidth, imageHeight);
6762
}
6863

69-
public static void drawSprite(PoseStack matrices, TextureAtlasSprite sprite, int x, int y, int imageWidth, int imageHeight) {
64+
public static void drawSprite(GuiGraphics guiGraphics, TextureAtlasSprite sprite, int x, int y, int imageWidth, int imageHeight) {
7065
RenderSystem.setShaderTexture(0, sprite.atlasLocation());
7166
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
72-
GuiComponent.blit(matrices, x, y, 0, imageWidth, imageHeight, sprite);
67+
guiGraphics.blit(x, y, 0, imageWidth, imageHeight, sprite);
7368
}
7469

75-
public static void drawTooltip(PoseStack matrices, List<Component> text, int x, int y) {
76-
mc().screen.renderComponentTooltip(matrices, text, x, y);
70+
public static void drawTooltip(GuiGraphics guiGraphics, List<Component> text, int x, int y) {
71+
guiGraphics.renderComponentTooltip(font(), text, x, y);
7772
}
7873

79-
public static void drawTooltip(PoseStack matrices, ItemStack itemStack, int x, int y) {
80-
mc().screen.renderComponentTooltip(matrices,
74+
public static void drawTooltip(GuiGraphics guiGraphics, ItemStack itemStack, int x, int y) {
75+
guiGraphics.renderComponentTooltip(font(),
8176
itemStack.getTooltipLines(Minecraft.getInstance().player, TooltipFlag.Default.NORMAL), x, y);
8277
}
8378

84-
public static void drawItem(PoseStack matrices, ItemStack itemStack, int x, int y) {
85-
mc().getItemRenderer().renderAndDecorateFakeItem(matrices, itemStack, x, y);
79+
public static void drawItem(GuiGraphics guiGraphics, ItemStack itemStack, int x, int y) {
80+
guiGraphics.renderFakeItem(itemStack, x, y);
8681
}
8782

88-
public static void drawItemDecorations(PoseStack matrices, ItemStack itemStack, int x, int y) {
89-
mc().getItemRenderer().renderGuiItemDecorations(matrices, font(), itemStack, x, y);
83+
public static void drawItemDecorations(GuiGraphics guiGraphics, ItemStack itemStack, int x, int y) {
84+
guiGraphics.renderItemDecorations(font(), itemStack, x, y);
9085
}
9186
}
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package com.github.franckyi.guapi.api;
22

3-
import com.mojang.blaze3d.vertex.PoseStack;
3+
import net.minecraft.client.gui.GuiGraphics;
44

55
public interface Renderable {
6-
default boolean preRender(PoseStack matrices, int mouseX, int mouseY, float delta) {
6+
default boolean preRender(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) {
77
return false;
88
}
99

10-
void render(PoseStack matrices, int mouseX, int mouseY, float delta);
10+
void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta);
1111

12-
default void postRender(PoseStack matrices, int mouseX, int mouseY, float delta) {
12+
default void postRender(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) {
1313
}
1414
}

common/src/main/java/com/github/franckyi/guapi/api/theme/Skin.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
import com.github.franckyi.guapi.api.event.ScreenEvent;
55
import com.github.franckyi.guapi.api.node.Node;
66
import com.github.franckyi.guapi.api.util.ScreenEventType;
7-
import com.mojang.blaze3d.vertex.PoseStack;
87
import net.minecraft.client.Minecraft;
98
import net.minecraft.client.gui.Font;
9+
import net.minecraft.client.gui.GuiGraphics;
1010

1111
public interface Skin<N extends Node> extends EventTarget {
12-
boolean preRender(N node, PoseStack matrices, int mouseX, int mouseY, float delta);
12+
boolean preRender(N node, GuiGraphics guiGraphics, int mouseX, int mouseY, float delta);
1313

14-
void render(N node, PoseStack matrices, int mouseX, int mouseY, float delta);
14+
void render(N node, GuiGraphics guiGraphics, int mouseX, int mouseY, float delta);
1515

16-
void postRender(N node, PoseStack matrices, int mouseX, int mouseY, float delta);
16+
void postRender(N node, GuiGraphics guiGraphics, int mouseX, int mouseY, float delta);
1717

1818
int computeWidth(N node);
1919

common/src/main/java/com/github/franckyi/guapi/base/ScreenHandlerImpl.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.github.franckyi.guapi.base.event.*;
1212
import com.mojang.blaze3d.vertex.PoseStack;
1313
import net.minecraft.client.Minecraft;
14+
import net.minecraft.client.gui.GuiGraphics;
1415
import net.minecraft.client.gui.screens.Screen;
1516
import org.jetbrains.annotations.NotNull;
1617

@@ -107,11 +108,11 @@ private void closeScreen() {
107108
Minecraft.getInstance().setScreen(oldScreen);
108109
}
109110

110-
private void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
111+
private void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) {
111112
try {
112-
getCurrentScene().render(matrices, mouseX, mouseY, delta);
113+
getCurrentScene().render(guiGraphics, mouseX, mouseY, delta);
113114
} catch (Exception e) {
114-
Guapi.getExceptionHandler().handleRenderException(e, matrices, mouseX, mouseY, delta, getCurrentScene());
115+
Guapi.getExceptionHandler().handleRenderException(e, guiGraphics, mouseX, mouseY, delta, getCurrentScene());
115116
Guapi.getDefaultLogger().error(Guapi.LOG_MARKER, "Error while rendering GUAPI Scene", e);
116117
hideScene();
117118
}
@@ -184,14 +185,14 @@ private GuapiScreen() {
184185
}
185186

186187
@Override
187-
public void render(@NotNull PoseStack matrices, int mouseX, int mouseY, float partialTicks) {
188+
public void render(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
188189
if (!currentSceneProperty().hasValue()) return;
189190
if (getCurrentScene().isTexturedBackground()) {
190-
renderDirtBackground(matrices);
191+
renderDirtBackground(guiGraphics);
191192
} else {
192-
renderBackground(matrices);
193+
renderBackground(guiGraphics);
193194
}
194-
ScreenHandlerImpl.this.render(matrices, mouseX, mouseY, partialTicks);
195+
ScreenHandlerImpl.this.render(guiGraphics, mouseX, mouseY, partialTicks);
195196
}
196197

197198
@Override

common/src/main/java/com/github/franckyi/guapi/base/node/AbstractNode.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import com.github.franckyi.guapi.api.util.Insets;
1313
import com.github.franckyi.guapi.api.util.ScreenEventType;
1414
import com.github.franckyi.guapi.base.event.ScreenEventHandlerDelegate;
15-
import com.mojang.blaze3d.vertex.PoseStack;
15+
import net.minecraft.client.gui.GuiGraphics;
1616
import net.minecraft.network.chat.Component;
1717

1818
public abstract class AbstractNode implements Node {
@@ -241,25 +241,25 @@ public <E extends ScreenEvent> void removeListener(ScreenEventType<E> target, Sc
241241
}
242242

243243
@Override
244-
public boolean preRender(PoseStack matrices, int mouseX, int mouseY, float delta) {
244+
public boolean preRender(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) {
245245
boolean res = checkRender();
246246
if (isVisible()) {
247-
res |= getSkin().preRender(this, matrices, mouseX, mouseY, delta);
247+
res |= getSkin().preRender(this, guiGraphics, mouseX, mouseY, delta);
248248
}
249249
return res;
250250
}
251251

252252
@Override
253-
public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
253+
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) {
254254
if (isVisible()) {
255-
getSkin().render(this, matrices, mouseX, mouseY, delta);
255+
getSkin().render(this, guiGraphics, mouseX, mouseY, delta);
256256
}
257257
}
258258

259259
@Override
260-
public void postRender(PoseStack matrices, int mouseX, int mouseY, float delta) {
260+
public void postRender(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) {
261261
if (isVisible()) {
262-
getSkin().postRender(this, matrices, mouseX, mouseY, delta);
262+
getSkin().postRender(this, guiGraphics, mouseX, mouseY, delta);
263263
}
264264
}
265265

common/src/main/java/com/github/franckyi/guapi/base/node/AbstractScene.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import com.github.franckyi.guapi.api.util.Insets;
1212
import com.github.franckyi.guapi.api.util.ScreenEventType;
1313
import com.github.franckyi.guapi.base.event.ScreenEventHandlerDelegate;
14-
import com.mojang.blaze3d.vertex.PoseStack;
14+
import net.minecraft.client.gui.GuiGraphics;
1515
import org.lwjgl.glfw.GLFW;
1616

1717
import java.util.ArrayList;
@@ -141,15 +141,15 @@ protected void setHovered(Node value) {
141141
}
142142

143143
@Override
144-
public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
144+
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) {
145145
if (shouldUpdateChildrenPos) {
146146
updateChildrenPos();
147147
shouldUpdateChildrenPos = false;
148148
}
149149
if (rootProperty().hasValue()) {
150-
while (getRoot().preRender(matrices, mouseX, mouseY, delta)) ;
151-
getRoot().render(matrices, mouseX, mouseY, delta);
152-
getRoot().postRender(matrices, mouseX, mouseY, delta);
150+
while (getRoot().preRender(guiGraphics, mouseX, mouseY, delta)) ;
151+
getRoot().render(guiGraphics, mouseX, mouseY, delta);
152+
getRoot().postRender(guiGraphics, mouseX, mouseY, delta);
153153
}
154154
}
155155

common/src/main/java/com/github/franckyi/guapi/base/theme/AbstractSkin.java

+11-10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.github.franckyi.guapi.api.theme.Skin;
88
import com.github.franckyi.guapi.api.util.ScreenEventType;
99
import com.mojang.blaze3d.vertex.PoseStack;
10+
import net.minecraft.client.gui.GuiGraphics;
1011

1112
import java.util.Random;
1213

@@ -18,28 +19,28 @@ protected AbstractSkin() {
1819
}
1920

2021
@Override
21-
public boolean preRender(N node, PoseStack matrices, int mouseX, int mouseY, float delta) {
22+
public boolean preRender(N node, GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) {
2223
return false;
2324
}
2425

2526
@Override
26-
public void render(N node, PoseStack matrices, int mouseX, int mouseY, float delta) {
27-
renderBackground(node, matrices);
27+
public void render(N node, GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) {
28+
renderBackground(node, guiGraphics);
2829
}
2930

3031
@Override
31-
public void postRender(N node, PoseStack matrices, int mouseX, int mouseY, float delta) {
32+
public void postRender(N node, GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) {
3233
switch (Guapi.getDebugMode()) {
3334
case OFF:
3435
break;
3536
case HOVER:
3637
if (!node.inBounds(mouseX, mouseY)) break;
3738
case FULL:
38-
renderDebug(node, matrices);
39+
renderDebug(node, guiGraphics);
3940
break;
4041
}
4142
if (!node.getTooltip().isEmpty() && node.isHovered()) {
42-
RenderHelper.drawTooltip(matrices, node.getTooltip(), mouseX, mouseY);
43+
RenderHelper.drawTooltip(guiGraphics, node.getTooltip(), mouseX, mouseY);
4344
}
4445
}
4546

@@ -48,13 +49,13 @@ public <E extends ScreenEvent> void onEvent(ScreenEventType<E> type, E event) {
4849
type.onEvent(this, event);
4950
}
5051

51-
protected void renderDebug(N node, PoseStack matrices) {
52-
RenderHelper.drawRectangle(matrices, node.getLeft(), node.getTop(),
52+
protected void renderDebug(N node, GuiGraphics guiGraphics) {
53+
RenderHelper.drawRectangle(guiGraphics, node.getLeft(), node.getTop(),
5354
node.getRight(), node.getBottom(), debugColor);
5455
}
5556

56-
protected void renderBackground(N node, PoseStack matrices) {
57-
RenderHelper.fillRectangle(matrices, node.getLeft(), node.getTop(),
57+
protected void renderBackground(N node, GuiGraphics guiGraphics) {
58+
RenderHelper.fillRectangle(guiGraphics, node.getLeft(), node.getTop(),
5859
node.getRight(), node.getBottom(), node.getBackgroundColor());
5960
}
6061
}

common/src/main/java/com/github/franckyi/guapi/base/theme/ProvidedSkin.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.github.franckyi.guapi.base.theme;
22

33
import com.github.franckyi.guapi.base.node.AbstractNode;
4-
import com.mojang.blaze3d.vertex.PoseStack;
4+
import net.minecraft.client.gui.GuiGraphics;
55

66
public abstract class ProvidedSkin<N extends AbstractNode> extends AbstractSkin<N> {
77
private final N node;
@@ -11,9 +11,9 @@ protected ProvidedSkin(N node) {
1111
}
1212

1313
@Override
14-
public void render(N node, PoseStack matrices, int mouseX, int mouseY, float delta) {
15-
super.render(node, matrices, mouseX, mouseY, delta);
16-
renderNode(matrices, mouseX, mouseY, delta);
14+
public void render(N node, GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) {
15+
super.render(node, guiGraphics, mouseX, mouseY, delta);
16+
renderNode(guiGraphics, mouseX, mouseY, delta);
1717
}
1818

1919
protected abstract <M> void renderNode(M matrices, int mouseX, int mouseY, float delta);

0 commit comments

Comments
 (0)