Skip to content

Commit

Permalink
Merge pull request #60 from x04/master-1.21-fabric
Browse files Browse the repository at this point in the history
update for 1.21 fabric
  • Loading branch information
r8420 authored Jul 15, 2024
2 parents b2ffead + eae309c commit 901a364
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 52 deletions.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.3
minecraft_version=1.21
yarn_mappings=1.21+build.2
loader_version=0.15.11

# Fabric API
fabric_version=0.99.0+1.20.6
fabric_version=0.100.3+1.21

# Mod Properties
mod_version=1.22.5.1-fabric
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public static void renderEdge(PoseStack matrixstack, double x, double z, double
Matrix4d matrix4d = new Matrix4d();
matrixstack.last().pose().get(matrix4d);
Tesselator tess = Tesselator.getInstance();
BufferBuilder bufferBuilder = tess.getBuilder();
Minecraft minecraft = Minecraft.getInstance();

Camera camera = minecraft.gameRenderer.getMainCamera();
Expand All @@ -112,7 +111,7 @@ public static void renderEdge(PoseStack matrixstack, double x, double z, double

z -= cameraZ;

bufferBuilder.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR);
BufferBuilder bufferBuilder = tess.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR);

float r = ((float) ((color >> 16) & 0xFF)) / 255F;
float g = ((float) ((color >> 8) & 0xFF)) / 255F;
Expand All @@ -121,14 +120,16 @@ public static void renderEdge(PoseStack matrixstack, double x, double z, double
drawVertex(bufferBuilder, matrix4d, x, h3, z, r, g, b);
drawVertex(bufferBuilder, matrix4d, x, h, z, r, g, b);

tess.end();
MeshData meshData = bufferBuilder.build();
if (meshData != null) {
BufferUploader.drawWithShader(meshData);
}
}

public static void renderGrid(PoseStack matrixstack, float x0, float y0, float z0, float x1, float y1, float z1, float step, int color) {
Matrix4d matrix4d = new Matrix4d();
matrixstack.last().pose().get(matrix4d);
Tesselator tess = Tesselator.getInstance();
BufferBuilder renderer = tess.getBuilder();
Minecraft minecraft = Minecraft.getInstance();

Camera camera = minecraft.gameRenderer.getMainCamera();
Expand All @@ -137,7 +138,7 @@ public static void renderGrid(PoseStack matrixstack, float x0, float y0, float z
double cameraZ = camera.getPosition().z;


renderer.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR);
BufferBuilder renderer = tess.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR);
float r = ((float) ((color >> 16) & 0xFF)) / 255F;
float g = ((float) ((color >> 8) & 0xFF)) / 255F;
float b = ((float) (color & 0xFF)) / 255F;
Expand Down Expand Up @@ -175,11 +176,15 @@ public static void renderGrid(PoseStack matrixstack, float x0, float y0, float z
drawVertex(renderer, matrix4d, x1 - cameraX, y0 - cameraY, z - cameraZ, r, g, b);
drawVertex(renderer, matrix4d, x1 - cameraX, y1 - cameraY, z - cameraZ, r, g, b);
}
tess.end();

MeshData meshData = renderer.build();
if (meshData != null) {
BufferUploader.drawWithShader(meshData);
}
}

private static void drawVertex(BufferBuilder renderer, Matrix4d matrix, double x, double y, double z, float r, float g, float b) {
Vector4d vector4d = matrix.transform(new Vector4d(x, y, z, 1.0D));
renderer.vertex(vector4d.x(), vector4d.y(), vector4d.z()).color(r, g, b, 1).endVertex();
renderer.addVertex((float)vector4d.x(), (float)vector4d.y(), (float)vector4d.z()).setColor(r, g, b, 1);
}
}
65 changes: 34 additions & 31 deletions src/client/java/at/ridgo8/moreoverlays/itemsearch/GuiRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ private void drawSearchFrame(EditBox textField, PoseStack matrixstack) {
RenderSystem.setShader(GameRenderer::getPositionColorShader);

Tesselator tess = Tesselator.getInstance();
BufferBuilder renderer = tess.getBuilder();

float x = textField.getX() - 2;
float y = textField.getY() - 4;
Expand All @@ -92,28 +91,31 @@ private void drawSearchFrame(EditBox textField, PoseStack matrixstack) {
float g = ((float) ((0xFFFF00 >> 8) & 0xFF)) / 255F;
float b = ((float) (0xFFFF00 & 0xFF)) / 255F;

renderer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
renderer.vertex(matrix4f, x + width + FRAME_RADIUS, y - FRAME_RADIUS, 1000).color(r, g, b, 1F).endVertex();
renderer.vertex(matrix4f, x - FRAME_RADIUS, y - FRAME_RADIUS, 1000).color(r, g, b, 1F).endVertex();
renderer.vertex(matrix4f, x - FRAME_RADIUS, y, 1000).color(r, g, b, 1F).endVertex();
renderer.vertex(matrix4f, x + width + FRAME_RADIUS, y, 1000).color(r, g, b, 1F).endVertex();

renderer.vertex(matrix4f, x, y, 1000).color(r, g, b, 1F).endVertex();
renderer.vertex(matrix4f, x - FRAME_RADIUS, y, 1000).color(r, g, b, 1F).endVertex();
renderer.vertex(matrix4f, x - FRAME_RADIUS, y + height, 1000).color(r, g, b, 1F).endVertex();
renderer.vertex(matrix4f, x, y + height, 1000).color(r, g, b, 1F).endVertex();

renderer.vertex(matrix4f, x + width + FRAME_RADIUS, y + height, 1000).color(r, g, b, 1F).endVertex();
renderer.vertex(matrix4f, x - FRAME_RADIUS, y + height, 1000).color(r, g, b, 1F).endVertex();
renderer.vertex(matrix4f, x - FRAME_RADIUS, y + height + FRAME_RADIUS, 1000).color(r, g, b, 1F).endVertex();
renderer.vertex(matrix4f, x + width + FRAME_RADIUS, y + height + FRAME_RADIUS, 1000).color(r, g, b, 1F).endVertex();

renderer.vertex(matrix4f, x + width + FRAME_RADIUS, y, 1000).color(r, g, b, 1F).endVertex();
renderer.vertex(matrix4f, x + width, y, 1000).color(r, g, b, 1F).endVertex();
renderer.vertex(matrix4f, x + width, y + height, 1000).color(r, g, b, 1F).endVertex();
renderer.vertex(matrix4f, x + width + FRAME_RADIUS, y + height, 1000).color(r, g, b, 1F).endVertex();

tess.end();
BufferBuilder renderer = tess.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
renderer.addVertex(matrix4f, x + width + FRAME_RADIUS, y - FRAME_RADIUS, 1000).setColor(r, g, b, 1F);
renderer.addVertex(matrix4f, x - FRAME_RADIUS, y - FRAME_RADIUS, 1000).setColor(r, g, b, 1F);
renderer.addVertex(matrix4f, x - FRAME_RADIUS, y, 1000).setColor(r, g, b, 1F);
renderer.addVertex(matrix4f, x + width + FRAME_RADIUS, y, 1000).setColor(r, g, b, 1F);

renderer.addVertex(matrix4f, x, y, 1000).setColor(r, g, b, 1F);
renderer.addVertex(matrix4f, x - FRAME_RADIUS, y, 1000).setColor(r, g, b, 1F);
renderer.addVertex(matrix4f, x - FRAME_RADIUS, y + height, 1000).setColor(r, g, b, 1F);
renderer.addVertex(matrix4f, x, y + height, 1000).setColor(r, g, b, 1F);

renderer.addVertex(matrix4f, x + width + FRAME_RADIUS, y + height, 1000).setColor(r, g, b, 1F);
renderer.addVertex(matrix4f, x - FRAME_RADIUS, y + height, 1000).setColor(r, g, b, 1F);
renderer.addVertex(matrix4f, x - FRAME_RADIUS, y + height + FRAME_RADIUS, 1000).setColor(r, g, b, 1F);
renderer.addVertex(matrix4f, x + width + FRAME_RADIUS, y + height + FRAME_RADIUS, 1000).setColor(r, g, b, 1F);

renderer.addVertex(matrix4f, x + width + FRAME_RADIUS, y, 1000).setColor(r, g, b, 1F);
renderer.addVertex(matrix4f, x + width, y, 1000).setColor(r, g, b, 1F);
renderer.addVertex(matrix4f, x + width, y + height, 1000).setColor(r, g, b, 1F);
renderer.addVertex(matrix4f, x + width + FRAME_RADIUS, y + height, 1000).setColor(r, g, b, 1F);

MeshData meshData = renderer.build();
if (meshData != null) {
BufferUploader.drawWithShader(meshData);
}

RenderSystem.disableBlend();
RenderSystem.enableDepthTest();
Expand All @@ -135,13 +137,12 @@ private void drawSlotOverlay(AbstractContainerScreen<?> gui) {
return;

Tesselator tess = Tesselator.getInstance();
BufferBuilder renderer = tess.getBuilder();

RenderSystem.enableBlend();

RenderSystem.setShader(GameRenderer::getPositionColorShader);

renderer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
BufferBuilder renderer = tess.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);

float r = ((float) ((0x000000 >> 16) & 0xFF)) / 255F;
float g = ((float) ((0x000000 >> 8) & 0xFF)) / 255F;
Expand All @@ -153,15 +154,17 @@ private void drawSlotOverlay(AbstractContainerScreen<?> gui) {
Vec2 posvec = slot.getValue().getView().getRenderPos(guiOffsetX, guiOffsetY);
float px = posvec.x;
float py = posvec.y;
renderer.vertex(px + 16 + guiOffsetX, py + guiOffsetY, OVERLAY_ZLEVEL).color(r, g, b, a).endVertex();
renderer.vertex(px + guiOffsetX, py + guiOffsetY, OVERLAY_ZLEVEL).color(r, g, b, a).endVertex();
renderer.vertex(px + guiOffsetX, py + 16 + guiOffsetY, OVERLAY_ZLEVEL).color(r, g, b, a).endVertex();
renderer.vertex(px + 16 + guiOffsetX, py + 16 + guiOffsetY, OVERLAY_ZLEVEL).color(r, g, b, a).endVertex();
renderer.addVertex(px + 16 + guiOffsetX, py + guiOffsetY, OVERLAY_ZLEVEL).setColor(r, g, b, a);
renderer.addVertex(px + guiOffsetX, py + guiOffsetY, OVERLAY_ZLEVEL).setColor(r, g, b, a);
renderer.addVertex(px + guiOffsetX, py + 16 + guiOffsetY, OVERLAY_ZLEVEL).setColor(r, g, b, a);
renderer.addVertex(px + 16 + guiOffsetX, py + 16 + guiOffsetY, OVERLAY_ZLEVEL).setColor(r, g, b, a);
}
}

tess.end();

MeshData meshData = renderer.build();
if (meshData != null) {
BufferUploader.drawWithShader(meshData);
}

RenderSystem.disableBlend();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static Collection<EnchantmentInstance> getEnchantmentData(ItemEnchantment
int level = nbt.value().getMaxLevel();

if (nbt.value() != null && level > 0) {
enchantments.add(new EnchantmentInstance(nbt.value(), level));
enchantments.add(new EnchantmentInstance(nbt, level));
}
}
return enchantments;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ public void registerCategories(IRecipeCategoryRegistration registration) {

@Override
public ResourceLocation getPluginUid() {
return new ResourceLocation(MoreOverlays.MOD_ID, "jei_module");
return ResourceLocation.fromNamespaceAndPath(MoreOverlays.MOD_ID, "jei_module");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class LightOverlayRenderer implements ILightRenderer {

public LightOverlayRenderer() {
tess = Tesselator.getInstance();
renderer = tess.getBuilder();
renderer = tess.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR);
minecraft = Minecraft.getInstance();
}

Expand Down Expand Up @@ -78,13 +78,13 @@ private static void renderCross(PoseStack matrixstack, BlockPos pos, float r, fl

private static void drawVertex(Matrix4d matrix, double x, double y, double z, float r, float g, float b) {
Vector4d vector4d = matrix.transform(new Vector4d(x, y, z, 1.0D));
renderer.vertex(vector4d.x(), vector4d.y(), vector4d.z()).color(r, g, b, 1).endVertex();
renderer.addVertex((float)vector4d.x(), (float)vector4d.y(), (float)vector4d.z()).setColor(r, g, b, 1);
}

public void renderOverlays(ILightScanner scanner, PoseStack matrixstack) {
RenderSystem.enableDepthTest();
RenderSystem.disableBlend();
RenderSystem.lineWidth((float) (double) Config.render_chunkLineWidth);
RenderSystem.lineWidth((float) Config.render_chunkLineWidth);
RenderSystem.setShader(GameRenderer::getPositionColorShader);

float ar = ((float) ((Config.render_spawnAColor >> 16) & 0xFF)) / 255F;
Expand All @@ -95,7 +95,7 @@ public void renderOverlays(ILightScanner scanner, PoseStack matrixstack) {
float ng = ((float) ((Config.render_spawnNColor >> 8) & 0xFF)) / 255F;
float nb = ((float) (Config.render_spawnNColor & 0xFF)) / 255F;

renderer.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR);
renderer = tess.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR);
for (Pair<BlockPos, Byte> entry : scanner.getLightModes()) {
Byte mode = entry.getValue();
if (mode == null || mode == 0)
Expand All @@ -105,7 +105,12 @@ else if (mode == 1)
else if (mode == 2)
renderCross(matrixstack, entry.getKey(), ar, ag, ab);
}
tess.end();

MeshData meshData = renderer.build();
if (meshData != null) {
BufferUploader.drawWithShader(meshData);
}

// restore render settings
RenderSystem.depthMask(true);
RenderSystem.lineWidth(1.0F);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import java.lang.reflect.Field;

import net.minecraft.client.DeltaTracker;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -20,7 +21,7 @@
@Mixin(Gui.class)
public class MixinOverlayRenderer {
@Inject(at = @At("TAIL"), method = "render")
private void onRender(GuiGraphics guiGraphics, float f, CallbackInfo ci) {
private void onRender(GuiGraphics guiGraphics, DeltaTracker deltaTracker, CallbackInfo ci) {
Minecraft mc = Minecraft.getInstance();
try {
if (mc.getDebugOverlay().showDebugScreen()) {
Expand Down
4 changes: 2 additions & 2 deletions src/client/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
],
"depends": {
"fabricloader": ">=0.15.0",
"minecraft": "~1.20",
"java": ">=17",
"minecraft": "~1.21",
"java": ">=21",
"fabric-api": "*"
}
}
2 changes: 1 addition & 1 deletion src/client/resources/moreoverlays.main.mixins.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"required": false,
"package": "at.ridgo8.moreoverlays.mixin.client",
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_21",
"client": [
"MixinDebugRenderer",
"MixinOverlayRenderer",
Expand Down

0 comments on commit 901a364

Please sign in to comment.