aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/makamys/neodymium/mixin
diff options
context:
space:
mode:
authormakamys <makamys@outlook.com>2022-06-30 08:44:54 +0200
committermakamys <makamys@outlook.com>2022-06-30 08:52:58 +0200
commit362a3b7d50557a4b86d70b398d37a9c438ffa262 (patch)
treef973ec7c27d9adf31d19f49ed5055626568e4f15 /src/main/java/makamys/neodymium/mixin
parent359c4b702d4327d92704201fc2977dbf9d179dd7 (diff)
downloadNeodymium-362a3b7d50557a4b86d70b398d37a9c438ffa262.tar.gz
Neodymium-362a3b7d50557a4b86d70b398d37a9c438ffa262.tar.bz2
Neodymium-362a3b7d50557a4b86d70b398d37a9c438ffa262.zip
Update meshes on `updateRenderersSort`, too
Fixes incorrect water rendering
Diffstat (limited to 'src/main/java/makamys/neodymium/mixin')
-rw-r--r--src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java29
1 files changed, 12 insertions, 17 deletions
diff --git a/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java b/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java
index a45257f..ad7b3d2 100644
--- a/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java
+++ b/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java
@@ -1,6 +1,6 @@
package makamys.neodymium.mixin;
-import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.spongepowered.asm.mixin.Mixin;
@@ -9,6 +9,8 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+import com.google.common.collect.Lists;
+
import makamys.neodymium.Neodymium;
import makamys.neodymium.ducks.IWorldRenderer;
import makamys.neodymium.renderer.ChunkMesh;
@@ -30,46 +32,39 @@ abstract class MixinWorldRenderer implements IWorldRenderer {
public boolean needsUpdate;
boolean savedDrawnStatus;
- private boolean insideUpdateRenderer;
public List<ChunkMesh> chunkMeshes;
- @Inject(method = "updateRenderer", at = @At(value = "HEAD"))
+ @Inject(method = {"updateRenderer", "updateRendererSort"}, at = @At(value = "HEAD"))
private void preUpdateRenderer(CallbackInfo ci) {
saveDrawnStatus();
- insideUpdateRenderer = true;
if(Neodymium.isActive()) {
- if(needsUpdate) {
- if(chunkMeshes != null) {
- chunkMeshes.clear();
- } else {
- chunkMeshes = new ArrayList<>();
- }
+ if(chunkMeshes != null) {
+ Collections.fill(chunkMeshes, null);
} else {
- chunkMeshes = null;
+ chunkMeshes = Lists.newArrayList(null, null);
}
}
}
- @Inject(method = "updateRenderer", at = @At(value = "RETURN"))
+ @Inject(method = {"updateRenderer", "updateRendererSort"}, at = @At(value = "RETURN"))
private void postUpdateRenderer(CallbackInfo ci) {
notifyIfDrawnStatusChanged();
- insideUpdateRenderer = false;
if(Neodymium.isActive()) {
if(chunkMeshes != null) {
Neodymium.renderer.onWorldRendererPost(WorldRenderer.class.cast(this));
- chunkMeshes.clear();
+ Collections.fill(chunkMeshes, null);
}
}
}
- @Inject(method = "postRenderBlocks", at = @At(value = "HEAD"))
+ @Inject(method = "postRenderBlocks", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/Tessellator;draw()I"))
private void prePostRenderBlocks(int pass, EntityLivingBase entity, CallbackInfo ci) {
- if(insideUpdateRenderer && Neodymium.isActive()) {
+ if(Neodymium.isActive()) {
if(chunkMeshes != null) {
- chunkMeshes.add(ChunkMesh.fromTessellator(pass, WorldRenderer.class.cast(this), Tessellator.instance));
+ chunkMeshes.set(pass, ChunkMesh.fromTessellator(pass, WorldRenderer.class.cast(this), Tessellator.instance));
}
}
}