Skip to content

Commit

Permalink
Fix map rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
tr7zw committed Sep 6, 2024
1 parent 6a2d493 commit f910345
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/main/java/dev/tr7zw/notenoughanimations/util/MapRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
}

}

0 comments on commit f910345

Please sign in to comment.