aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/makamys/lodmod/ducks/IWorldRenderer.java1
-rw-r--r--src/main/java/makamys/lodmod/mixin/MixinWorldRenderer.java35
-rw-r--r--src/main/java/makamys/lodmod/renderer/LODRenderer.java6
3 files changed, 28 insertions, 14 deletions
diff --git a/src/main/java/makamys/lodmod/ducks/IWorldRenderer.java b/src/main/java/makamys/lodmod/ducks/IWorldRenderer.java
index 56cfb7b..83857d6 100644
--- a/src/main/java/makamys/lodmod/ducks/IWorldRenderer.java
+++ b/src/main/java/makamys/lodmod/ducks/IWorldRenderer.java
@@ -9,5 +9,4 @@ import net.minecraft.client.renderer.WorldRenderer;
public interface IWorldRenderer {
public List<ChunkMesh> getChunkMeshes();
- public void myTick();
}
diff --git a/src/main/java/makamys/lodmod/mixin/MixinWorldRenderer.java b/src/main/java/makamys/lodmod/mixin/MixinWorldRenderer.java
index eba0a5e..7caecb1 100644
--- a/src/main/java/makamys/lodmod/mixin/MixinWorldRenderer.java
+++ b/src/main/java/makamys/lodmod/mixin/MixinWorldRenderer.java
@@ -45,11 +45,11 @@ abstract class MixinWorldRenderer implements IWorldRenderer {
@Shadow
private int glRenderList;
- boolean lastDrawn;
-
@Shadow
public boolean needsUpdate;
+ boolean savedDrawnStatus;
+
public List<ChunkMesh> chunkMeshes;
@Redirect(method = "setPosition", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/RenderItem;renderAABB(Lnet/minecraft/util/AxisAlignedBB;)V"))
@@ -70,6 +70,8 @@ abstract class MixinWorldRenderer implements IWorldRenderer {
@Inject(method = "updateRenderer", at = @At(value = "HEAD"))
private void preUpdateRenderer(CallbackInfo ci) {
+ saveDrawnStatus();
+
if(LODMod.isActive()) {
if(needsUpdate) {
if(chunkMeshes != null) {
@@ -83,8 +85,10 @@ abstract class MixinWorldRenderer implements IWorldRenderer {
}
}
- @Inject(method = "updateRenderer", at = @At(value = "TAIL"))
+ @Inject(method = "updateRenderer", at = @At(value = "RETURN"))
private void postUpdateRenderer(CallbackInfo ci) {
+ notifyIfDrawnStatusChanged();
+
if(LODMod.isActive()) {
if(chunkMeshes != null) {
LODMod.renderer.onWorldRendererPost(WorldRenderer.class.cast(this));
@@ -150,11 +154,28 @@ abstract class MixinWorldRenderer implements IWorldRenderer {
return chunkMeshes;
}
- public void myTick() {
- boolean drawn = isInFrustum && (!skipRenderPass[0] || !skipRenderPass[1]);
- if(drawn != lastDrawn) {
+ @Inject(method = "updateInFrustum", at = @At(value = "HEAD"))
+ private void preUpdateInFrustum(CallbackInfo ci) {
+ saveDrawnStatus();
+ }
+
+ @Inject(method = "updateInFrustum", at = @At(value = "RETURN"))
+ private void postUpdateInFrustum(CallbackInfo ci) {
+ notifyIfDrawnStatusChanged();
+ }
+
+ private void saveDrawnStatus() {
+ savedDrawnStatus = isDrawn();
+ }
+
+ private void notifyIfDrawnStatusChanged() {
+ boolean drawn = isDrawn();
+ if(LODMod.isActive() && drawn != savedDrawnStatus) {
LODMod.renderer.onWorldRendererChanged(WorldRenderer.class.cast(this), drawn);
}
- lastDrawn = drawn;
+ }
+
+ private boolean isDrawn() {
+ return isInFrustum && (!skipRenderPass[0] || !skipRenderPass[1]);
}
}
diff --git a/src/main/java/makamys/lodmod/renderer/LODRenderer.java b/src/main/java/makamys/lodmod/renderer/LODRenderer.java
index 942acdb..d13f4e4 100644
--- a/src/main/java/makamys/lodmod/renderer/LODRenderer.java
+++ b/src/main/java/makamys/lodmod/renderer/LODRenderer.java
@@ -115,12 +115,6 @@ public class LODRenderer {
Minecraft.getMinecraft().entityRenderer.enableLightmap((double)alpha);
if(hasInited) {
- for(WorldRenderer wr : sortedWorldRenderers) {
- if(wr != null) {
- ((IWorldRenderer)wr).myTick();
- }
- }
-
mainLoop();
if(LODMod.debugEnabled) {
handleKeyboard();