mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-14 01:14:08 +00:00
fix world client leaks in bop fog handlers (#2056)
This commit is contained in:
1 parent
269b7245d3
commit
a66db1517a
4 files changed
+16
-3
No files matched your search
@@ -17,6 +17,10 @@ public final class BopFogColorSource implements BopFogBlend.ColorSource {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void freeWorld() {
|
||||
this.world = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fogColour(int x, int y, int z) {
|
||||
final BiomeGenBase biome = FogBiomeCache.get(world, x, z);
|
||||
|
||||
@@ -9,7 +9,7 @@ public final class FogBiomeCache {
|
||||
private static final int MAX_ENTRIES = 16384;
|
||||
|
||||
private static final Long2ObjectOpenHashMap<BiomeGenBase> CACHE = new Long2ObjectOpenHashMap<>();
|
||||
private static World lastWorld;
|
||||
private static World cachedWorld;
|
||||
private static int generation;
|
||||
|
||||
private FogBiomeCache() {}
|
||||
@@ -18,10 +18,14 @@ public final class FogBiomeCache {
|
||||
return generation;
|
||||
}
|
||||
|
||||
public static void invalidate() {
|
||||
cachedWorld = null;
|
||||
}
|
||||
|
||||
public static BiomeGenBase get(World world, int x, int z) {
|
||||
if (world != lastWorld) {
|
||||
if (world != cachedWorld) {
|
||||
CACHE.clear();
|
||||
lastWorld = world;
|
||||
cachedWorld = world;
|
||||
generation++;
|
||||
}
|
||||
final long key = ((long) x << 32) | (z & 0xFFFFFFFFL);
|
||||
|
||||
+4
@@ -6,6 +6,8 @@ import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.bop.BopFogBlend;
|
||||
import com.gtnewhorizons.angelica.compat.bop.FogBiomeCache;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
@@ -166,6 +168,8 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
|
||||
TesrBatchRenderer.INSTANCE.clearRetained();
|
||||
ModelPartBatcher.INSTANCE.clear();
|
||||
GpuCulling.onWorldUnload();
|
||||
BopFogBlend.invalidate();
|
||||
FogBiomeCache.invalidate();
|
||||
super.unloadWorld();
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -52,6 +52,7 @@ public class MixinFogHandlerBiomeCache {
|
||||
final float[] sums = angelica$sums;
|
||||
BopFogBlend.accumulate(world, FogBiomeCache.generation(), BopFogColorSource.INSTANCE.forWorld(world),
|
||||
playerEntity.posX, playerEntity.posZ, playerX, playerY, playerZ, distance, sums);
|
||||
BopFogColorSource.INSTANCE.freeWorld();
|
||||
|
||||
float rBiomeFog = sums[0];
|
||||
float gBiomeFog = sums[1];
|
||||
|
||||
Reference in new issue
Block a user