aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/anthonyhilyard/iceberg/renderer/CheckedBufferSource.java
diff options
context:
space:
mode:
authorAnthony Hilyard <anthony.hilyard@gmail.com>2023-04-09 13:22:32 -0700
committerAnthony Hilyard <anthony.hilyard@gmail.com>2023-04-09 13:22:32 -0700
commitc205088078971c5bb1f4be084e1fe314dc7dad3b (patch)
tree70008c843678d1506b701703c87d466c780a8e3b /src/main/java/com/anthonyhilyard/iceberg/renderer/CheckedBufferSource.java
parent94e0927f324032c49a610f41c6055e56a0823321 (diff)
downloadIceberg-c205088078971c5bb1f4be084e1fe314dc7dad3b.tar.gz
Iceberg-c205088078971c5bb1f4be084e1fe314dc7dad3b.tar.bz2
Iceberg-c205088078971c5bb1f4be084e1fe314dc7dad3b.zip
Ported changes from 1.1.5. 3D item renderer now supports most items
that spawn entities.
Diffstat (limited to 'src/main/java/com/anthonyhilyard/iceberg/renderer/CheckedBufferSource.java')
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/renderer/CheckedBufferSource.java47
1 files changed, 43 insertions, 4 deletions
diff --git a/src/main/java/com/anthonyhilyard/iceberg/renderer/CheckedBufferSource.java b/src/main/java/com/anthonyhilyard/iceberg/renderer/CheckedBufferSource.java
index 5d34821..ffffdec 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/renderer/CheckedBufferSource.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/renderer/CheckedBufferSource.java
@@ -1,20 +1,59 @@
package com.anthonyhilyard.iceberg.renderer;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
+
+import com.anthonyhilyard.iceberg.Loader;
+
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
+import net.minecraftforge.fml.ModList;
-public final class CheckedBufferSource implements MultiBufferSource
+public class CheckedBufferSource implements MultiBufferSource
{
- private boolean hasRendered = false;
- private final MultiBufferSource bufferSource;
+ protected boolean hasRendered = false;
+ protected final MultiBufferSource bufferSource;
+
+ private static Boolean useSodiumVersion = null;
- public CheckedBufferSource(MultiBufferSource bufferSource)
+ protected CheckedBufferSource(MultiBufferSource bufferSource)
{
this.bufferSource = bufferSource;
}
+ public static CheckedBufferSource create(MultiBufferSource bufferSource)
+ {
+ if (useSodiumVersion == null)
+ {
+ try
+ {
+ // Check if Rubidium 0.6.4 is installed using Forge API.
+ useSodiumVersion = ModList.get().isLoaded("rubidium") && ModList.get().getModContainerById("rubidium").get().getModInfo().getVersion().equals(new DefaultArtifactVersion("0.6.4"));
+ }
+ catch (Exception e)
+ {
+ Loader.LOGGER.error(ExceptionUtils.getStackTrace(e));
+ }
+ }
+
+ if (useSodiumVersion)
+ {
+ // Instantiate the Rubidium implementation using reflection.
+ try
+ {
+ return (CheckedBufferSource) Class.forName("com.anthonyhilyard.iceberg.renderer.CheckedBufferSourceSodium").getDeclaredConstructor(MultiBufferSource.class).newInstance(bufferSource);
+ }
+ catch (Exception e)
+ {
+ Loader.LOGGER.error(ExceptionUtils.getStackTrace(e));
+ }
+ }
+
+ return new CheckedBufferSource(bufferSource);
+ }
+
@Override
public VertexConsumer getBuffer(RenderType renderType)
{