Fix concurrent modify exception.

This commit is contained in:
Eoghanmc22 2020-08-13 18:50:57 -04:00
parent cc01a48cf1
commit d12618af0f
2 changed files with 10 additions and 4 deletions

View File

@ -109,9 +109,7 @@ public class PerGroupChunkProvider extends ThreadProvider {
ArrayList<Future<?>> futures = new ArrayList<>();
instanceInstanceMap.entrySet().forEach(entry -> {
final Instance instance = entry.getKey();
final Map<LongSet, Instance> instanceMap = entry.getValue();
instanceInstanceMap.forEach((instance, instanceMap) -> {
// True if the instance ended its tick call
AtomicBoolean instanceUpdated = new AtomicBoolean(false);
@ -157,7 +155,7 @@ public class PerGroupChunkProvider extends ThreadProvider {
}
private Map<LongSet, Instance> getInstanceMap(Instance instance) {
return instanceInstanceMap.computeIfAbsent(instance, inst -> new HashMap<>());
return instanceInstanceMap.computeIfAbsent(instance, inst -> new ConcurrentHashMap<>());
}
}

View File

@ -70,4 +70,12 @@ public final class MathUtils {
public static float setBetween(float number, float min, float max) {
return number > max ? max : number < min ? min : number;
}
public static int clamp(int value, int min, int max) {
if (value < min) {
return min;
} else {
return Math.min(value, max);
}
}
}