diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/animation/MixinChunkCache.java b/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/animation/MixinChunkCache.java index e8a7f2dee..9045df3a7 100644 --- a/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/animation/MixinChunkCache.java +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/animation/MixinChunkCache.java @@ -18,4 +18,9 @@ public class MixinChunkCache implements ITexturesCache { public HashSet getRenderedTextures() { return renderedIcons; } + + @Override + public void enableTextureTracking() { + + } } diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/animation/MixinRenderBlocks.java b/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/animation/MixinRenderBlocks.java index 416d50e55..1723e7b11 100644 --- a/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/animation/MixinRenderBlocks.java +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/animation/MixinRenderBlocks.java @@ -2,7 +2,7 @@ import com.gtnewhorizons.angelica.mixins.interfaces.ITexturesCache; import com.gtnewhorizons.angelica.utils.AnimationsRenderUtils; -import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; +import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; import net.minecraft.block.Block; import net.minecraft.block.BlockFire; import net.minecraft.client.renderer.RenderBlocks; @@ -27,7 +27,8 @@ public class MixinRenderBlocks implements ITexturesCache { @Shadow public IIcon overrideBlockTexture; - private Set renderedSprites = new ObjectOpenHashSet<>(); + private Set renderedSprites = new ReferenceOpenHashSet<>(); + private boolean enableSpriteTracking; /** * @author laetansky Here where things get very tricky. We can't just mark blocks textures for update because this @@ -46,14 +47,17 @@ public class MixinRenderBlocks implements ITexturesCache { AnimationsRenderUtils.markBlockTextureForUpdate(icon, blockAccess); - this.renderedSprites.add(icon); + if(this.enableSpriteTracking) + this.renderedSprites.add(icon); } @Inject(method = "renderBlockFire", at = @At("HEAD")) public void angelica$markFireBlockAnimationForUpdate(BlockFire instance, int x, int y, int z, CallbackInfoReturnable cir) { - this.renderedSprites.add(instance.getFireIcon(0)); - this.renderedSprites.add(instance.getFireIcon(1)); + if(this.enableSpriteTracking) { + this.renderedSprites.add(instance.getFireIcon(0)); + this.renderedSprites.add(instance.getFireIcon(1)); + } AnimationsRenderUtils.markBlockTextureForUpdate(instance.getFireIcon(0), blockAccess); AnimationsRenderUtils.markBlockTextureForUpdate(instance.getFireIcon(1), blockAccess); } @@ -62,7 +66,8 @@ public class MixinRenderBlocks implements ITexturesCache { public IIcon angelica$markFluidAnimationForUpdate(IIcon icon) { AnimationsRenderUtils.markBlockTextureForUpdate(icon, blockAccess); - this.renderedSprites.add(icon); + if(this.enableSpriteTracking) + this.renderedSprites.add(icon); return icon; } @@ -72,11 +77,17 @@ public class MixinRenderBlocks implements ITexturesCache { CallbackInfo ci) { AnimationsRenderUtils.markBlockTextureForUpdate(icon, blockAccess); - this.renderedSprites.add(icon); + if(this.enableSpriteTracking) + this.renderedSprites.add(icon); } @Override public Set getRenderedTextures() { return renderedSprites; } + + @Override + public void enableTextureTracking() { + enableSpriteTracking = true; + } } diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/animation/MixinWorldRenderer.java b/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/animation/MixinWorldRenderer.java index 4eb9c0429..e5fe613a4 100644 --- a/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/animation/MixinWorldRenderer.java +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/animation/MixinWorldRenderer.java @@ -26,6 +26,7 @@ public class MixinWorldRenderer implements ITexturesCache { @ModifyArg(method = "updateRenderer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderBlocks;(Lnet/minecraft/world/IBlockAccess;)V")) private IBlockAccess angelica$onUpdateRenderer(IBlockAccess chunkCache) { + ((ITexturesCache) chunkCache).enableTextureTracking(); renderedIcons = ((ITexturesCache) chunkCache).getRenderedTextures(); return chunkCache; } @@ -43,4 +44,9 @@ public class MixinWorldRenderer implements ITexturesCache { public Set getRenderedTextures() { return renderedIcons; } + + @Override + public void enableTextureTracking() { + + } } diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/interfaces/ITexturesCache.java b/src/main/java/com/gtnewhorizons/angelica/mixins/interfaces/ITexturesCache.java index 0cbfe99fd..789d598a1 100644 --- a/src/main/java/com/gtnewhorizons/angelica/mixins/interfaces/ITexturesCache.java +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/interfaces/ITexturesCache.java @@ -7,4 +7,5 @@ public interface ITexturesCache { Set getRenderedTextures(); + void enableTextureTracking(); } diff --git a/src/main/java/me/jellysquid/mods/sodium/client/render/chunk/tasks/ChunkRenderRebuildTask.java b/src/main/java/me/jellysquid/mods/sodium/client/render/chunk/tasks/ChunkRenderRebuildTask.java index a2538a746..ac012de78 100644 --- a/src/main/java/me/jellysquid/mods/sodium/client/render/chunk/tasks/ChunkRenderRebuildTask.java +++ b/src/main/java/me/jellysquid/mods/sodium/client/render/chunk/tasks/ChunkRenderRebuildTask.java @@ -116,6 +116,7 @@ public ChunkBuildResult performBuild(ChunkRenderCacheLocal cache, ChunkBuildB final WorldSlice slice = cache.getWorldSlice(); final RenderBlocks renderBlocks = new RenderBlocks(slice); + if(renderBlocks instanceof ITexturesCache) ((ITexturesCache)renderBlocks).enableTextureTracking(); final int baseX = this.render.getOriginX(); final int baseY = this.render.getOriginY(); @@ -246,6 +247,7 @@ private void performMainBuild(ChunkRenderCacheLocal cache, ChunkBuildBuffers buf final int baseZ = this.render.getOriginZ(); final BlockPosImpl renderOffset = this.offset; final RenderBlocks rb = new RenderBlocks(slice.getWorld()); + if(rb instanceof ITexturesCache) ((ITexturesCache)rb).enableTextureTracking(); while(!mainThreadBlocks.isEmpty()) { final long longPos = mainThreadBlocks.dequeueLong(); if (cancellationSource.isCancelled()) {