Fix a potential problem with "Entity already added" when using the dormant

chunk cache capability. The entities in the dormant chunk cache will get new
IDs prior to the cached chunk returning.
This commit is contained in:
Christian 2013-01-25 21:21:20 -05:00
parent f20ea649c6
commit ae7e328228
2 changed files with 21 additions and 2 deletions

View file

@ -880,7 +880,18 @@ public class ForgeChunkManager
public static Chunk fetchDormantChunk(long coords, World world)
{
Cache<Long, Chunk> cache = dormantChunkCache.get(world);
return cache == null ? null : cache.getIfPresent(coords);
Chunk chunk = cache.getIfPresent(coords);
if (chunk != null)
{
for (List<Entity> eList : chunk.entityLists)
{
for (Entity e: eList)
{
e.resetEntityId();
}
}
}
return chunk;
}
static void captureConfig(File configDir)

View file

@ -138,7 +138,7 @@
}
public int func_82143_as()
@@ -2399,4 +2441,84 @@
@@ -2399,4 +2441,92 @@
{
return this.isBurning();
}
@ -221,5 +221,13 @@
+ {
+ persistentID = UUID.randomUUID();
+ }
+ }
+
+ /**
+ * Reset the entity ID to a new value. Not to be used from Mod code
+ */
+ public final void resetEntityId()
+ {
+ this.entityId = nextEntityID++;
+ }
}