Finally fix #67
This commit is contained in:
@ -73,7 +73,7 @@
|
||||
|
||||
if (this.players.isEmpty())
|
||||
{
|
||||
+ if (this.theWorldServer.loadedEntityList.size() == 0 || this.theWorldServer.theChunkProviderServer.loadedChunkHashMap.size() == 0)
|
||||
+ if (this.theWorldServer.loadedEntityList.size() == 0 || this.theWorldServer.theChunkProviderServer.loadedChunkHashMap_KC.size() == 0)
|
||||
+ {
|
||||
+ return; // CraftBukkit - Only do unload when we go from non-empty to empty
|
||||
+ }
|
||||
|
@ -67,11 +67,11 @@
|
||||
- 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 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 WorldServer worldObj;
|
||||
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); // KCauldron - vanilla/mystcraft compatibility
|
||||
private static final String __OBFID = "CL_00001436";
|
||||
|
||||
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_)
|
||||
{
|
||||
- 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()
|
||||
@ -102,7 +102,7 @@
|
||||
{
|
||||
- this.chunksToUnload.add(Long.valueOf(ChunkCoordIntPair.chunkXZ2Int(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)
|
||||
+ {
|
||||
@ -118,7 +118,7 @@
|
||||
- this.chunksToUnload.add(Long.valueOf(ChunkCoordIntPair.chunkXZ2Int(p_73241_1_, p_73241_2_)));
|
||||
+ // CraftBukkit start
|
||||
+ 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)
|
||||
+ {
|
||||
@ -138,7 +138,7 @@
|
||||
- Chunk chunk = (Chunk)iterator.next();
|
||||
- this.unloadChunksIfNotNearSpawn(chunk.xPosition, chunk.zPosition);
|
||||
- }
|
||||
+ this.loadedChunkHashMap.forEachValue(new TObjectProcedure<Chunk>() {
|
||||
+ this.loadedChunkHashMap_KC.forEachValue(new TObjectProcedure<Chunk>() {
|
||||
+ @Override
|
||||
+ public boolean execute(Chunk chunk) {
|
||||
+ unloadChunksIfNotNearSpawn(chunk.xPosition, chunk.zPosition);
|
||||
@ -156,7 +156,7 @@
|
||||
- this.chunksToUnload.remove(Long.valueOf(k));
|
||||
- Chunk chunk = (Chunk)this.loadedChunkHashMap.getValueByKey(k);
|
||||
+ 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;
|
||||
AnvilChunkLoader loader = null;
|
||||
|
||||
@ -178,7 +178,7 @@
|
||||
- this.chunksToUnload.remove(Long.valueOf(k));
|
||||
- Chunk chunk = (Chunk)this.loadedChunkHashMap.getValueByKey(k);
|
||||
+ 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
|
||||
|
||||
if (chunk == null)
|
||||
@ -195,7 +195,7 @@
|
||||
if (chunk == null)
|
||||
{
|
||||
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");
|
||||
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_)}));
|
||||
@ -213,9 +213,8 @@
|
||||
- this.loadedChunks.add(chunk);
|
||||
- loadingChunks.remove(k);
|
||||
- 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.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
|
||||
+
|
||||
+ if (chunk != null)
|
||||
@ -241,14 +240,14 @@
|
||||
}
|
||||
|
||||
return chunk;
|
||||
@@ -195,11 +276,29 @@
|
||||
@@ -195,11 +275,29 @@
|
||||
|
||||
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_));
|
||||
- return chunk == null ? (!this.worldObj.findingSpawnPoint && !this.loadChunkOnProvideRequest ? this.defaultEmptyChunk : this.loadChunk(p_73154_1_, p_73154_2_)) : chunk;
|
||||
+ // 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)
|
||||
+
|
||||
+ if (chunk == this.defaultEmptyChunk)
|
||||
@ -274,7 +273,7 @@
|
||||
{
|
||||
if (this.currentChunkLoader == null)
|
||||
{
|
||||
@@ -209,6 +308,7 @@
|
||||
@@ -209,6 +307,7 @@
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -282,7 +281,7 @@
|
||||
Chunk chunk = this.currentChunkLoader.loadChunk(this.worldObj, p_73239_1_, p_73239_2_);
|
||||
|
||||
if (chunk != null)
|
||||
@@ -217,8 +317,11 @@
|
||||
@@ -217,8 +316,11 @@
|
||||
|
||||
if (this.currentChunkProvider != null)
|
||||
{
|
||||
@ -294,7 +293,7 @@
|
||||
}
|
||||
|
||||
return chunk;
|
||||
@@ -231,7 +334,7 @@
|
||||
@@ -231,7 +333,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -303,7 +302,7 @@
|
||||
{
|
||||
if (this.currentChunkLoader != null)
|
||||
{
|
||||
@@ -246,7 +349,7 @@
|
||||
@@ -246,7 +348,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -312,7 +311,7 @@
|
||||
{
|
||||
if (this.currentChunkLoader != null)
|
||||
{
|
||||
@@ -254,15 +357,18 @@
|
||||
@@ -254,15 +356,18 @@
|
||||
{
|
||||
p_73242_1_.lastSaveTime = this.worldObj.getTotalWorldTime();
|
||||
this.currentChunkLoader.saveChunk(this.worldObj, p_73242_1_);
|
||||
@ -332,7 +331,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,6 +383,35 @@
|
||||
@@ -277,6 +382,35 @@
|
||||
if (this.currentChunkProvider != null)
|
||||
{
|
||||
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_);
|
||||
chunk.setChunkModified();
|
||||
}
|
||||
@@ -286,11 +421,13 @@
|
||||
@@ -286,11 +420,13 @@
|
||||
public boolean saveChunks(boolean p_73151_1_, IProgressUpdate p_73151_2_)
|
||||
{
|
||||
int i = 0;
|
||||
@ -385,7 +384,7 @@
|
||||
|
||||
if (p_73151_1_)
|
||||
{
|
||||
@@ -325,36 +462,61 @@
|
||||
@@ -325,36 +461,60 @@
|
||||
{
|
||||
if (!this.worldObj.levelSaving)
|
||||
{
|
||||
@ -408,7 +407,7 @@
|
||||
{
|
||||
- if (!this.chunksToUnload.isEmpty())
|
||||
+ long chunkcoordinates = this.chunksToUnload.popFirst();
|
||||
+ Chunk chunk = this.loadedChunkHashMap.get(chunkcoordinates);
|
||||
+ Chunk chunk = this.loadedChunkHashMap_KC.get(chunkcoordinates);
|
||||
+
|
||||
+ if (chunk == null)
|
||||
{
|
||||
@ -451,11 +450,10 @@
|
||||
+ this.safeSaveChunk(chunk);
|
||||
+ this.safeSaveExtraChunkData(chunk);
|
||||
+ // this.unloadQueue.remove(olong);
|
||||
+ this.loadedChunkHashMap.remove(chunkcoordinates); // CraftBukkit
|
||||
+ this.loadedChunkHashMap_KC.remove(chunkcoordinates); // CraftBukkit
|
||||
+ 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);
|
||||
+ 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);
|
||||
+ return currentChunkProvider.unloadQueuedChunks();
|
||||
+ }
|
||||
@ -467,21 +465,21 @@
|
||||
if (this.currentChunkLoader != null)
|
||||
{
|
||||
this.currentChunkLoader.chunkTick();
|
||||
@@ -371,7 +533,7 @@
|
||||
@@ -371,7 +531,7 @@
|
||||
|
||||
public String makeString()
|
||||
{
|
||||
- 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_)
|
||||
@@ -386,8 +548,31 @@
|
||||
@@ -386,8 +546,31 @@
|
||||
|
||||
public int getLoadedChunkCount()
|
||||
{
|
||||
- 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_) {}
|
||||
@ -498,8 +496,8 @@
|
||||
+ public long lastAccessed(int x, int z)
|
||||
+ {
|
||||
+ long chunkHash = LongHash.toLong(x, z);
|
||||
+ if (!loadedChunkHashMap.containsKey(chunkHash)) return 0;
|
||||
+ return loadedChunkHashMap.get(chunkHash).lastAccessedTick;
|
||||
+ if (!loadedChunkHashMap_KC.containsKey(chunkHash)) return 0;
|
||||
+ return loadedChunkHashMap_KC.get(chunkHash).lastAccessedTick;
|
||||
+ }
|
||||
+
|
||||
+ /*private boolean shouldUnloadChunk(Chunk chunk)
|
||||
|
@ -10,14 +10,13 @@
|
||||
class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider<QueuedChunk, net.minecraft.world.chunk.Chunk, Runnable, RuntimeException> {
|
||||
private final AtomicInteger threadNumber = new AtomicInteger(1);
|
||||
|
||||
@@ -41,13 +44,21 @@
|
||||
@@ -41,13 +44,20 @@
|
||||
queuedChunk.loader.loadEntities(queuedChunk.world, queuedChunk.compound.getCompoundTag("Level"), chunk);
|
||||
MinecraftForge.EVENT_BUS.post(new ChunkDataEvent.Load(chunk, queuedChunk.compound)); // Don't call ChunkDataEvent.Load async
|
||||
chunk.lastSaveTime = queuedChunk.provider.worldObj.getTotalWorldTime();
|
||||
- queuedChunk.provider.loadedChunkHashMap.add(ChunkCoordIntPair.chunkXZ2Int(queuedChunk.x, queuedChunk.z), chunk);
|
||||
+ queuedChunk.provider.loadedChunkHashMap.put(LongHash.toLong(queuedChunk.x, queuedChunk.z), chunk);
|
||||
+ queuedChunk.provider.loadedChunkHashMap_KC.put(LongHash.toLong(queuedChunk.x, queuedChunk.z), chunk);
|
||||
queuedChunk.provider.loadedChunks.add(chunk);
|
||||
+ queuedChunk.provider.loadedChunkHashMap_vanilla.add(ChunkCoordIntPair.chunkXZ2Int(queuedChunk.x, queuedChunk.z), chunk); // Cauldron - vanilla/mystcraft compatibility
|
||||
chunk.onChunkLoad();
|
||||
|
||||
if (queuedChunk.provider.currentChunkProvider != null) {
|
||||
|
Reference in New Issue
Block a user