From f91034596a5500ff5fda8d329bb551f2d9e2905b Mon Sep 17 00:00:00 2001 From: tr7zw Date: Fri, 6 Sep 2024 22:00:20 +0200 Subject: [PATCH] Fix map rendering --- .../notenoughanimations/util/MapRenderer.java | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/main/java/dev/tr7zw/notenoughanimations/util/MapRenderer.java b/src/main/java/dev/tr7zw/notenoughanimations/util/MapRenderer.java index d5298ca..1a61727 100644 --- a/src/main/java/dev/tr7zw/notenoughanimations/util/MapRenderer.java +++ b/src/main/java/dev/tr7zw/notenoughanimations/util/MapRenderer.java @@ -7,7 +7,6 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.MapItem; import net.minecraft.world.level.saveddata.maps.MapItemSavedData; @@ -66,16 +65,16 @@ public static void renderFirstPersonMap(PoseStack matrices, MultiBufferSource ve com.mojang.blaze3d.vertex.VertexConsumer vertexConsumer = vertexConsumers .getBuffer(mapState == null ? MAP_BACKGROUND : MAP_BACKGROUND_CHECKERBOARD); Matrix4f matrix4f = matrices.last().pose(); - NMSHelper.addVertex(vertexConsumer, matrix4f, -7.0f, 135.0f, 0.0f, 255, 255, 255, 255, 0, 1, light); - NMSHelper.addVertex(vertexConsumer, matrix4f, 135.0f, 135.0f, 0.0f, 255, 255, 255, 255, 1, 1, light); - NMSHelper.addVertex(vertexConsumer, matrix4f, 135.0f, -7.0f, 0.0f, 255, 255, 255, 255, 1, 0, light); - NMSHelper.addVertex(vertexConsumer, matrix4f, -7.0f, -7.0f, 0.0f, 255, 255, 255, 255, 0, 0, light); + addVertex(vertexConsumer, matrix4f, -7.0f, 135.0f, 0.0f, 0, 1, light); + addVertex(vertexConsumer, matrix4f, 135.0f, 135.0f, 0.0f, 1, 1, light); + addVertex(vertexConsumer, matrix4f, 135.0f, -7.0f, 0.0f, 1, 0, light); + addVertex(vertexConsumer, matrix4f, -7.0f, -7.0f, 0.0f, 0, 0, light); // mirrored back site vertexConsumer = vertexConsumers.getBuffer(MAP_BACKGROUND); - NMSHelper.addVertex(vertexConsumer, matrix4f, -7.0f, -7.0f, 0.0f, 255, 255, 255, 255, 0, 0, light); - NMSHelper.addVertex(vertexConsumer, matrix4f, 135.0f, -7.0f, 0.0f, 255, 255, 255, 255, 1, 0, light); - NMSHelper.addVertex(vertexConsumer, matrix4f, 135.0f, 135.0f, 0.0f, 255, 255, 255, 255, 1, 1, light); - NMSHelper.addVertex(vertexConsumer, matrix4f, -7.0f, 135.0f, 0.0f, 255, 255, 255, 255, 0, 1, light); + addVertex(vertexConsumer, matrix4f, -7.0f, -7.0f, 0.0f, 0, 0, light); + addVertex(vertexConsumer, matrix4f, 135.0f, -7.0f, 0.0f, 1, 0, light); + addVertex(vertexConsumer, matrix4f, 135.0f, 135.0f, 0.0f, 1, 1, light); + addVertex(vertexConsumer, matrix4f, -7.0f, 135.0f, 0.0f, 0, 1, light); if (mapState != null) { // spotless:off @@ -87,5 +86,16 @@ public static void renderFirstPersonMap(PoseStack matrices, MultiBufferSource ve //spotless:on } } + + public static void addVertex(VertexConsumer cons, Matrix4f matrix4f, float x, float y, float z, float u, float v, int lightmapUV) { + // spotless:off + //#if MC >= 12100 + cons.addVertex(matrix4f, x, y, z).setColor(-1).setUv(u, v).setLight(lightmapUV); + //#else + //$$ cons.vertex(matrix4f, x, y, z).color(255, 255, 255, 255).uv(u, v).uv2(lightmapUV) + //$$ .endVertex(); + //#endif + //spotless:on + } }