Fix #120 (concurrent modification exception when computing villager textures)

This commit is contained in:
Sollace 2019-07-10 15:44:28 +02:00
parent ee8e970cee
commit c3ddc01422

View file

@ -74,16 +74,17 @@ 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; }
}
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) {