aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormakamys <makamys@outlook.com>2021-05-09 06:12:07 +0200
committermakamys <makamys@outlook.com>2021-05-09 06:12:07 +0200
commit8d0e7250bc8b6613a6131b56e1097086669cb26b (patch)
tree7d6a92a05e6a02715e991dd9c695a99253981aab /src
parentd13ce46adf63aea6f8d675c85818549eec3b7c90 (diff)
downloadNeodymium-8d0e7250bc8b6613a6131b56e1097086669cb26b.tar.gz
Neodymium-8d0e7250bc8b6613a6131b56e1097086669cb26b.tar.bz2
Neodymium-8d0e7250bc8b6613a6131b56e1097086669cb26b.zip
Use correct player pos for camera
Diffstat (limited to 'src')
-rw-r--r--src/main/java/makamys/lodmod/mixin/MixinEntityRenderer.java2
-rw-r--r--src/main/java/makamys/lodmod/renderer/LODRenderer.java13
2 files changed, 10 insertions, 5 deletions
diff --git a/src/main/java/makamys/lodmod/mixin/MixinEntityRenderer.java b/src/main/java/makamys/lodmod/mixin/MixinEntityRenderer.java
index dcfcbac..12f1eea 100644
--- a/src/main/java/makamys/lodmod/mixin/MixinEntityRenderer.java
+++ b/src/main/java/makamys/lodmod/mixin/MixinEntityRenderer.java
@@ -32,7 +32,7 @@ abstract class MixinEntityRenderer {
private void afterSortAndRender(float alpha, long something, CallbackInfo ci) {
if(LODMod.isActive()) {
Minecraft.getMinecraft().entityRenderer.enableLightmap((double)alpha);
- LODMod.renderer.beforeRenderTerrain();
+ LODMod.renderer.beforeRenderTerrain(alpha);
Minecraft.getMinecraft().entityRenderer.disableLightmap((double)alpha);
}
}
diff --git a/src/main/java/makamys/lodmod/renderer/LODRenderer.java b/src/main/java/makamys/lodmod/renderer/LODRenderer.java
index dd41fdd..ca95be4 100644
--- a/src/main/java/makamys/lodmod/renderer/LODRenderer.java
+++ b/src/main/java/makamys/lodmod/renderer/LODRenderer.java
@@ -86,7 +86,7 @@ public class LODRenderer {
hasInited = init();
}
- public void beforeRenderTerrain() {
+ public void beforeRenderTerrain(float alpha) {
if(hasInited) {
mainLoop();
handleKeyboard();
@@ -99,7 +99,7 @@ public class LODRenderer {
if(renderLOD) {
sort();
initIndexBuffers();
- render();
+ render(alpha);
}
}
}
@@ -242,7 +242,7 @@ public class LODRenderer {
glBindVertexArray(0);
}
- private void render() {
+ private void render(float alpha) {
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glDisable(GL11.GL_TEXTURE_2D);
@@ -301,7 +301,12 @@ public class LODRenderer {
float originY = 0;
float originZ = 0;
- glUniform3f(u_playerPos, (float)EntityFX.interpPosX - originX, (float)EntityFX.interpPosY - originY, (float)EntityFX.interpPosZ - originZ);
+ 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;
+
+ glUniform3f(u_playerPos, (float)interpX - originX, (float)interpY - originY, (float)interpZ - originZ);
glUniform1i(u_light, 1);
}