From 008b09891a544131ec62adb9f41f8ab14f4cce88 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Mon, 14 Oct 2024 17:44:55 -0400 Subject: [PATCH] fix meshemitter --- .../flywheel/lib/model/baked/MeshEmitter.java | 9 ++++++--- .../flywheel/lib/model/baked/MeshEmitter.java | 8 +++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/fabric/src/lib/java/dev/engine_room/flywheel/lib/model/baked/MeshEmitter.java b/fabric/src/lib/java/dev/engine_room/flywheel/lib/model/baked/MeshEmitter.java index dd5094466..9f0c7e2d0 100644 --- a/fabric/src/lib/java/dev/engine_room/flywheel/lib/model/baked/MeshEmitter.java +++ b/fabric/src/lib/java/dev/engine_room/flywheel/lib/model/baked/MeshEmitter.java @@ -31,7 +31,9 @@ class MeshEmitter { public void end() { if (((BufferBuilderAccessor) bufferBuilder).flywheel$getBuilding()) { emit(); + bufferBuilder = new BufferBuilder(byteBufferBuilder, VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK); } + resultConsumer = null; } @@ -41,10 +43,11 @@ class MeshEmitter { } void prepareForGeometry(boolean shade) { - bufferBuilder = new BufferBuilder(byteBufferBuilder, VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK); - - if (((BufferBuilderAccessor) bufferBuilder).flywheel$getBuilding() && shade != currentShade) { + if (!((BufferBuilderAccessor) bufferBuilder).flywheel$getBuilding()) { + bufferBuilder = new BufferBuilder(byteBufferBuilder, VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK); + } else if (shade != currentShade) { emit(); + bufferBuilder = new BufferBuilder(byteBufferBuilder, VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK); } currentShade = shade; diff --git a/forge/src/lib/java/dev/engine_room/flywheel/lib/model/baked/MeshEmitter.java b/forge/src/lib/java/dev/engine_room/flywheel/lib/model/baked/MeshEmitter.java index 3426a4947..204df5b35 100644 --- a/forge/src/lib/java/dev/engine_room/flywheel/lib/model/baked/MeshEmitter.java +++ b/forge/src/lib/java/dev/engine_room/flywheel/lib/model/baked/MeshEmitter.java @@ -34,6 +34,7 @@ class MeshEmitter implements VertexConsumer { public void end() { if (((BufferBuilderAccessor) bufferBuilder).flywheel$getBuilding()) { emit(); + bufferBuilder = new BufferBuilder(byteBufferBuilder, VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK); } resultConsumer = null; } @@ -44,10 +45,11 @@ class MeshEmitter implements VertexConsumer { } void prepareForGeometry(boolean shade) { - bufferBuilder = new BufferBuilder(byteBufferBuilder, VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK); - - if (((BufferBuilderAccessor) bufferBuilder).flywheel$getBuilding() && shade != currentShade) { + if (!((BufferBuilderAccessor) bufferBuilder).flywheel$getBuilding()) { + bufferBuilder = new BufferBuilder(byteBufferBuilder, VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK); + } else if (shade != currentShade) { emit(); + bufferBuilder = new BufferBuilder(byteBufferBuilder, VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK); } currentShade = shade;