mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 12:37:59 +01:00
Fix #120 (concurrent modification exception when computing villager textures)
This commit is contained in:
parent
ee8e970cee
commit
c3ddc01422
1 changed files with 9 additions and 8 deletions
|
@ -74,16 +74,17 @@ class VillagerProfessionTextureCache<T extends LivingEntity & VillagerDataContai
|
|||
// through all the lambda generations if we can avoid it.
|
||||
}
|
||||
|
||||
return cache.computeIfAbsent(key, k -> {
|
||||
return verifyTexture(formatter.supplyTexture(k)).orElseGet(() -> {
|
||||
if (type == VillagerType.PLAINS) {
|
||||
// if texture loading fails, use the fallback.
|
||||
return fallback;
|
||||
}
|
||||
Identifier result = verifyTexture(formatter.supplyTexture(key)).orElseGet(() -> {
|
||||
if (type == VillagerType.PLAINS) {
|
||||
// if texture loading fails, use the fallback.
|
||||
return fallback;
|
||||
}
|
||||
|
||||
return getTexture(VillagerType.PLAINS, profession);
|
||||
});
|
||||
return getTexture(VillagerType.PLAINS, profession);
|
||||
});
|
||||
|
||||
cache.put(key, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
protected Optional<Identifier> verifyTexture(Identifier texture) {
|
||||
|
|
Loading…
Reference in a new issue