remove chunkManager
This commit is contained in:
@ -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 kcauldron.ChunkManager chunkManager = new kcauldron.ChunkManager();
|
||||
+
|
||||
+ public List loadedChunks = new ArrayList(); // Cauldron - vanilla compatibility
|
||||
public WorldServer worldObj;
|
||||
private Set<Long> loadingChunks = com.google.common.collect.Sets.newHashSet();
|
||||
+ public LongHashMap loadedChunkHashMap = new kcauldron.wrapper.VanillaChunkHashMap(chunkManager); // KCauldron - vanilla/mystcraft compatibility
|
||||
+ public LongHashMap loadedChunkHashMap = new LongHashMap();
|
||||
private static final String __OBFID = "CL_00001436";
|
||||
|
||||
public ChunkProviderServer(WorldServer p_i1520_1_, IChunkLoader p_i1520_2_, IChunkProvider p_i1520_3_)
|
||||
@ -80,12 +80,8 @@
|
||||
this.defaultEmptyChunk = new EmptyChunk(p_i1520_1_, 0, 0);
|
||||
this.worldObj = p_i1520_1_;
|
||||
this.currentChunkLoader = p_i1520_2_;
|
||||
@@ -57,16 +94,22 @@
|
||||
|
||||
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.chunkManager.chunkExists(p_73149_1_, p_73149_2_); // KCauldron
|
||||
@@ -60,13 +97,19 @@
|
||||
return this.loadedChunkHashMap.containsItem(ChunkCoordIntPair.chunkXZ2Int(p_73149_1_, p_73149_2_));
|
||||
}
|
||||
|
||||
- public List func_152380_a()
|
||||
@ -97,7 +93,7 @@
|
||||
public void unloadChunksIfNotNearSpawn(int p_73241_1_, int p_73241_2_)
|
||||
{
|
||||
+ // PaperSpigot start - Asynchronous lighting updates
|
||||
+ Chunk chunk = this.chunkManager.getChunk(p_73241_1_, p_73241_2_); // KCauldron
|
||||
+ Chunk chunk = this.getChunkIfLoaded(p_73241_1_,p_73241_2_);
|
||||
+ if (chunk != null && chunk.worldObj.spigotConfig.useAsyncLighting && (chunk.pendingLightUpdates.get() > 0 || chunk.worldObj.getTotalWorldTime() - chunk.lightUpdateTime < 20)) {
|
||||
+ return;
|
||||
+ }
|
||||
@ -105,7 +101,7 @@
|
||||
if (this.worldObj.provider.canRespawnHere() && DimensionManager.shouldLoadSpawn(this.worldObj.provider.dimensionId))
|
||||
{
|
||||
ChunkCoordinates chunkcoordinates = this.worldObj.getSpawnPoint();
|
||||
@@ -74,26 +117,52 @@
|
||||
@@ -74,14 +117,33 @@
|
||||
int l = p_73241_2_ * 16 + 8 - chunkcoordinates.posZ;
|
||||
short short1 = 128;
|
||||
|
||||
@ -141,32 +137,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
public void unloadAllChunks()
|
||||
{
|
||||
- Iterator iterator = this.loadedChunks.iterator();
|
||||
+ // KCauldron start
|
||||
+ this.chunkManager.forEach(new cern.colt.function.ObjectProcedure() {
|
||||
+ @Override
|
||||
+ public boolean apply(Object arg) {
|
||||
+ final Chunk chunk = (Chunk) arg;
|
||||
+ unloadChunksIfNotNearSpawn(chunk.xPosition, chunk.zPosition);
|
||||
+ return false;
|
||||
+ }
|
||||
+ });
|
||||
+ // KCauldron end
|
||||
+ }
|
||||
|
||||
- while (iterator.hasNext())
|
||||
- {
|
||||
- Chunk chunk = (Chunk)iterator.next();
|
||||
- this.unloadChunksIfNotNearSpawn(chunk.xPosition, chunk.zPosition);
|
||||
- }
|
||||
+ public Chunk getChunkIfLoaded(int x, int z) {
|
||||
+ return this.chunkManager.getChunk(x, z); // KCauldron
|
||||
@@ -96,6 +158,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ public Chunk getChunkIfLoaded(int x, int z) {
|
||||
+ return (Chunk)this.loadedChunkHashMap.getValueByKey(ChunkCoordIntPair.chunkXZ2Int(x, z));
|
||||
+ }
|
||||
+
|
||||
public Chunk loadChunk(int p_73158_1_, int p_73158_2_)
|
||||
@@ -103,9 +172,9 @@
|
||||
{
|
||||
return loadChunk(p_73158_1_, p_73158_2_, null);
|
||||
@@ -103,9 +169,9 @@
|
||||
|
||||
public Chunk loadChunk(int par1, int par2, Runnable runnable)
|
||||
{
|
||||
@ -174,12 +156,12 @@
|
||||
- this.chunksToUnload.remove(Long.valueOf(k));
|
||||
- Chunk chunk = (Chunk)this.loadedChunkHashMap.getValueByKey(k);
|
||||
+ this.chunksToUnload.remove(par1, par2);
|
||||
+ Chunk chunk = (Chunk) this.chunkManager.getChunk(par1, par2); // KCauldron
|
||||
+ Chunk chunk = this.getChunkIfLoaded(par1,par2);
|
||||
+ boolean newChunk = false;
|
||||
AnvilChunkLoader loader = null;
|
||||
|
||||
if (this.currentChunkLoader instanceof AnvilChunkLoader)
|
||||
@@ -113,6 +182,8 @@
|
||||
@@ -113,6 +179,8 @@
|
||||
loader = (AnvilChunkLoader) this.currentChunkLoader;
|
||||
}
|
||||
|
||||
@ -188,7 +170,7 @@
|
||||
// We can only use the queue for already generated chunks
|
||||
if (chunk == null && loader != null && loader.chunkExists(this.worldObj, par1, par2))
|
||||
{
|
||||
@@ -128,6 +199,12 @@
|
||||
@@ -128,6 +196,12 @@
|
||||
}
|
||||
else if (chunk == null)
|
||||
{
|
||||
@ -201,7 +183,7 @@
|
||||
chunk = this.originalLoadChunk(par1, par2);
|
||||
}
|
||||
|
||||
@@ -142,18 +219,20 @@
|
||||
@@ -142,18 +216,20 @@
|
||||
|
||||
public Chunk originalLoadChunk(int p_73158_1_, int p_73158_2_)
|
||||
{
|
||||
@ -210,7 +192,7 @@
|
||||
- Chunk chunk = (Chunk)this.loadedChunkHashMap.getValueByKey(k);
|
||||
+ generatorLock.lock(); try { // KCauldron
|
||||
+ this.chunksToUnload.remove(p_73158_1_, p_73158_2_);
|
||||
+ Chunk chunk = (Chunk) this.chunkManager.getChunk(p_73158_1_, p_73158_2_); // KCauldron
|
||||
+ Chunk chunk = this.getChunkIfLoaded(p_73158_1_,p_73158_2_);
|
||||
+ boolean newChunk = false; // CraftBukkit
|
||||
|
||||
if (chunk == null)
|
||||
@ -227,7 +209,7 @@
|
||||
if (chunk == null)
|
||||
{
|
||||
chunk = this.safeLoadChunk(p_73158_1_, p_73158_2_);
|
||||
@@ -176,30 +255,84 @@
|
||||
@@ -176,30 +252,84 @@
|
||||
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_)}));
|
||||
@ -245,7 +227,7 @@
|
||||
- this.loadedChunks.add(chunk);
|
||||
- loadingChunks.remove(k);
|
||||
- chunk.onChunkLoad();
|
||||
+ this.chunkManager.putChunk(chunk, p_73158_1_, p_73158_2_); // KCauldron
|
||||
+ this.loadedChunkHashMap.add(ChunkCoordIntPair.chunkXZ2Int(p_73158_1_,p_73158_2_),chunk);
|
||||
+ this.loadedChunks.add(chunk); // Cauldron - vanilla compatibility
|
||||
+ loadingChunks.remove(LongHash.toLong(p_73158_1_, p_73158_2_)); // Cauldron - LongHash
|
||||
+
|
||||
@ -294,7 +276,7 @@
|
||||
- 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 = this.chunkManager.getChunk(p_73154_1_, p_73154_2_); // KCauldron
|
||||
+ Chunk chunk = this.getChunkIfLoaded(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)
|
||||
@ -320,7 +302,7 @@
|
||||
{
|
||||
if (this.currentChunkLoader == null)
|
||||
{
|
||||
@@ -209,6 +342,7 @@
|
||||
@@ -209,6 +339,7 @@
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -328,7 +310,7 @@
|
||||
Chunk chunk = this.currentChunkLoader.loadChunk(this.worldObj, p_73239_1_, p_73239_2_);
|
||||
|
||||
if (chunk != null)
|
||||
@@ -217,8 +351,11 @@
|
||||
@@ -217,8 +348,11 @@
|
||||
|
||||
if (this.currentChunkProvider != null)
|
||||
{
|
||||
@ -340,7 +322,7 @@
|
||||
}
|
||||
|
||||
return chunk;
|
||||
@@ -231,7 +368,7 @@
|
||||
@@ -231,7 +365,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -349,7 +331,7 @@
|
||||
{
|
||||
if (this.currentChunkLoader != null)
|
||||
{
|
||||
@@ -246,7 +383,7 @@
|
||||
@@ -246,7 +380,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -358,7 +340,7 @@
|
||||
{
|
||||
if (this.currentChunkLoader != null)
|
||||
{
|
||||
@@ -254,15 +391,18 @@
|
||||
@@ -254,15 +388,18 @@
|
||||
{
|
||||
p_73242_1_.lastSaveTime = this.worldObj.getTotalWorldTime();
|
||||
this.currentChunkLoader.saveChunk(this.worldObj, p_73242_1_);
|
||||
@ -378,7 +360,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,6 +417,35 @@
|
||||
@@ -277,6 +414,35 @@
|
||||
if (this.currentChunkProvider != null)
|
||||
{
|
||||
this.currentChunkProvider.populate(p_73153_1_, p_73153_2_, p_73153_3_);
|
||||
@ -414,7 +396,7 @@
|
||||
GameRegistry.generateWorld(p_73153_2_, p_73153_3_, worldObj, currentChunkProvider, p_73153_1_);
|
||||
chunk.setChunkModified();
|
||||
}
|
||||
@@ -286,11 +455,13 @@
|
||||
@@ -286,11 +452,13 @@
|
||||
public boolean saveChunks(boolean p_73151_1_, IProgressUpdate p_73151_2_)
|
||||
{
|
||||
int i = 0;
|
||||
@ -431,7 +413,7 @@
|
||||
|
||||
if (p_73151_1_)
|
||||
{
|
||||
@@ -325,36 +496,73 @@
|
||||
@@ -325,36 +493,73 @@
|
||||
{
|
||||
if (!this.worldObj.levelSaving)
|
||||
{
|
||||
@ -454,7 +436,7 @@
|
||||
{
|
||||
- if (!this.chunksToUnload.isEmpty())
|
||||
+ long chunkcoordinates = this.chunksToUnload.popFirst();
|
||||
+ Chunk chunk = this.chunkManager.getChunk(LongHash.msw(chunkcoordinates), LongHash.lsw(chunkcoordinates));
|
||||
+ Chunk chunk = this.getChunkIfLoaded(LongHash.msw(chunkcoordinates), LongHash.lsw(chunkcoordinates));
|
||||
+
|
||||
+ if (chunk == null)
|
||||
{
|
||||
@ -509,10 +491,10 @@
|
||||
-
|
||||
- this.chunksToUnload.remove(olong);
|
||||
- this.loadedChunkHashMap.remove(olong.longValue());
|
||||
+ this.chunkManager.remove(chunk.xPosition, chunk.zPosition); // KCauldron
|
||||
+ this.loadedChunkHashMap.remove(ChunkCoordIntPair.chunkXZ2Int(chunk.xPosition, chunk.zPosition));
|
||||
+ this.loadedChunks.remove(chunk); // Cauldron - vanilla compatibility
|
||||
+ ForgeChunkManager.putDormantChunk(chunkcoordinates, chunk);
|
||||
+ if(this.chunkManager.size() == 0 && ForgeChunkManager.getPersistentChunksFor(this.worldObj).size() == 0 && !DimensionManager.shouldLoadSpawn(this.worldObj.provider.dimensionId)){
|
||||
+ if(this.loadedChunkHashMap.getNumHashElements() == 0 && ForgeChunkManager.getPersistentChunksFor(this.worldObj).size() == 0 && !DimensionManager.shouldLoadSpawn(this.worldObj.provider.dimensionId)){
|
||||
+ DimensionManager.unloadWorld(this.worldObj.provider.dimensionId);
|
||||
+ return currentChunkProvider.unloadQueuedChunks();
|
||||
+ }
|
||||
@ -524,21 +506,16 @@
|
||||
if (this.currentChunkLoader != null)
|
||||
{
|
||||
this.currentChunkLoader.chunkTick();
|
||||
@@ -371,7 +579,7 @@
|
||||
@@ -371,7 +576,7 @@
|
||||
|
||||
public String makeString()
|
||||
{
|
||||
- return "ServerChunkCache: " + this.loadedChunkHashMap.getNumHashElements() + " Drop: " + this.chunksToUnload.size();
|
||||
+ return "ServerChunkCache: " + this.chunkManager.size() + " Drop: " + this.chunksToUnload.size(); // Cauldron
|
||||
+ return "ServerChunkCache: " + this.loadedChunkHashMap.getNumHashElements() + " 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 +594,53 @@
|
||||
|
||||
public int getLoadedChunkCount()
|
||||
{
|
||||
- return this.loadedChunkHashMap.getNumHashElements();
|
||||
+ return this.chunkManager.size(); // KCauldron
|
||||
@@ -390,4 +595,49 @@
|
||||
}
|
||||
|
||||
public void recreateStructures(int p_82695_1_, int p_82695_2_) {}
|
||||
@ -554,7 +531,7 @@
|
||||
+
|
||||
+ public long lastAccessed(int x, int z)
|
||||
+ {
|
||||
+ final Chunk chunk = this.chunkManager.getChunk(x, z); // KCauldron
|
||||
+ final Chunk chunk = this.getChunkIfLoaded(x,x);
|
||||
+ return chunk == null ? 0 : chunk.lastAccessedTick; // KCauldron
|
||||
+ }
|
||||
+
|
||||
|
Reference in New Issue
Block a user