diff --git a/resources/patches.xml b/resources/patches.xml
index b7148e75..97203a56 100644
--- a/resources/patches.xml
+++ b/resources/patches.xml
@@ -108,6 +108,7 @@
+
spawnEntityInWorld
forceChunk,unforceChunk
diff --git a/src/common/nallar/patched/world/PatchWorld.java b/src/common/nallar/patched/world/PatchWorld.java
index a2117f6a..f92c66f4 100644
--- a/src/common/nallar/patched/world/PatchWorld.java
+++ b/src/common/nallar/patched/world/PatchWorld.java
@@ -705,30 +705,32 @@ public void updateEntities() {
final Profiler theProfiler = this.theProfiler;
theProfiler.startSection("updateEntities");
int var1;
- Entity var2;
+ Entity weatherEffect;
CrashReport var4;
CrashReportCategory var5;
theProfiler.startSection("global");
- final List weatherEffects = this.weatherEffects;
- for (var1 = 0; var1 < weatherEffects.size(); ++var1) {
- var2 = (Entity) weatherEffects.get(var1);
-
- try {
- ++var2.ticksExisted;
- var2.onUpdate();
- } catch (Throwable var6) {
- var4 = CrashReport.makeCrashReport(var6, "Ticking entity");
- var5 = var4.makeCategory("Entity being ticked");
- if (var2 != null) {
- var2.func_85029_a(var5);
+ final List weatherEffects = this.weatherEffects;
+ synchronized (weatherEffects) {
+ Iterator iterator = weatherEffects.iterator();
+ while (iterator.hasNext()) {
+ weatherEffect = iterator.next();
+
+ if (weatherEffect == null) {
+ iterator.remove();
+ continue;
}
- throw new ReportedException(var4);
- }
+ try {
+ ++weatherEffect.ticksExisted;
+ weatherEffect.onUpdate();
+ } catch (Throwable t) {
+ Log.severe("Failed to tick weather " + Log.toString(weatherEffect), t);
+ }
- if (var2 == null || var2.isDead) {
- weatherEffects.remove(var1--);
+ if (weatherEffect.isDead) {
+ iterator.remove();
+ }
}
}
@@ -759,26 +761,26 @@ public void updateEntities() {
unloadedEntitySet.clear();
theProfiler.endStartSection("entities");
for (var1 = 0; var1 < loadedEntityList.size(); ++var1) {
- var2 = (Entity) loadedEntityList.get(var1);
+ weatherEffect = (Entity) loadedEntityList.get(var1);
- if (var2.ridingEntity != null) {
- if (!var2.ridingEntity.isDead && var2.ridingEntity.riddenByEntity == var2) {
+ if (weatherEffect.ridingEntity != null) {
+ if (!weatherEffect.ridingEntity.isDead && weatherEffect.ridingEntity.riddenByEntity == weatherEffect) {
continue;
}
- var2.ridingEntity.riddenByEntity = null;
- var2.ridingEntity = null;
+ weatherEffect.ridingEntity.riddenByEntity = null;
+ weatherEffect.ridingEntity = null;
}
theProfiler.startSection("tick");
- if (!var2.isDead) {
+ if (!weatherEffect.isDead) {
try {
- updateEntity(var2);
+ updateEntity(weatherEffect);
} catch (Throwable var7) {
var4 = CrashReport.makeCrashReport(var7, "Ticking entity");
var5 = var4.makeCategory("Entity being ticked");
- var2.func_85029_a(var5);
+ weatherEffect.func_85029_a(var5);
throw new ReportedException(var4);
}
@@ -787,19 +789,19 @@ public void updateEntities() {
theProfiler.endSection();
theProfiler.startSection("remove");
- if (var2.isDead) {
- var3 = var2.chunkCoordX;
- var13 = var2.chunkCoordZ;
+ if (weatherEffect.isDead) {
+ var3 = weatherEffect.chunkCoordX;
+ var13 = weatherEffect.chunkCoordZ;
- if (var2.addedToChunk) {
+ if (weatherEffect.addedToChunk) {
Chunk chunk = getChunkIfExists(var3, var13);
if (chunk != null) {
- chunk.removeEntity(var2);
+ chunk.removeEntity(weatherEffect);
}
}
loadedEntityList.remove(var1--);
- releaseEntitySkin(var2);
+ releaseEntitySkin(weatherEffect);
}
theProfiler.endSection();