mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-29 15: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,8 +74,7 @@ class VillagerProfessionTextureCache<T extends LivingEntity & VillagerDataContai
|
||||||
// through all the lambda generations if we can avoid it.
|
// through all the lambda generations if we can avoid it.
|
||||||
}
|
}
|
||||||
|
|
||||||
return cache.computeIfAbsent(key, k -> {
|
Identifier result = verifyTexture(formatter.supplyTexture(key)).orElseGet(() -> {
|
||||||
return verifyTexture(formatter.supplyTexture(k)).orElseGet(() -> {
|
|
||||||
if (type == VillagerType.PLAINS) {
|
if (type == VillagerType.PLAINS) {
|
||||||
// if texture loading fails, use the fallback.
|
// if texture loading fails, use the fallback.
|
||||||
return fallback;
|
return fallback;
|
||||||
|
@ -83,7 +82,9 @@ class VillagerProfessionTextureCache<T extends LivingEntity & VillagerDataContai
|
||||||
|
|
||||||
return getTexture(VillagerType.PLAINS, profession);
|
return getTexture(VillagerType.PLAINS, profession);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
cache.put(key, result);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Optional<Identifier> verifyTexture(Identifier texture) {
|
protected Optional<Identifier> verifyTexture(Identifier texture) {
|
||||||
|
|
Loading…
Reference in a new issue