From 9526753a17fda35479db6c16d5e6db93b11abcc3 Mon Sep 17 00:00:00 2001 From: MCRcortex <18544518+MCRcortex@users.noreply.github.com> Date: Fri, 2 Aug 2024 04:01:18 +1000 Subject: [PATCH] Fix for #2586 (#2619) Co-authored-by: mcrcortex <{ID}+{username}@users.noreply.github.com> --- .../sodium/mixin/core/world/map/ClientLevelMixin.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/world/map/ClientLevelMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/world/map/ClientLevelMixin.java index fef3b18b23..682821b1f4 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/world/map/ClientLevelMixin.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/world/map/ClientLevelMixin.java @@ -1,10 +1,15 @@ package net.caffeinemc.mods.sodium.mixin.core.world.map; +import net.caffeinemc.mods.sodium.client.render.chunk.map.ChunkStatus; import net.caffeinemc.mods.sodium.client.render.chunk.map.ChunkTracker; import net.caffeinemc.mods.sodium.client.render.chunk.map.ChunkTrackerHolder; import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.level.chunk.LevelChunk; import org.spongepowered.asm.mixin.Mixin; 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.callback.CallbackInfo; import java.util.Objects; @@ -18,4 +23,10 @@ public class ClientLevelMixin implements ChunkTrackerHolder { public ChunkTracker sodium$getTracker() { return Objects.requireNonNull(this.chunkTracker); } + + @Inject(method = "unload", at = @At("HEAD")) + private void sodium$trackChunkUnload(LevelChunk levelChunk, CallbackInfo ci) { + var pos = levelChunk.getPos(); + this.chunkTracker.onChunkStatusRemoved(pos.x, pos.z, ChunkStatus.FLAG_ALL); + } }