aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/anthonyhilyard/iceberg/renderer/CheckedBufferSourceSodium.java
diff options
context:
space:
mode:
authorAnthony Hilyard <anthony.hilyard@gmail.com>2023-03-29 23:12:14 -0700
committerAnthony Hilyard <anthony.hilyard@gmail.com>2023-03-29 23:12:14 -0700
commit81ee44c7b9297e24cf7b3e8be3452d06d4d7a7ac (patch)
treece0352c615677bd5b9bebfcdfbca1a72bd6ebc6d /src/main/java/com/anthonyhilyard/iceberg/renderer/CheckedBufferSourceSodium.java
parentb0d1aa6d5076738965f1f0fd9df98c6cd5bf946f (diff)
downloadIceberg-81ee44c7b9297e24cf7b3e8be3452d06d4d7a7ac.tar.gz
Iceberg-81ee44c7b9297e24cf7b3e8be3452d06d4d7a7ac.tar.bz2
Iceberg-81ee44c7b9297e24cf7b3e8be3452d06d4d7a7ac.zip
Fixed several 3d item preview issues.
Diffstat (limited to 'src/main/java/com/anthonyhilyard/iceberg/renderer/CheckedBufferSourceSodium.java')
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/renderer/CheckedBufferSourceSodium.java67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/main/java/com/anthonyhilyard/iceberg/renderer/CheckedBufferSourceSodium.java b/src/main/java/com/anthonyhilyard/iceberg/renderer/CheckedBufferSourceSodium.java
new file mode 100644
index 0000000..2a37254
--- /dev/null
+++ b/src/main/java/com/anthonyhilyard/iceberg/renderer/CheckedBufferSourceSodium.java
@@ -0,0 +1,67 @@
+package com.anthonyhilyard.iceberg.renderer;
+
+import org.lwjgl.system.MemoryStack;
+
+import com.mojang.blaze3d.vertex.VertexConsumer;
+
+import net.minecraft.client.renderer.MultiBufferSource;
+import net.minecraft.client.renderer.RenderType;
+
+import me.jellysquid.mods.sodium.client.render.vertex.VertexBufferWriter;
+import me.jellysquid.mods.sodium.client.render.vertex.VertexFormatDescription;
+
+public final class CheckedBufferSourceSodium extends CheckedBufferSource
+{
+ protected CheckedBufferSourceSodium(MultiBufferSource bufferSource)
+ {
+ super(bufferSource);
+ }
+
+ @Override
+ public VertexConsumer getBuffer(RenderType renderType)
+ {
+ final VertexConsumer vertexConsumer = bufferSource.getBuffer(renderType);
+ VertexConsumer vertexConsumerWrap = new VertexConsumerSodium()
+ {
+ @Override
+ public VertexConsumer vertex(double x, double y, double z)
+ {
+ hasRendered = true;
+ return vertexConsumer.vertex(x, y, z);
+ }
+
+ @Override
+ public VertexConsumer color(int r, int g, int b, int a) { return vertexConsumer.color(r, g, b, a); }
+
+ @Override
+ public VertexConsumer uv(float u, float v) { return vertexConsumer.uv(u, v); }
+
+ @Override
+ public VertexConsumer overlayCoords(int x, int y) { return vertexConsumer.overlayCoords(x, y); }
+
+ @Override
+ public VertexConsumer uv2(int u, int v) { return vertexConsumer.uv2(u, v); }
+
+ @Override
+ public VertexConsumer normal(float x, float y, float z) { return vertexConsumer.normal(x, y, z); }
+
+ @Override
+ public void endVertex() { vertexConsumer.endVertex(); }
+
+ @Override
+ public void defaultColor(int r, int g, int b, int a) { vertexConsumer.defaultColor(r, g, b, a); }
+
+ @Override
+ public void unsetDefaultColor() { vertexConsumer.unsetDefaultColor(); }
+
+ @Override
+ public void push(MemoryStack memoryStack, long pointer, int count, VertexFormatDescription format)
+ {
+ hasRendered = true;
+ ((VertexBufferWriter)vertexConsumer).push(memoryStack, pointer, count, format);
+ }
+ };
+
+ return vertexConsumerWrap;
+ }
+} \ No newline at end of file