Skip to content

Commit 79d963e

Browse files
feat: port to 1.21.2
1 parent 072c8df commit 79d963e

File tree

15 files changed

+116
-97
lines changed

15 files changed

+116
-97
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## [21.2.0]
2+
3+
### Changes
4+
5+
- Ported to 1.21.2
6+
- Tooltip on entry hover has how been moved to help text under the main gui
7+
8+
### Fixed
9+
10+
- Scrollbar should no longer click through to the entry behind it
11+
112
## [21.0.0]
213

314
### Changes

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'fabric-loom' version '1.6-SNAPSHOT'
2+
id 'fabric-loom' version '1.8-SNAPSHOT'
33
id 'maven-publish'
44
id 'pro.mikey.plugins.insaniam' version "0.1-SNAPSHOT"
55
id "me.modmuss50.mod-publish-plugin" version "0.5.1"

gradle.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Done to increase the memory available to gradle.
22
org.gradle.jvmargs=-Xmx4G
3-
minecraft_version=1.21
3+
minecraft_version=1.21.2
44

55
# Mod Properties
6-
mod_version=21.0.0
6+
mod_version=21.2.0
77
maven_group=pro.mikey
88
archives_base_name=advanced-xray-fabric
99

10-
loader_version=0.15.11
11-
fabric_version=0.100.1+1.21
10+
loader_version=0.16.9
11+
fabric_version=0.106.1+1.21.2
1212

1313
curse_id=444663
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/client/java/pro/mikey/fabric/xray/ScanTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ private Set<BlockPosWithColor> collectBlocks() {
108108

109109
for (int k = chunkStartX; k < chunkStartX + 16; k++) {
110110
for (int l = chunkStartZ; l < chunkStartZ + 16; l++) {
111-
for (int m = world.getMinBuildHeight(); m < world.getMaxBuildHeight() + (1 << 4); m++) {
111+
for (int m = world.getMinY(); m < world.getMaxY() + (1 << 4); m++) {
112112
BlockPos pos = new BlockPos(k, m, l);
113113
BasicColor validBlock = isValidBlock(pos, world, blocks);
114114
if (validBlock != null) {

src/client/java/pro/mikey/fabric/xray/cache/BlockSearchEntry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static BlockState blockStateFromStringNBT(String nbt) {
3131
return Blocks.AIR.defaultBlockState();
3232
}
3333

34-
return NbtUtils.readBlockState(BuiltInRegistries.BLOCK.asLookup(), tag);
34+
return NbtUtils.readBlockState(BuiltInRegistries.BLOCK, tag);
3535
}
3636

3737
public static String blockStateToStringNBT(BlockState state) {

src/client/java/pro/mikey/fabric/xray/records/BasicColor.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,19 @@ public static BasicColor of(String hex) {
1919
String toHex() {
2020
return String.format("#%02x%02x%02x", this.red, this.green, this.blue);
2121
}
22+
23+
/**
24+
* Convert the color to an int along with a alpha value of 255
25+
*/
26+
public int toInt() {
27+
return (255 << 24) + (this.red << 16) + (this.green << 8) + this.blue;
28+
}
29+
30+
public int toInt(int alpha) {
31+
return (alpha << 24) + (this.red << 16) + (this.green << 8) + this.blue;
32+
}
33+
34+
public static int rgbaToInt(int red, int green, int blue, float alpha) {
35+
return ((int) (alpha * 255) << 24) + (red << 16) + (green << 8) + blue;
36+
}
2237
}

src/client/java/pro/mikey/fabric/xray/render/RenderOutlines.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package pro.mikey.fabric.xray.render;
22

3+
import com.mojang.blaze3d.buffers.BufferUsage;
34
import com.mojang.blaze3d.systems.RenderSystem;
45
import com.mojang.blaze3d.vertex.*;
56
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext;
67
import net.fabricmc.loader.api.FabricLoader;
78
import net.minecraft.client.Camera;
9+
import net.minecraft.client.renderer.CoreShaders;
810
import net.minecraft.client.renderer.GameRenderer;
911
import net.minecraft.world.phys.Vec3;
1012
import org.joml.Matrix4f;
@@ -37,7 +39,7 @@ public static synchronized void render(WorldRenderContext context) {
3739

3840
if (vertexBuffer == null || requestedRefresh.get()) {
3941
requestedRefresh.set(false);
40-
vertexBuffer = new VertexBuffer(VertexBuffer.Usage.STATIC);
42+
vertexBuffer = new VertexBuffer(BufferUsage.STATIC_WRITE);
4143

4244
Tesselator tessellator = Tesselator.getInstance();
4345
BufferBuilder buffer = tessellator.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR);
@@ -59,13 +61,12 @@ public static synchronized void render(WorldRenderContext context) {
5961
Camera camera = context.camera();
6062
Vec3 cameraPos = camera.getPosition();
6163

64+
PoseStack poseStack = context.matrixStack();
65+
6266
RenderSystem.depthMask(false);
6367
RenderSystem.enableBlend();
6468
RenderSystem.defaultBlendFunc();
6569

66-
RenderSystem.applyModelViewMatrix();
67-
68-
PoseStack poseStack = context.matrixStack();
6970
poseStack.pushPose();
7071

7172
if (canvasLoaded == 1) { // canvas compat
@@ -75,19 +76,23 @@ public static synchronized void render(WorldRenderContext context) {
7576
poseStack.mulPose(new Quaternionf(0.0, 1.0 * sin(f/2.0f), 0.0, cos(f/2.0f)));
7677
}
7778

78-
RenderSystem.setShader(GameRenderer::getPositionColorShader);
79-
RenderSystem.applyModelViewMatrix();
79+
RenderSystem.setShader(CoreShaders.POSITION_COLOR);
8080
RenderSystem.depthFunc(GL11.GL_ALWAYS);
8181

82-
context.projectionMatrix().lookAt(cameraPos.toVector3f(), cameraPos.toVector3f().add(camera.getLookVector()), camera.getUpVector());
82+
Matrix4f matrix4f = new Matrix4f(context.projectionMatrix());
83+
84+
matrix4f.lookAt(cameraPos.toVector3f(), cameraPos.toVector3f().add(camera.getLookVector()), camera.getUpVector());
8385

8486
vertexBuffer.bind();
85-
vertexBuffer.drawWithShader(poseStack.last().pose(), new Matrix4f(context.projectionMatrix()), RenderSystem.getShader());
87+
vertexBuffer.drawWithShader(poseStack.last().pose(), matrix4f, RenderSystem.getShader());
8688
VertexBuffer.unbind();
89+
90+
// Reset everything
8791
RenderSystem.depthFunc(GL11.GL_LEQUAL);
92+
RenderSystem.disableBlend();
93+
RenderSystem.depthMask(true);
8894

8995
poseStack.popPose();
90-
RenderSystem.applyModelViewMatrix();
9196
}
9297
}
9398

src/client/java/pro/mikey/fabric/xray/screens/AbstractScreen.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.mojang.blaze3d.vertex.PoseStack;
55
import net.minecraft.client.gui.GuiGraphics;
66
import net.minecraft.client.gui.screens.Screen;
7+
import net.minecraft.client.renderer.RenderType;
78
import net.minecraft.network.chat.Component;
89
import net.minecraft.resources.ResourceLocation;
910
import pro.mikey.fabric.xray.Utils;
@@ -19,14 +20,10 @@ public abstract class AbstractScreen extends Screen {
1920
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) {
2021
super.render(guiGraphics, mouseX, mouseY, delta);
2122

22-
// RenderSystem.pushMatrix();
23-
// RenderSystem.translatef(0.0F, 0.0F, 100.0F);
24-
// RenderSystem.setShaderTexture(0, TEXTURE);
2523
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
2624
int i = (this.width - 147) / 2;
2725
int j = (this.height - 166) / 2;
2826

29-
guiGraphics.blit(TEXTURE, i, j, 1, 1, 147, 166);
30-
// RenderSystem.popMatrix();
27+
guiGraphics.blit(RenderType::guiTextured, TEXTURE, i, j, 1, 1, 147, 166, 256, 256);
3128
}
3229
}

src/client/java/pro/mikey/fabric/xray/screens/forge/GuiBase.java

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package pro.mikey.fabric.xray.screens.forge;
22

3+
import com.mojang.blaze3d.vertex.PoseStack;
34
import net.minecraft.client.Minecraft;
45
import net.minecraft.client.gui.Font;
56
import net.minecraft.client.gui.GuiGraphics;
67
import net.minecraft.client.gui.components.Renderable;
78
import net.minecraft.client.gui.screens.Screen;
9+
import net.minecraft.client.renderer.RenderType;
810
import net.minecraft.network.chat.Component;
911
import net.minecraft.resources.ResourceLocation;
1012
import pro.mikey.fabric.xray.Utils;
@@ -38,12 +40,16 @@ public boolean charTyped(char keyTyped, int __unknown) {
3840

3941
@Override
4042
public void render(GuiGraphics guiGraphics, int x, int y, float partialTicks) {
43+
super.render(guiGraphics, x, y, partialTicks);
44+
this.renderExtra(guiGraphics, x, y, partialTicks);
45+
4146
this.renderBackground(guiGraphics, x, y, partialTicks);
4247
int width = this.width;
4348
int height = this.height;
4449
if (this.hasSide) {
45-
guiGraphics.blit(this.getBackground(), width / 2 + 60, height / 2 - 180 / 2, 0, 0, 150, 180, 150, 180);
50+
guiGraphics.blit(RenderType::guiTextured, this.getBackground(), width / 2 + 60, height / 2 - 180 / 2, 0, 0, 150, 180, 150, 180);
4651
guiGraphics.blit(
52+
RenderType::guiTextured,
4753
this.getBackground(),
4854
width / 2 - 150,
4955
height / 2 - 118,
@@ -54,14 +60,11 @@ public void render(GuiGraphics guiGraphics, int x, int y, float partialTicks) {
5460
this.backgroundWidth,
5561
this.backgroundHeight
5662
);
57-
58-
if (this.hasSideTitle()) {
59-
guiGraphics.drawString(this.font, this.sideTitle, width / 2 + 80, height / 2 - 77, 0xffff00);
60-
}
6163
}
6264

6365
if (!this.hasSide) {
6466
guiGraphics.blit(
67+
RenderType::guiTextured,
6568
this.getBackground(),
6669
width / 2 - this.backgroundWidth / 2 + 1,
6770
height / 2 - this.backgroundHeight / 2,
@@ -74,27 +77,33 @@ public void render(GuiGraphics guiGraphics, int x, int y, float partialTicks) {
7477
);
7578
}
7679

77-
// RenderSystem.enableTexture();
80+
PoseStack pose = guiGraphics.pose();
81+
pose.pushPose();
82+
for (Renderable renderable : this.renderables) {
83+
renderable.render(guiGraphics, x, y, partialTicks);
84+
}
85+
pose.popPose();
86+
87+
this.renderExtra(guiGraphics, x, y, partialTicks);
88+
7889
if (this.hasTitle()) {
7990
if (this.hasSide) {
8091
guiGraphics.drawString(
81-
this.font, this.title(), width / 2 - 138, height / 2 - 105, 0xffff00);
92+
this.font, this.title(), width / 2 - 138, height / 2 - 105, 0xffff00);
8293
} else {
8394
guiGraphics.drawString(
8495
this.font,
85-
this.title(),
86-
width / 2 - ( this.backgroundWidth / 2) + 14,
87-
height / 2 - ( this.backgroundHeight / 2) + 13,
88-
0xffff00
89-
);
96+
this.title(),
97+
width / 2 - ( this.backgroundWidth / 2) + 14,
98+
height / 2 - ( this.backgroundHeight / 2) + 13,
99+
0xffff00
100+
);
90101
}
91102
}
92103

93-
for (Renderable renderable : this.renderables) {
94-
renderable.render(guiGraphics, x, y, partialTicks);
104+
if (this.hasSide && this.hasSideTitle()) {
105+
guiGraphics.drawString(this.font, this.sideTitle, width / 2 + 80, height / 2 - 77, 0xffff00);
95106
}
96-
97-
this.renderExtra(guiGraphics, x, y, partialTicks);
98107
}
99108

100109
public ResourceLocation getBackground() {

0 commit comments

Comments
 (0)