aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/makamys
diff options
context:
space:
mode:
authormakamys <makamys@outlook.com>2021-05-10 13:44:38 +0200
committermakamys <makamys@outlook.com>2021-05-10 13:44:38 +0200
commitc95e989d793b81530343871a6062059f18bbffdb (patch)
tree75d4d18004992ded1de6b7fab3e6adbef43333a5 /src/main/java/makamys
parent53667f60256297c98ea0e58ec164ef922c702361 (diff)
downloadNeodymium-c95e989d793b81530343871a6062059f18bbffdb.tar.gz
Neodymium-c95e989d793b81530343871a6062059f18bbffdb.tar.bz2
Neodymium-c95e989d793b81530343871a6062059f18bbffdb.zip
Move my render hook before renderSortedRenderers
Diffstat (limited to 'src/main/java/makamys')
-rw-r--r--src/main/java/makamys/lodmod/mixin/MixinEntityRenderer.java9
-rw-r--r--src/main/java/makamys/lodmod/mixin/MixinRenderGlobal.java10
-rw-r--r--src/main/java/makamys/lodmod/renderer/LODRenderer.java17
3 files changed, 22 insertions, 14 deletions
diff --git a/src/main/java/makamys/lodmod/mixin/MixinEntityRenderer.java b/src/main/java/makamys/lodmod/mixin/MixinEntityRenderer.java
index 7a30512..eb3341a 100644
--- a/src/main/java/makamys/lodmod/mixin/MixinEntityRenderer.java
+++ b/src/main/java/makamys/lodmod/mixin/MixinEntityRenderer.java
@@ -22,13 +22,4 @@ abstract class MixinEntityRenderer {
farPlaneDistance *= LODMod.renderer.getFarPlaneDistanceMultiplier();
}
}
-
- @Inject(method = "renderWorld", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glAlphaFunc(IF)V", shift = At.Shift.AFTER, ordinal = 1))
- private void afterSortAndRender(float alpha, long something, CallbackInfo ci) {
- if(LODMod.isActive()) {
- Minecraft.getMinecraft().entityRenderer.enableLightmap((double)alpha);
- LODMod.renderer.beforeRenderTerrain(alpha);
- Minecraft.getMinecraft().entityRenderer.disableLightmap((double)alpha);
- }
- }
}
diff --git a/src/main/java/makamys/lodmod/mixin/MixinRenderGlobal.java b/src/main/java/makamys/lodmod/mixin/MixinRenderGlobal.java
index 51a8b11..0981974 100644
--- a/src/main/java/makamys/lodmod/mixin/MixinRenderGlobal.java
+++ b/src/main/java/makamys/lodmod/mixin/MixinRenderGlobal.java
@@ -2,9 +2,12 @@ package makamys.lodmod.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import makamys.lodmod.LODMod;
+import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.client.renderer.WorldRenderer;
@@ -28,4 +31,11 @@ abstract class MixinRenderGlobal {
}
return numba;
}
+
+ @Inject(method = "renderSortedRenderers", at = @At(value = "HEAD"))
+ public void preRenderSortedRenderers(int startRenderer, int numRenderers, int renderPass, double partialTickTime, CallbackInfoReturnable cir) {
+ if(LODMod.isActive()) {
+ LODMod.renderer.preRenderSortedRenderers(renderPass, partialTickTime);
+ }
+ }
}
diff --git a/src/main/java/makamys/lodmod/renderer/LODRenderer.java b/src/main/java/makamys/lodmod/renderer/LODRenderer.java
index 891f736..a821d73 100644
--- a/src/main/java/makamys/lodmod/renderer/LODRenderer.java
+++ b/src/main/java/makamys/lodmod/renderer/LODRenderer.java
@@ -37,6 +37,7 @@ import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.vector.Matrix4f;
+import makamys.lodmod.LODMod;
import makamys.lodmod.ducks.IWorldRenderer;
import makamys.lodmod.util.Util;
@@ -90,7 +91,11 @@ public class LODRenderer {
hasInited = init();
}
- public void beforeRenderTerrain(float alpha) {
+ public void preRenderSortedRenderers(int renderPass, double alpha) {
+ if(renderPass != 0) return;
+
+ Minecraft.getMinecraft().entityRenderer.enableLightmap((double)alpha);
+
if(hasInited) {
mainLoop();
handleKeyboard();
@@ -106,6 +111,8 @@ public class LODRenderer {
render(alpha);
}
}
+
+ Minecraft.getMinecraft().entityRenderer.disableLightmap((double)alpha);
}
private void sort() {
@@ -246,7 +253,7 @@ public class LODRenderer {
glBindVertexArray(0);
}
- private void render(float alpha) {
+ private void render(double alpha) {
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glDisable(GL11.GL_TEXTURE_2D);
@@ -303,9 +310,9 @@ public class LODRenderer {
float originZ = 0;
Entity rve = Minecraft.getMinecraft().renderViewEntity;
- double interpX = rve.lastTickPosX + (rve.posX - rve.lastTickPosX) * (double)alpha;
- double interpY = rve.lastTickPosY + (rve.posY - rve.lastTickPosY) * (double)alpha + rve.getEyeHeight();
- double interpZ = rve.lastTickPosZ + (rve.posZ - rve.lastTickPosZ) * (double)alpha;
+ double interpX = rve.lastTickPosX + (rve.posX - rve.lastTickPosX) * alpha;
+ double interpY = rve.lastTickPosY + (rve.posY - rve.lastTickPosY) * alpha + rve.getEyeHeight();
+ double interpZ = rve.lastTickPosZ + (rve.posZ - rve.lastTickPosZ) * alpha;
glUniform3f(u_playerPos, (float)interpX - originX, (float)interpY - originY, (float)interpZ - originZ);