From 64ef95cddabe0c76aee062d3f77ba47cd3890b7b Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Sun, 3 Sep 2023 17:18:45 -0400 Subject: [PATCH] Ignore undersized quads --- .../buffer_builder/intrinsics/BufferBuilderMixin.java | 8 ++++++++ .../render/model/block/BlockModelRendererMixin.java | 5 +++++ .../features/render/model/item/ItemRendererMixin.java | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/src/main/java/me/jellysquid/mods/sodium/mixin/features/render/immediate/buffer_builder/intrinsics/BufferBuilderMixin.java b/src/main/java/me/jellysquid/mods/sodium/mixin/features/render/immediate/buffer_builder/intrinsics/BufferBuilderMixin.java index b034000980..44cf4cab63 100644 --- a/src/main/java/me/jellysquid/mods/sodium/mixin/features/render/immediate/buffer_builder/intrinsics/BufferBuilderMixin.java +++ b/src/main/java/me/jellysquid/mods/sodium/mixin/features/render/immediate/buffer_builder/intrinsics/BufferBuilderMixin.java @@ -32,6 +32,10 @@ public void quad(MatrixStack.Entry matrices, BakedQuad bakedQuad, float r, float throw new IllegalStateException(); } + if (bakedQuad.getVertexData().length < 32) { + return; // we do not accept quads with less than 4 properly sized vertices + } + VertexBufferWriter writer = VertexBufferWriter.of(this); ModelQuadView quad = (ModelQuadView) bakedQuad; @@ -56,6 +60,10 @@ public void quad(MatrixStack.Entry matrices, BakedQuad bakedQuad, float[] bright throw new IllegalStateException(); } + if (bakedQuad.getVertexData().length < 32) { + return; // we do not accept quads with less than 4 properly sized vertices + } + VertexBufferWriter writer = VertexBufferWriter.of(this); ModelQuadView quad = (ModelQuadView) bakedQuad; diff --git a/src/main/java/me/jellysquid/mods/sodium/mixin/features/render/model/block/BlockModelRendererMixin.java b/src/main/java/me/jellysquid/mods/sodium/mixin/features/render/model/block/BlockModelRendererMixin.java index 54dad6b1c7..4f790ad2a5 100644 --- a/src/main/java/me/jellysquid/mods/sodium/mixin/features/render/model/block/BlockModelRendererMixin.java +++ b/src/main/java/me/jellysquid/mods/sodium/mixin/features/render/model/block/BlockModelRendererMixin.java @@ -74,6 +74,11 @@ private void renderFast(MatrixStack.Entry entry, VertexConsumer vertexConsumer, private static void renderQuads(MatrixStack.Entry matrices, VertexBufferWriter writer, int defaultColor, List quads, int light, int overlay) { for (int i = 0; i < quads.size(); i++) { BakedQuad bakedQuad = quads.get(i); + + if (bakedQuad.getVertexData().length < 32) { + continue; // ignore bad quads + } + BakedQuadView quad = (BakedQuadView) bakedQuad; int color = quad.hasColor() ? defaultColor : 0xFFFFFFFF; diff --git a/src/main/java/me/jellysquid/mods/sodium/mixin/features/render/model/item/ItemRendererMixin.java b/src/main/java/me/jellysquid/mods/sodium/mixin/features/render/model/item/ItemRendererMixin.java index 1c0e3f9f18..196d4af0ab 100644 --- a/src/main/java/me/jellysquid/mods/sodium/mixin/features/render/model/item/ItemRendererMixin.java +++ b/src/main/java/me/jellysquid/mods/sodium/mixin/features/render/model/item/ItemRendererMixin.java @@ -80,6 +80,11 @@ private void renderModelFast(BakedModel model, ItemStack itemStack, int light, i private void renderBakedItemQuads(MatrixStack.Entry matrices, VertexBufferWriter writer, List quads, ItemStack itemStack, ItemColorProvider colorProvider, int light, int overlay) { for (int i = 0; i < quads.size(); i++) { BakedQuad bakedQuad = quads.get(i); + + if (bakedQuad.getVertexData().length < 32) { + continue; // ignore bad quads + } + BakedQuadView quad = (BakedQuadView) bakedQuad; int color = 0xFFFFFFFF;