aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/makamys/neodymium/mixin
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/makamys/neodymium/mixin
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/makamys/neodymium/mixin')
-rw-r--r--src/main/java/makamys/neodymium/mixin/MixinTessellator.java14
1 files changed, 13 insertions, 1 deletions
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);
+ }
}
}