Maybe fixed colormatic's mod compat?

This commit is contained in:
TomTheFurry
2022-04-02 13:49:28 +08:00
parent 150ba98a4e
commit 15e5a04ffd
2 changed files with 9 additions and 1 deletions
@@ -49,7 +49,11 @@ public class TintGetterOverrideFast implements BlockAndTintGetter {
@Override
public int getBlockTint(BlockPos blockPos, ColorResolver colorResolver) {
Biome b = _getBiome(blockPos);
return tintCaches.get(colorResolver).computeIfAbsent(b, (key) -> colorResolver.getColor(b, blockPos.getX(), blockPos.getZ()));
ConcurrentHashMap<Biome, Integer> concurrentHashMap = this.tintCaches.get(colorResolver);
if (concurrentHashMap == null) { // This is a compat fix for Colormatic's mixin
this.tintCaches.put(colorResolver, concurrentHashMap = new ConcurrentHashMap<>());
}
return concurrentHashMap.computeIfAbsent(b, (key) -> colorResolver.getColor(b, blockPos.getX(), blockPos.getZ()));
}
@Override
@@ -72,6 +72,10 @@ public class TintGetterOverrideSmooth implements BlockAndTintGetter {
@Override
public int getBlockTint(BlockPos blockPos, ColorResolver colorResolver) {
BlockTintCache blockTintCache = this.tintCaches.get(colorResolver);
if (blockTintCache == null) { // This is a compat fix for Colormatic's mixin
this.tintCaches.put(colorResolver,
blockTintCache = new BlockTintCache((pos) -> calculateBlockTint(pos, colorResolver)));
}
return blockTintCache.getColor(blockPos);
}