Skip to content

Commit 183d620

Browse files
committed
✨ fabric-1.21.6
1 parent 52a8ef4 commit 183d620

3 files changed

Lines changed: 50 additions & 20 deletions

File tree

.idea/ModAliasState.xml

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fabric/origin/src/main/java/io/github/kituin/chatimage/integration/NativeImageBackedTexture.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,19 @@
2121
@Environment(EnvType.CLIENT)
2222
public class NativeImageBackedTexture extends AbstractTexture implements DynamicTexture {
2323
private static final Logger LOGGER = LogUtils.getLogger();
24+
2425
@Nullable
2526
private NativeImage image;
2627

2728
public NativeImageBackedTexture(NativeImage image) {
2829
this.image = image;
2930
if (!RenderSystem.isOnRenderThread()) {
30-
try{
31+
try {
3132
MinecraftClient.getInstance().execute(() -> {
3233
this.glTexture = RenderSystem.getDevice().createTexture(
3334
(String) null,
3435
// IF >= fabric-1.21.6
35-
// 4,
36+
// 1,
3637
// END IF
3738
TextureFormat.RGBA8,
3839
this.image.getWidth(),
@@ -43,6 +44,9 @@ public NativeImageBackedTexture(NativeImage image) {
4344
1
4445
);
4546
this.upload();
47+
// IF >= fabric-1.21.6
48+
// this.glTextureView = RenderSystem.getDevice().createTextureView(this.glTexture);
49+
// END IF
4650
});
4751
} catch (Exception e) {
4852
LOGGER.error("Failed to upload texture", e);
@@ -51,7 +55,7 @@ public NativeImageBackedTexture(NativeImage image) {
5155
this.glTexture = RenderSystem.getDevice().createTexture(
5256
(String) null,
5357
// IF >= fabric-1.21.6
54-
// 4,
58+
// 1,
5559
// END IF
5660
TextureFormat.RGBA8,
5761
this.image.getWidth(),
@@ -62,6 +66,9 @@ public NativeImageBackedTexture(NativeImage image) {
6266
1
6367
);
6468
this.upload();
69+
// IF >= fabric-1.21.6
70+
// this.glTextureView = RenderSystem.getDevice().createTextureView(this.glTexture);
71+
// END IF
6572
}
6673

6774
}

fabric/origin/src/main/java/io/github/kituin/chatimage/mixin/DrawContextMixin.java

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import net.minecraft.client.gui.DrawContext;
1111
import net.minecraft.client.gui.tooltip.HoveredTooltipPositioner;
1212
import net.minecraft.client.gui.tooltip.TooltipBackgroundRenderer;
13-
import net.minecraft.client.util.math.MatrixStack;
1413
import net.minecraft.text.*;
1514
import net.minecraft.util.Identifier;
1615
import org.jetbrains.annotations.Nullable;
@@ -46,25 +45,28 @@ public abstract class DrawContextMixin {
4645
@Shadow
4746
@Nullable
4847
private MinecraftClient client;
48+
4949
@Shadow
5050
@Final
51-
private MatrixStack matrices;
51+
private #MatrixStack# matrices;
52+
5253
@Shadow
5354
public abstract int getScaledWindowWidth();
55+
5456
@Shadow
5557
public abstract int getScaledWindowHeight();
58+
5659
@Shadow
5760
public abstract void drawOrderedTooltip(TextRenderer textRenderer, List<? extends OrderedText> text, int x, int y);
61+
62+
@Shadow
63+
public abstract void drawTexture(
5864
// IF >= fabric-1.21.6
59-
// @Shadow
60-
// public abstract void drawTexturedQuad(Identifier sprite, int x1, int y1, int x2, int y2, float u1, float u2, float v1, float v2);
61-
// ELSE
62-
// @Shadow
63-
// public abstract void drawTexture(
64-
// IF >= fabric-1.21.2
65-
//Function<Identifier, RenderLayer> renderLayers,
66-
// END IF
67-
// Identifier texture, int x, int y, float u, float v, int width, int height, int textureWidth, int textureHeight);
65+
// com.mojang.blaze3d.pipeline.RenderPipeline pipeline,
66+
// ELSE IF >= fabric-1.21.2
67+
// Function<Identifier, RenderLayer> renderLayers,
68+
// END IF
69+
Identifier texture, int x, int y, float u, float v, int width, int height, int textureWidth, int textureHeight);
6870
// END IF
6971
// IF < fabric-1.21.2
7072
// @Shadow
@@ -93,7 +95,12 @@ public void drawHoverEvent(TextRenderer textRenderer, Style style, int x, int y,
9395
int l = vector2ic.x();
9496
int m = vector2ic.y();
9597
// 背景
96-
this.matrices.push();
98+
// IF >= fabric-1.21.6
99+
// this.matrices.pushMatrix();
100+
//
101+
// ELSE
102+
// this.matrices.push();
103+
// END IF
97104
// IF >= fabric-1.21.2
98105
// TooltipBackgroundRenderer.render((DrawContext) (Object)this, l, m, allWidth, allHeight,
99106
// IF <= fabric-1.21.5
@@ -105,22 +112,30 @@ public void drawHoverEvent(TextRenderer textRenderer, Style style, int x, int y,
105112
// TooltipBackgroundRenderer.render((DrawContext) (Object)this, l, m, allWidth,allHeight, 400);
106113
// });
107114
// END IF
108-
this.matrices.translate(0.0F, 0.0F, 400.0F);
115+
116+
117+
109118

110119
// 图片
111120
// IF >= fabric-1.21.6
112-
// this.drawTexturedQuad(
121+
// this.matrices.translate(0.0F, 0.0F);
122+
// this.drawTexture(
123+
// net.minecraft.client.gl.RenderPipelines.GUI_TEXTURED,
113124
//
114125
// ELSE
126+
// this.matrices.translate(0.0F, 0.0F, 400.0F);
115127
// this.drawTexture(
116128
// END IF
117129
// IF >= fabric-1.21.2 && <= fabric-1.21.5
118130
// RenderLayer::getGuiTextured,
119131
// END IF
120132
(Identifier) frame.getId(), l + CONFIG.paddingLeft, m + CONFIG.paddingTop, 0, 0, viewWidth, viewHeight, viewWidth, viewHeight
121133
);
122-
123-
this.matrices.pop();
134+
// IF >= fabric-1.21.6
135+
// this.matrices.popMatrix();
136+
// ELSE
137+
// this.matrices.pop();
138+
// END IF
124139
frame.gifLoop(CONFIG.gifSpeed);
125140
} else {
126141
MutableText text = (MutableText) frame.getErrorMessage(

0 commit comments

Comments
 (0)