prevent concurrency issues when updating Bolts during render (probable performance impact)
@@ -39,6 +39,7 @@ public class BoltRenderer {
if (refresh) {
refreshTimestamp = timestamp;
}
+ synchronized (boltOwners) {
for (Iterator<Map.Entry<Object, BoltOwnerData>> iter = boltOwners.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry<Object, BoltOwnerData> entry = iter.next();
BoltOwnerData data = entry.getValue();
@@ -56,11 +57,13 @@ public class BoltRenderer {
}
}
}
+ }
public void update(Object owner, BoltEffect newBoltData, float partialTicks) {
if (minecraft.world == null) {
return;
}
+ synchronized (boltOwners) {
BoltOwnerData data = boltOwners.computeIfAbsent(owner, o -> new BoltOwnerData());
data.lastBolt = newBoltData;
Timestamp timestamp = new Timestamp(minecraft.world.getGameTime(), partialTicks);
@@ -69,6 +72,7 @@ public class BoltRenderer {
}
data.lastUpdateTimestamp = timestamp;
}
+ }
public class BoltOwnerData {
