diff --git a/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/CapturingTessellator.java b/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/CapturingTessellator.java index cbeb6e23..f166fb18 100644 --- a/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/CapturingTessellator.java +++ b/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/CapturingTessellator.java @@ -8,12 +8,14 @@ import static com.gtnewhorizon.gtnhlib.client.renderer.cel.util.ModelQuadUtil.TE import static com.gtnewhorizon.gtnhlib.client.renderer.cel.util.ModelQuadUtil.vertexOffset; import static net.minecraft.util.MathHelper.clamp_int; +import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.ModelQuadView; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.reflect.Field; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.Arrays; +import java.util.Collections; import java.util.List; import net.minecraft.client.renderer.Tessellator; @@ -138,8 +140,8 @@ public class CapturingTessellator extends Tessellator implements ITessellatorIns reset(); } - public List getQuads() { - return collectedQuads; + public List getQuads() { + return Collections.unmodifiableList(collectedQuads); } public void clearQuads() { @@ -150,7 +152,7 @@ public class CapturingTessellator extends Tessellator implements ITessellatorIns this.collectedQuads.clear(); } - public static ByteBuffer quadsToBuffer(List quads, VertexFormat format) { + public static ByteBuffer quadsToBuffer(List quads, VertexFormat format) { if (!format.canWriteQuads()) { throw new IllegalStateException("Vertex format has no quad writer: " + format); } diff --git a/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/TessellatorManager.java b/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/TessellatorManager.java index 44eb330f..c10b2c2b 100644 --- a/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/TessellatorManager.java +++ b/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/TessellatorManager.java @@ -1,15 +1,12 @@ package com.gtnewhorizon.gtnhlib.client.renderer; -import java.nio.ByteBuffer; -import java.util.List; - -import net.minecraft.client.renderer.Tessellator; - -import org.lwjgl.opengl.GL11; - -import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.ModelQuad; +import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.ModelQuadView; import com.gtnewhorizon.gtnhlib.client.renderer.vbo.VertexBuffer; import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat; +import java.nio.ByteBuffer; +import java.util.List; +import net.minecraft.client.renderer.Tessellator; +import org.lwjgl.opengl.GL11; @SuppressWarnings("unused") public class TessellatorManager { @@ -57,7 +54,9 @@ public class TessellatorManager { /// Stop the CapturingTessellator and return the pooled quads. The quads are valid until clearQuads() is called on /// the CapturingTesselator, which must be done before starting capturing again. - public static List stopCapturingToPooledQuads() { + /// + /// @return The quads captured. This list is not copied, and thus should *not* be modified by callers. + public static List stopCapturingToPooledQuads() { if (!currentlyCapturing.get()) throw new IllegalStateException("Tried to stop capturing when not capturing!"); currentlyCapturing.set(false); final CapturingTessellator tess = capturingTessellator.get(); @@ -65,7 +64,7 @@ public class TessellatorManager { // Be sure we got all the quads if (tess.isDrawing) tess.draw(); - final List quads = tess.getQuads(); + final var quads = tess.getQuads(); tess.discard(); tess.restoreTranslation();