aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/makamys
diff options
context:
space:
mode:
authormakamys <makamys@outlook.com>2022-06-03 13:11:12 +0200
committermakamys <makamys@outlook.com>2022-06-03 13:11:12 +0200
commit4371a8fb2bc0596d945c5f156d01fa44b56bcf8b (patch)
tree3e714123e3161e69be53f2e507524e228659c0e5 /src/main/java/makamys
parentd5b0ec39fda8bc53ecb44ff491eba6e0b096b296 (diff)
downloadNeodymium-4371a8fb2bc0596d945c5f156d01fa44b56bcf8b.tar.gz
Neodymium-4371a8fb2bc0596d945c5f156d01fa44b56bcf8b.tar.bz2
Neodymium-4371a8fb2bc0596d945c5f156d01fa44b56bcf8b.zip
Make it work without OptiFine
Diffstat (limited to 'src/main/java/makamys')
-rw-r--r--src/main/java/makamys/lodmod/MixinConfigPlugin.java73
-rw-r--r--src/main/java/makamys/lodmod/mixin/MixinRenderGlobal.java8
-rw-r--r--src/main/java/makamys/lodmod/mixin/MixinRenderGlobal_OptiFine.java24
-rw-r--r--src/main/java/makamys/lodmod/mixin/MixinTessellator.java4
4 files changed, 100 insertions, 9 deletions
diff --git a/src/main/java/makamys/lodmod/MixinConfigPlugin.java b/src/main/java/makamys/lodmod/MixinConfigPlugin.java
new file mode 100644
index 0000000..4d9fed1
--- /dev/null
+++ b/src/main/java/makamys/lodmod/MixinConfigPlugin.java
@@ -0,0 +1,73 @@
+package makamys.lodmod;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+import org.spongepowered.asm.lib.tree.ClassNode;
+import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
+import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
+
+public class MixinConfigPlugin implements IMixinConfigPlugin {
+
+ private static boolean isOptiFinePresent = MixinConfigPlugin.class.getResource("/optifine/OptiFineTweaker.class") != null;
+
+ @Override
+ public void onLoad(String mixinPackage) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String getRefMapperConfig() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
+ return true;
+ }
+
+ @Override
+ public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public List<String> getMixins() {
+ List<String> mixins = new ArrayList<>();
+ mixins.addAll(Arrays.asList("MixinChunkCache",
+ "MixinEntityRenderer",
+ "MixinRenderGlobal",
+ "MixinTessellator",
+ "MixinWorldRenderer",
+ "MixinRenderBlocks"));
+
+ if (isOptiFinePresent()) {
+ System.out.println("Detected OptiFine");
+ mixins.add("MixinRenderGlobal_OptiFine");
+ }
+
+ return mixins;
+ }
+
+ @Override
+ public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public static boolean isOptiFinePresent() {
+ return isOptiFinePresent;
+ }
+
+}
diff --git a/src/main/java/makamys/lodmod/mixin/MixinRenderGlobal.java b/src/main/java/makamys/lodmod/mixin/MixinRenderGlobal.java
index 39b435e..e03bc95 100644
--- a/src/main/java/makamys/lodmod/mixin/MixinRenderGlobal.java
+++ b/src/main/java/makamys/lodmod/mixin/MixinRenderGlobal.java
@@ -31,14 +31,6 @@ abstract class MixinRenderGlobal {
}
}
- // for OptiFine's Fast Render option
- @Redirect(method = "renderSortedRenderersFast", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glCallLists(Ljava/nio/IntBuffer;)V"), remap=false)
- private void redirectRenderAllRenderLists(IntBuffer buffer) {
- if(!LODMod.isActive() || (LODMod.isActive() && LODMod.renderer.renderWorld)) {
- GL11.glCallLists(buffer);
- }
- }
-
@Inject(method = "renderSortedRenderers", at = @At(value = "HEAD"))
public void preRenderSortedRenderers(int startRenderer, int numRenderers, int renderPass, double partialTickTime, CallbackInfoReturnable cir) {
if(LODMod.isActive()) {
diff --git a/src/main/java/makamys/lodmod/mixin/MixinRenderGlobal_OptiFine.java b/src/main/java/makamys/lodmod/mixin/MixinRenderGlobal_OptiFine.java
new file mode 100644
index 0000000..f1742be
--- /dev/null
+++ b/src/main/java/makamys/lodmod/mixin/MixinRenderGlobal_OptiFine.java
@@ -0,0 +1,24 @@
+package makamys.lodmod.mixin;
+
+import java.nio.IntBuffer;
+
+import org.lwjgl.opengl.GL11;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Redirect;
+
+import makamys.lodmod.LODMod;
+import net.minecraft.client.renderer.RenderBlocks;
+
+@Mixin(RenderBlocks.class)
+abstract class MixinRenderGlobal_OptiFine {
+
+ // for OptiFine's Fast Render option
+ @Redirect(method = "renderSortedRenderersFast", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glCallLists(Ljava/nio/IntBuffer;)V"), remap=false)
+ private void redirectRenderAllRenderLists(IntBuffer buffer) {
+ if(!LODMod.isActive() || (LODMod.isActive() && LODMod.renderer.renderWorld)) {
+ GL11.glCallLists(buffer);
+ }
+ }
+
+}
diff --git a/src/main/java/makamys/lodmod/mixin/MixinTessellator.java b/src/main/java/makamys/lodmod/mixin/MixinTessellator.java
index d791ba9..9bb8e77 100644
--- a/src/main/java/makamys/lodmod/mixin/MixinTessellator.java
+++ b/src/main/java/makamys/lodmod/mixin/MixinTessellator.java
@@ -7,6 +7,7 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import makamys.lodmod.LODMod;
+import makamys.lodmod.MixinConfigPlugin;
import makamys.lodmod.ducks.ITessellator;
import makamys.lodmod.renderer.ChunkMesh;
import makamys.lodmod.renderer.MeshQuad;
@@ -79,7 +80,8 @@ abstract class MixinTessellator implements ITessellator {
int zOffset = wr.posZ;
for(int quadI = 0; quadI < this.vertexCount / 4; quadI++) {
- MeshQuad quad = new MeshQuad(rawBuffer, quadI * 32, new ChunkMesh.Flags(hasTexture, hasBrightness, hasColor, hasNormals), xOffset, yOffset, zOffset);
+ 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);
/*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;
}*/