@ -67,11 +67,11 @@
- public List loadedChunks = new ArrayList();
- public List loadedChunks = new ArrayList();
+ public boolean loadChunkOnProvideRequest = MinecraftServer.getServer().cauldronConfig.loadChunkOnRequest.getValue(); // Cauldron - if true, allows mods to force load chunks. to disable, set load-chunk-on-request in cauldron.yml to false
+ public boolean loadChunkOnProvideRequest = MinecraftServer.getServer().cauldronConfig.loadChunkOnRequest.getValue(); // Cauldron - if true, allows mods to force load chunks. to disable, set load-chunk-on-request in cauldron.yml to false
+ public int initialTick; // Cauldron counter to keep track of when this loader was created
+ public int initialTick; // Cauldron counter to keep track of when this loader was created
+ public TLongObjectMap<Chunk> loadedChunkHashMap = new TSynchronizedLongObjectMap<Chunk>(new TLongObjectHashMap<Chunk>());
+ public TLongObjectMap<Chunk> loadedChunkHashMap_KC = new TSynchronizedLongObjectMap<Chunk>(new TLongObjectHashMap<Chunk>());
+ public List loadedChunks = new ArrayList(); // Cauldron - vanilla compatibility
+ public List loadedChunks = new ArrayList(); // Cauldron - vanilla compatibility
public WorldServer worldObj;
public WorldServer worldObj;
private Set<Long> loadingChunks = com.google.common.collect.Sets.newHashSet();
private Set<Long> loadingChunks = com.google.common.collect.Sets.newHashSet();
+ public LongHashMap loadedChunkHashMap_vanilla = new LongHashMap(); // Cauldron - vanilla/mystcraft compatibility
+ public LongHashMap loadedChunkHashMap = new kcauldron.wrapper.VanillaChunkHashMap(loadedChunkHashMap_KC); // K Cauldron - vanilla/mystcraft compatibility
private static final String __OBFID = "CL_00001436";
private static final String __OBFID = "CL_00001436";
public ChunkProviderServer(WorldServer p_i1520_1_, IChunkLoader p_i1520_2_, IChunkProvider p_i1520_3_)
public ChunkProviderServer(WorldServer p_i1520_1_, IChunkLoader p_i1520_2_, IChunkProvider p_i1520_3_)
@ -85,7 +85,7 @@
public boolean chunkExists(int p_73149_1_, int p_73149_2_)
public boolean chunkExists(int p_73149_1_, int p_73149_2_)
{
{
- return this.loadedChunkHashMap.containsItem(ChunkCoordIntPair.chunkXZ2Int(p_73149_1_, p_73149_2_));
- return this.loadedChunkHashMap.containsItem(ChunkCoordIntPair.chunkXZ2Int(p_73149_1_, p_73149_2_));
+ return this.loadedChunkHashMap.containsKey(LongHash.toLong(p_73149_1_, p_73149_2_)); // CraftBukkit
+ return this.loadedChunkHashMap_KC .containsKey(LongHash.toLong(p_73149_1_, p_73149_2_)); // CraftBukkit
}
}
- public List func_152380_a()
- public List func_152380_a()
@ -102,7 +102,7 @@
{
{
- this.chunksToUnload.add(Long.valueOf(ChunkCoordIntPair.chunkXZ2Int(p_73241_1_, p_73241_2_)));
- this.chunksToUnload.add(Long.valueOf(ChunkCoordIntPair.chunkXZ2Int(p_73241_1_, p_73241_2_)));
+ this.chunksToUnload.add(p_73241_1_, p_73241_2_);
+ this.chunksToUnload.add(p_73241_1_, p_73241_2_);
+ Chunk c = this.loadedChunkHashMap.get(LongHash.toLong(p_73241_1_, p_73241_2_));
+ Chunk c = this.loadedChunkHashMap_KC .get(LongHash.toLong(p_73241_1_, p_73241_2_));
+
+
+ if (c != null)
+ if (c != null)
+ {
+ {
@ -118,7 +118,7 @@
- this.chunksToUnload.add(Long.valueOf(ChunkCoordIntPair.chunkXZ2Int(p_73241_1_, p_73241_2_)));
- this.chunksToUnload.add(Long.valueOf(ChunkCoordIntPair.chunkXZ2Int(p_73241_1_, p_73241_2_)));
+ // CraftBukkit start
+ // CraftBukkit start
+ this.chunksToUnload.add(p_73241_1_, p_73241_2_);
+ this.chunksToUnload.add(p_73241_1_, p_73241_2_);
+ Chunk c = this.loadedChunkHashMap.get(LongHash.toLong(p_73241_1_, p_73241_2_));
+ Chunk c = this.loadedChunkHashMap_KC .get(LongHash.toLong(p_73241_1_, p_73241_2_));
+
+
+ if (c != null)
+ if (c != null)
+ {
+ {
@ -138,7 +138,7 @@
- Chunk chunk = (Chunk)iterator.next();
- Chunk chunk = (Chunk)iterator.next();
- this.unloadChunksIfNotNearSpawn(chunk.xPosition, chunk.zPosition);
- this.unloadChunksIfNotNearSpawn(chunk.xPosition, chunk.zPosition);
- }
- }
+ this.loadedChunkHashMap.forEachValue(new TObjectProcedure<Chunk>() {
+ this.loadedChunkHashMap_KC .forEachValue(new TObjectProcedure<Chunk>() {
+ @Override
+ @Override
+ public boolean execute(Chunk chunk) {
+ public boolean execute(Chunk chunk) {
+ unloadChunksIfNotNearSpawn(chunk.xPosition, chunk.zPosition);
+ unloadChunksIfNotNearSpawn(chunk.xPosition, chunk.zPosition);
@ -156,7 +156,7 @@
- this.chunksToUnload.remove(Long.valueOf(k));
- this.chunksToUnload.remove(Long.valueOf(k));
- Chunk chunk = (Chunk)this.loadedChunkHashMap.getValueByKey(k);
- Chunk chunk = (Chunk)this.loadedChunkHashMap.getValueByKey(k);
+ this.chunksToUnload.remove(par1, par2);
+ this.chunksToUnload.remove(par1, par2);
+ Chunk chunk = (Chunk) this.loadedChunkHashMap.get(LongHash.toLong(par1, par2));
+ Chunk chunk = (Chunk) this.loadedChunkHashMap_KC .get(LongHash.toLong(par1, par2));
+ boolean newChunk = false;
+ boolean newChunk = false;
AnvilChunkLoader loader = null;
AnvilChunkLoader loader = null;
@ -178,7 +178,7 @@
- this.chunksToUnload.remove(Long.valueOf(k));
- this.chunksToUnload.remove(Long.valueOf(k));
- Chunk chunk = (Chunk)this.loadedChunkHashMap.getValueByKey(k);
- Chunk chunk = (Chunk)this.loadedChunkHashMap.getValueByKey(k);
+ this.chunksToUnload.remove(p_73158_1_, p_73158_2_);
+ this.chunksToUnload.remove(p_73158_1_, p_73158_2_);
+ Chunk chunk = (Chunk) this.loadedChunkHashMap.get(LongHash.toLong(p_73158_1_, p_73158_2_));
+ Chunk chunk = (Chunk) this.loadedChunkHashMap_KC .get(LongHash.toLong(p_73158_1_, p_73158_2_));
+ boolean newChunk = false; // CraftBukkit
+ boolean newChunk = false; // CraftBukkit
if (chunk == null)
if (chunk == null)
@ -195,7 +195,7 @@
if (chunk == null)
if (chunk == null)
{
{
chunk = this.safeLoadChunk(p_73158_1_, p_73158_2_);
chunk = this.safeLoadChunk(p_73158_1_, p_73158_2_);
@@ -176,18 +235,40 @@
@@ -176,18 +235,39 @@
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Exception generating new chunk");
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Exception generating new chunk");
CrashReportCategory crashreportcategory = crashreport.makeCategory("Chunk to be generated");
CrashReportCategory crashreportcategory = crashreport.makeCategory("Chunk to be generated");
crashreportcategory.addCrashSection("Location", String.format("%d,%d", new Object[] {Integer.valueOf(p_73158_1_), Integer.valueOf(p_73158_2_)}));
crashreportcategory.addCrashSection("Location", String.format("%d,%d", new Object[] {Integer.valueOf(p_73158_1_), Integer.valueOf(p_73158_2_)}));
@ -213,9 +213,8 @@
- this.loadedChunks.add(chunk);
- this.loadedChunks.add(chunk);
- loadingChunks.remove(k);
- loadingChunks.remove(k);
- chunk.onChunkLoad();
- chunk.onChunkLoad();
+ this.loadedChunkHashMap.put(LongHash.toLong(p_73158_1_, p_73158_2_), chunk); // CraftBukkit
+ this.loadedChunkHashMap_KC .put(LongHash.toLong(p_73158_1_, p_73158_2_), chunk); // CraftBukkit
+ this.loadedChunks.add(chunk); // Cauldron - vanilla compatibility
+ this.loadedChunks.add(chunk); // Cauldron - vanilla compatibility
+ this.loadedChunkHashMap_vanilla.add(ChunkCoordIntPair.chunkXZ2Int(p_73158_1_, p_73158_2_), chunk); // Cauldron - vanilla/mystcraft compatibility
+ loadingChunks.remove(LongHash.toLong(p_73158_1_, p_73158_2_)); // Cauldron - LongHash
+ loadingChunks.remove(LongHash.toLong(p_73158_1_, p_73158_2_)); // Cauldron - LongHash
+
+
+ if (chunk != null)
+ if (chunk != null)
@ -241,14 +240,14 @@
}
}
return chunk;
return chunk;
@@ -195,11 +276 ,29 @@
@@ -195,11 +275 ,29 @@
public Chunk provideChunk(int p_73154_1_, int p_73154_2_)
public Chunk provideChunk(int p_73154_1_, int p_73154_2_)
{
{
- Chunk chunk = (Chunk)this.loadedChunkHashMap.getValueByKey(ChunkCoordIntPair.chunkXZ2Int(p_73154_1_, p_73154_2_));
- Chunk chunk = (Chunk)this.loadedChunkHashMap.getValueByKey(ChunkCoordIntPair.chunkXZ2Int(p_73154_1_, p_73154_2_));
- return chunk == null ? (!this.worldObj.findingSpawnPoint && !this.loadChunkOnProvideRequest ? this.defaultEmptyChunk : this.loadChunk(p_73154_1_, p_73154_2_)) : chunk;
- return chunk == null ? (!this.worldObj.findingSpawnPoint && !this.loadChunkOnProvideRequest ? this.defaultEmptyChunk : this.loadChunk(p_73154_1_, p_73154_2_)) : chunk;
+ // CraftBukkit start
+ // CraftBukkit start
+ Chunk chunk = (Chunk) this.loadedChunkHashMap.get(LongHash.toLong(p_73154_1_, p_73154_2_));
+ Chunk chunk = (Chunk) this.loadedChunkHashMap_KC .get(LongHash.toLong(p_73154_1_, p_73154_2_));
+ chunk = chunk == null ? (shouldLoadChunk() ? this.loadChunk(p_73154_1_, p_73154_2_) : this.defaultEmptyChunk) : chunk; // Cauldron handle forge server tick events and load the chunk within 5 seconds of the world being loaded (for chunk loaders)
+ chunk = chunk == null ? (shouldLoadChunk() ? this.loadChunk(p_73154_1_, p_73154_2_) : this.defaultEmptyChunk) : chunk; // Cauldron handle forge server tick events and load the chunk within 5 seconds of the world being loaded (for chunk loaders)
+
+
+ if (chunk == this.defaultEmptyChunk)
+ if (chunk == this.defaultEmptyChunk)
@ -274,7 +273,7 @@
{
{
if (this.currentChunkLoader == null)
if (this.currentChunkLoader == null)
{
{
@@ -209,6 +308 ,7 @@
@@ -209,6 +307 ,7 @@
{
{
try
try
{
{
@ -282,7 +281,7 @@
Chunk chunk = this.currentChunkLoader.loadChunk(this.worldObj, p_73239_1_, p_73239_2_);
Chunk chunk = this.currentChunkLoader.loadChunk(this.worldObj, p_73239_1_, p_73239_2_);
if (chunk != null)
if (chunk != null)
@@ -217,8 +317 ,11 @@
@@ -217,8 +316 ,11 @@
if (this.currentChunkProvider != null)
if (this.currentChunkProvider != null)
{
{
@ -294,7 +293,7 @@
}
}
return chunk;
return chunk;
@@ -231,7 +334 ,7 @@
@@ -231,7 +333 ,7 @@
}
}
}
}
@ -303,7 +302,7 @@
{
{
if (this.currentChunkLoader != null)
if (this.currentChunkLoader != null)
{
{
@@ -246,7 +349 ,7 @@
@@ -246,7 +348 ,7 @@
}
}
}
}
@ -312,7 +311,7 @@
{
{
if (this.currentChunkLoader != null)
if (this.currentChunkLoader != null)
{
{
@@ -254,15 +357 ,18 @@
@@ -254,15 +356 ,18 @@
{
{
p_73242_1_.lastSaveTime = this.worldObj.getTotalWorldTime();
p_73242_1_.lastSaveTime = this.worldObj.getTotalWorldTime();
this.currentChunkLoader.saveChunk(this.worldObj, p_73242_1_);
this.currentChunkLoader.saveChunk(this.worldObj, p_73242_1_);
@ -332,7 +331,7 @@
}
}
}
}
@@ -277,6 +383 ,35 @@
@@ -277,6 +382 ,35 @@
if (this.currentChunkProvider != null)
if (this.currentChunkProvider != null)
{
{
this.currentChunkProvider.populate(p_73153_1_, p_73153_2_, p_73153_3_);
this.currentChunkProvider.populate(p_73153_1_, p_73153_2_, p_73153_3_);
@ -368,7 +367,7 @@
GameRegistry.generateWorld(p_73153_2_, p_73153_3_, worldObj, currentChunkProvider, p_73153_1_);
GameRegistry.generateWorld(p_73153_2_, p_73153_3_, worldObj, currentChunkProvider, p_73153_1_);
chunk.setChunkModified();
chunk.setChunkModified();
}
}
@@ -286,11 +421 ,13 @@
@@ -286,11 +420 ,13 @@
public boolean saveChunks(boolean p_73151_1_, IProgressUpdate p_73151_2_)
public boolean saveChunks(boolean p_73151_1_, IProgressUpdate p_73151_2_)
{
{
int i = 0;
int i = 0;
@ -385,7 +384,7 @@
if (p_73151_1_)
if (p_73151_1_)
{
{
@@ -325,36 +462,61 @@
@@ -325,36 +461,60 @@
{
{
if (!this.worldObj.levelSaving)
if (!this.worldObj.levelSaving)
{
{
@ -408,7 +407,7 @@
{
{
- if (!this.chunksToUnload.isEmpty())
- if (!this.chunksToUnload.isEmpty())
+ long chunkcoordinates = this.chunksToUnload.popFirst();
+ long chunkcoordinates = this.chunksToUnload.popFirst();
+ Chunk chunk = this.loadedChunkHashMap.get(chunkcoordinates);
+ Chunk chunk = this.loadedChunkHashMap_KC .get(chunkcoordinates);
+
+
+ if (chunk == null)
+ if (chunk == null)
{
{
@ -451,11 +450,10 @@
+ this.safeSaveChunk(chunk);
+ this.safeSaveChunk(chunk);
+ this.safeSaveExtraChunkData(chunk);
+ this.safeSaveExtraChunkData(chunk);
+ // this.unloadQueue.remove(olong);
+ // this.unloadQueue.remove(olong);
+ this.loadedChunkHashMap.remove(chunkcoordinates); // CraftBukkit
+ this.loadedChunkHashMap_KC .remove(chunkcoordinates); // CraftBukkit
+ this.loadedChunks.remove(chunk); // Cauldron - vanilla compatibility
+ this.loadedChunks.remove(chunk); // Cauldron - vanilla compatibility
+ this.loadedChunkHashMap_vanilla.remove(ChunkCoordIntPair.chunkXZ2Int(LongHash.msw(chunkcoordinates), LongHash.lsw(chunkcoordinates))); // Cauldron - vanilla/mystcraft compatibility
+ ForgeChunkManager.putDormantChunk(chunkcoordinates, chunk);
+ ForgeChunkManager.putDormantChunk(chunkcoordinates, chunk);
+ if(this.loadedChunkHashMap.size() == 0 && ForgeChunkManager.getPersistentChunksFor(this.worldObj).size() == 0 && !DimensionManager.shouldLoadSpawn(this.worldObj.provider.dimensionId)){
+ if(this.loadedChunkHashMap_KC .size() == 0 && ForgeChunkManager.getPersistentChunksFor(this.worldObj).size() == 0 && !DimensionManager.shouldLoadSpawn(this.worldObj.provider.dimensionId)){
+ DimensionManager.unloadWorld(this.worldObj.provider.dimensionId);
+ DimensionManager.unloadWorld(this.worldObj.provider.dimensionId);
+ return currentChunkProvider.unloadQueuedChunks();
+ return currentChunkProvider.unloadQueuedChunks();
+ }
+ }
@ -467,21 +465,21 @@
if (this.currentChunkLoader != null)
if (this.currentChunkLoader != null)
{
{
this.currentChunkLoader.chunkTick();
this.currentChunkLoader.chunkTick();
@@ -371,7 +533 ,7 @@
@@ -371,7 +531 ,7 @@
public String makeString()
public String makeString()
{
{
- return "ServerChunkCache: " + this.loadedChunkHashMap.getNumHashElements() + " Drop: " + this.chunksToUnload.size();
- return "ServerChunkCache: " + this.loadedChunkHashMap.getNumHashElements() + " Drop: " + this.chunksToUnload.size();
+ return "ServerChunkCache: " + this.loadedChunkHashMap.size() + " Drop: " + this.chunksToUnload.size(); // Cauldron
+ return "ServerChunkCache: " + this.loadedChunkHashMap_KC .size() + " Drop: " + this.chunksToUnload.size(); // Cauldron
}
}
public List getPossibleCreatures(EnumCreatureType p_73155_1_, int p_73155_2_, int p_73155_3_, int p_73155_4_)
public List getPossibleCreatures(EnumCreatureType p_73155_1_, int p_73155_2_, int p_73155_3_, int p_73155_4_)
@@ -386,8 +548 ,31 @@
@@ -386,8 +546 ,31 @@
public int getLoadedChunkCount()
public int getLoadedChunkCount()
{
{
- return this.loadedChunkHashMap.getNumHashElements();
- return this.loadedChunkHashMap.getNumHashElements();
+ return this.loadedChunkHashMap.size(); // Cauldron
+ return this.loadedChunkHashMap_KC .size(); // Cauldron
}
}
public void recreateStructures(int p_82695_1_, int p_82695_2_) {}
public void recreateStructures(int p_82695_1_, int p_82695_2_) {}
@ -498,8 +496,8 @@
+ public long lastAccessed(int x, int z)
+ public long lastAccessed(int x, int z)
+ {
+ {
+ long chunkHash = LongHash.toLong(x, z);
+ long chunkHash = LongHash.toLong(x, z);
+ if (!loadedChunkHashMap.containsKey(chunkHash)) return 0;
+ if (!loadedChunkHashMap_KC .containsKey(chunkHash)) return 0;
+ return loadedChunkHashMap.get(chunkHash).lastAccessedTick;
+ return loadedChunkHashMap_KC .get(chunkHash).lastAccessedTick;
+ }
+ }
+
+
+ /*private boolean shouldUnloadChunk(Chunk chunk)
+ /*private boolean shouldUnloadChunk(Chunk chunk)