aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/makamys
diff options
context:
space:
mode:
authormakamys <makamys@outlook.com>2022-06-03 17:09:09 +0200
committermakamys <makamys@outlook.com>2022-06-03 17:09:09 +0200
commitb0f7f36a0b26f8ae0f6c238ae1a11f68d20efa1c (patch)
tree24dacd5df7b5ac5c0d3917c7e29bd9d91c103cb8 /src/main/java/makamys
parent4371a8fb2bc0596d945c5f156d01fa44b56bcf8b (diff)
downloadNeodymium-b0f7f36a0b26f8ae0f6c238ae1a11f68d20efa1c.tar.gz
Neodymium-b0f7f36a0b26f8ae0f6c238ae1a11f68d20efa1c.tar.bz2
Neodymium-b0f7f36a0b26f8ae0f6c238ae1a11f68d20efa1c.zip
Detect OptiFine fast render properly
Diffstat (limited to 'src/main/java/makamys')
-rw-r--r--src/main/java/makamys/lodmod/LODMod.java12
-rw-r--r--src/main/java/makamys/lodmod/mixin/MixinRenderGlobal_OptiFine.java3
-rw-r--r--src/main/java/makamys/lodmod/mixin/MixinTessellator.java4
3 files changed, 16 insertions, 3 deletions
diff --git a/src/main/java/makamys/lodmod/LODMod.java b/src/main/java/makamys/lodmod/LODMod.java
index 5c251e0..acdc45b 100644
--- a/src/main/java/makamys/lodmod/LODMod.java
+++ b/src/main/java/makamys/lodmod/LODMod.java
@@ -15,6 +15,7 @@ import net.minecraftforge.event.world.ChunkEvent;
import net.minecraftforge.event.world.WorldEvent;
import java.io.File;
+import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
@@ -64,6 +65,8 @@ public class LODMod
public static boolean fogEventWasPosted;
+ public static boolean ofFastRender;
+
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
@@ -162,6 +165,15 @@ public class LODMod
if(world != getRendererWorld()) {
onPlayerWorldChanged(world);
}
+
+ if(MixinConfigPlugin.isOptiFinePresent()) {
+ try {
+ ofFastRender = (boolean)Class.forName("Config").getMethod("isFastRender").invoke(null);
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException
+ | SecurityException | ClassNotFoundException e) {
+ // oops
+ }
+ }
}
}
diff --git a/src/main/java/makamys/lodmod/mixin/MixinRenderGlobal_OptiFine.java b/src/main/java/makamys/lodmod/mixin/MixinRenderGlobal_OptiFine.java
index f1742be..3ce0c4c 100644
--- a/src/main/java/makamys/lodmod/mixin/MixinRenderGlobal_OptiFine.java
+++ b/src/main/java/makamys/lodmod/mixin/MixinRenderGlobal_OptiFine.java
@@ -9,8 +9,9 @@ import org.spongepowered.asm.mixin.injection.Redirect;
import makamys.lodmod.LODMod;
import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraft.client.renderer.RenderGlobal;
-@Mixin(RenderBlocks.class)
+@Mixin(RenderGlobal.class)
abstract class MixinRenderGlobal_OptiFine {
// for OptiFine's Fast Render option
diff --git a/src/main/java/makamys/lodmod/mixin/MixinTessellator.java b/src/main/java/makamys/lodmod/mixin/MixinTessellator.java
index 9bb8e77..08d220a 100644
--- a/src/main/java/makamys/lodmod/mixin/MixinTessellator.java
+++ b/src/main/java/makamys/lodmod/mixin/MixinTessellator.java
@@ -80,8 +80,8 @@ abstract class MixinTessellator implements ITessellator {
int zOffset = wr.posZ;
for(int quadI = 0; quadI < this.vertexCount / 4; quadI++) {
- boolean of = MixinConfigPlugin.isOptiFinePresent();
- MeshQuad quad = new MeshQuad(rawBuffer, quadI * 32, new ChunkMesh.Flags(hasTexture, hasBrightness, hasColor, hasNormals), of ? xOffset : 0, of ? yOffset : 0, of ? zOffset : 0);
+ boolean fr = MixinConfigPlugin.isOptiFinePresent() && LODMod.ofFastRender;
+ MeshQuad quad = new MeshQuad(rawBuffer, quadI * 32, new ChunkMesh.Flags(hasTexture, hasBrightness, hasColor, hasNormals), fr ? xOffset : 0, fr ? yOffset : 0, fr ? zOffset : 0);
/*if(quad.bUs[0] == quad.bUs[1] && quad.bUs[1] == quad.bUs[2] && quad.bUs[2] == quad.bUs[3] && quad.bUs[3] == quad.bVs[0] && quad.bVs[0] == quad.bVs[1] && quad.bVs[1] == quad.bVs[2] && quad.bVs[2] == quad.bVs[3] && quad.bVs[3] == 0) {
quad.deleted = true;
}*/