aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authormakamys <makamys@outlook.com>2022-08-14 05:35:32 +0200
committermakamys <makamys@outlook.com>2022-08-14 05:37:12 +0200
commitaea8d637ea3e14255fdd011ef1ae38b4b7066b9e (patch)
treeb28f587ba92bc3744c73329e85e5882153bdb314 /src/main/java
parent2151f5c267a18b59bd51d9a07bab06978a9200c7 (diff)
downloadNeodymium-aea8d637ea3e14255fdd011ef1ae38b4b7066b9e.tar.gz
Neodymium-aea8d637ea3e14255fdd011ef1ae38b4b7066b9e.tar.bz2
Neodymium-aea8d637ea3e14255fdd011ef1ae38b4b7066b9e.zip
Disable vanilla chunk mesh construction
Improves chunk update performance
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/makamys/neodymium/config/Config.java2
-rw-r--r--src/main/java/makamys/neodymium/mixin/MixinTessellator.java14
2 files changed, 15 insertions, 1 deletions
diff --git a/src/main/java/makamys/neodymium/config/Config.java b/src/main/java/makamys/neodymium/config/Config.java
index 5b110fd..a8ea60e 100644
--- a/src/main/java/makamys/neodymium/config/Config.java
+++ b/src/main/java/makamys/neodymium/config/Config.java
@@ -80,6 +80,8 @@ public class Config {
public static boolean showDebugInfo;
@ConfigBoolean(cat="debug", def=false)
public static boolean wireframe;
+ @ConfigBoolean(cat="debug", def=false, com="Enable building of vanilla chunk meshes. Makes it possible to switch to the vanilla renderer on the fly, at the cost of reducing chunk update performance.")
+ public static boolean enableVanillaChunkMeshes;
private static Configuration config;
private static File configFile = new File(Launch.minecraftHome, "config/" + MODID + ".cfg");
diff --git a/src/main/java/makamys/neodymium/mixin/MixinTessellator.java b/src/main/java/makamys/neodymium/mixin/MixinTessellator.java
index 15f71da..cdd4ffe 100644
--- a/src/main/java/makamys/neodymium/mixin/MixinTessellator.java
+++ b/src/main/java/makamys/neodymium/mixin/MixinTessellator.java
@@ -1,10 +1,12 @@
package makamys.neodymium.mixin;
import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+import makamys.neodymium.config.Config;
import makamys.neodymium.ducks.ITessellator;
import makamys.neodymium.renderer.ChunkMesh;
import net.minecraft.client.renderer.Tessellator;
@@ -14,10 +16,20 @@ abstract class MixinTessellator implements ITessellator {
private boolean nd$captureMeshes;
- @Inject(method = "draw", at = @At(value = "HEAD"))
+ @Shadow protected abstract void reset();
+
+ @Shadow private boolean isDrawing;
+
+ @Inject(method = "draw", at = @At(value = "HEAD"), cancellable = true)
private void preDraw(CallbackInfoReturnable<Integer> cir) {
if(nd$captureMeshes) {
ChunkMesh.preTessellatorDraw((Tessellator)(Object)this);
+
+ if(Config.enabled && !Config.enableVanillaChunkMeshes) {
+ isDrawing = false;
+ reset();
+ cir.setReturnValue(0);
+ }
}
}