diff options
author | makamys <makamys@outlook.com> | 2022-06-25 07:11:18 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2022-06-25 07:31:45 +0200 |
commit | 1e100f6142424e1f96c4a4d00d58b44f8c95d047 (patch) | |
tree | 976283652845075c21330bb18addf8310b5c395d /src/main/java/makamys | |
parent | d917562e71c30a933afd9bfd562ce5394e40cbaf (diff) | |
download | Neodymium-1e100f6142424e1f96c4a4d00d58b44f8c95d047.tar.gz Neodymium-1e100f6142424e1f96c4a4d00d58b44f8c95d047.tar.bz2 Neodymium-1e100f6142424e1f96c4a4d00d58b44f8c95d047.zip |
Add debug keybind to speed up renderer update rate
Diffstat (limited to 'src/main/java/makamys')
-rw-r--r-- | src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java | 16 | ||||
-rw-r--r-- | src/main/java/makamys/neodymium/renderer/NeoRenderer.java | 13 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java b/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java index d38f491..f4d01ac 100644 --- a/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java +++ b/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java @@ -2,6 +2,7 @@ package makamys.neodymium.mixin; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; @@ -11,6 +12,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import makamys.neodymium.Neodymium; import net.minecraft.client.renderer.RenderGlobal; import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.entity.EntityLivingBase; /** Blocks vanilla chunk rendering while NeoRenderer is active. */ @Mixin(RenderGlobal.class) @@ -19,6 +21,9 @@ abstract class MixinRenderGlobal { @Shadow private WorldRenderer[] sortedWorldRenderers; + @Unique + private boolean isInsideUpdateRenderers; + @Redirect(method = "renderSortedRenderers", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderGlobal;renderAllRenderLists(ID)V")) private void redirectRenderAllRenderLists(RenderGlobal thiz, int p1, double p2) { if(Neodymium.shouldRenderVanillaWorld()) { @@ -40,4 +45,15 @@ abstract class MixinRenderGlobal { Neodymium.renderer = null; } } + + @Inject(method = "updateRenderers", at = @At(value = "RETURN")) + public void postUpdateRenderers(EntityLivingBase entity, boolean flag, CallbackInfoReturnable<Boolean> cir) { + if(Neodymium.isActive() && !isInsideUpdateRenderers) { + isInsideUpdateRenderers = true; + for(int i = 0; i < Neodymium.renderer.rendererSpeedup; i++) { + ((RenderGlobal)(Object)this).updateRenderers(entity, flag); + } + isInsideUpdateRenderers = false; + } + } } diff --git a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java index 7a74141..03c7911 100644 --- a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java +++ b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java @@ -49,6 +49,7 @@ public class NeoRenderer { public boolean hasInited = false; public boolean destroyPending; public boolean reloadPending; + public int rendererSpeedup; private static boolean[] wasDown = new boolean[256]; @@ -216,6 +217,13 @@ public class NeoRenderer { if(Keyboard.isKeyDown(Keyboard.KEY_LEFT) && !wasDown[Keyboard.KEY_LEFT]) { reloadPending = true; } + if(Keyboard.isKeyDown(Keyboard.KEY_RIGHT) && !wasDown[Keyboard.KEY_RIGHT]) { + if(rendererSpeedup == 0) { + rendererSpeedup = 300; + } else { + rendererSpeedup = 0; + } + } } for(int i = 0; i < 256; i++) { wasDown[i] = Keyboard.isKeyDown(i); @@ -558,6 +566,11 @@ public class NeoRenderer { "Meshes: " + ChunkMesh.instances + " (" + ChunkMesh.usedRAM / 1024 / 1024 + "MB)", "Rendered: " + renderedMeshes + " (" + renderedQuads / 1000 + "KQ)" )); + if(rendererSpeedup > 0) { + text.addAll(Arrays.asList( + "(!) Renderer speedup active" + )); + } return text; } |