3
0

Merge branch 'kcx-1614' of ssh://git.xjboss.net:3389/KC-RELOADED/KCauldronX into kcx-1614

This commit is contained in:
xjboss 2017-08-02 18:54:06 +08:00
commit bf320fbbfa
10 changed files with 102 additions and 127 deletions

View File

@ -73,7 +73,7 @@
if (this.players.isEmpty()) if (this.players.isEmpty())
{ {
+ if (this.theWorldServer.loadedEntityList.size() == 0 || this.theWorldServer.theChunkProviderServer.chunkManager.size() == 0) + if (this.theWorldServer.loadedEntityList.size() == 0 || this.theWorldServer.theChunkProviderServer.getLoadedChunkCount() == 0)
+ { + {
+ return; // CraftBukkit - Only do unload when we go from non-empty to empty + return; // CraftBukkit - Only do unload when we go from non-empty to empty
+ } + }

View File

@ -963,7 +963,7 @@
} }
catch (Throwable throwable1) catch (Throwable throwable1)
{ {
@@ -1916,30 +2420,84 @@ @@ -1916,30 +2420,87 @@
{ {
this.getChunkFromChunkCoords(j, l).removeEntity(entity); this.getChunkFromChunkCoords(j, l).removeEntity(entity);
} }
@ -1040,7 +1040,10 @@
+ } + }
+ +
+ if (tileentity.hasWorldObj() && CauldronHooks.canTileEntityTick(tileentity, this) + if (tileentity.hasWorldObj() && CauldronHooks.canTileEntityTick(tileentity, this)
+ && this.blockExists(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord)) + && (MinecraftServer.cauldronConfig.tickTEOnlyChunkActive.getValue()?this.isActiveBlockCoord(tileentity.xCoord,tileentity.zCoord):
+ this.blockExists(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord)
+ )
+ )
+ { + {
try try
{ {
@ -1055,7 +1058,7 @@
crashreport = CrashReport.makeCrashReport(throwable, "Ticking block entity"); crashreport = CrashReport.makeCrashReport(throwable, "Ticking block entity");
crashreportcategory = crashreport.makeCategory("Block entity being ticked"); crashreportcategory = crashreport.makeCategory("Block entity being ticked");
tileentity.func_145828_a(crashreportcategory); tileentity.func_145828_a(crashreportcategory);
@@ -1955,23 +2513,13 @@ @@ -1955,23 +2516,13 @@
} }
} }
} }
@ -1084,7 +1087,7 @@
if (!this.field_147483_b.isEmpty()) if (!this.field_147483_b.isEmpty())
{ {
for (Object tile : field_147483_b) for (Object tile : field_147483_b)
@@ -1981,6 +2529,7 @@ @@ -1981,6 +2532,7 @@
this.loadedTileEntityList.removeAll(this.field_147483_b); this.loadedTileEntityList.removeAll(this.field_147483_b);
this.field_147483_b.clear(); this.field_147483_b.clear();
} }
@ -1092,7 +1095,7 @@
this.field_147481_N = false; this.field_147481_N = false;
@@ -2016,17 +2565,23 @@ @@ -2016,17 +2568,23 @@
this.addedTileEntityList.clear(); this.addedTileEntityList.clear();
} }
@ -1119,7 +1122,7 @@
} }
public void updateEntity(Entity p_72870_1_) public void updateEntity(Entity p_72870_1_)
@@ -2036,21 +2591,41 @@ @@ -2036,21 +2594,41 @@
public void updateEntityWithOptionalForce(Entity p_72866_1_, boolean p_72866_2_) public void updateEntityWithOptionalForce(Entity p_72866_1_, boolean p_72866_2_)
{ {
@ -1163,7 +1166,7 @@
p_72866_1_.lastTickPosX = p_72866_1_.posX; p_72866_1_.lastTickPosX = p_72866_1_.posX;
p_72866_1_.lastTickPosY = p_72866_1_.posY; p_72866_1_.lastTickPosY = p_72866_1_.posY;
p_72866_1_.lastTickPosZ = p_72866_1_.posZ; p_72866_1_.lastTickPosZ = p_72866_1_.posZ;
@@ -2134,6 +2709,7 @@ @@ -2134,6 +2712,7 @@
p_72866_1_.riddenByEntity = null; p_72866_1_.riddenByEntity = null;
} }
} }
@ -1171,7 +1174,7 @@
} }
} }
@@ -2570,7 +3146,7 @@ @@ -2570,7 +3149,7 @@
return; return;
} }
@ -1180,7 +1183,7 @@
{ {
if (this.field_147481_N) if (this.field_147481_N)
{ {
@@ -2612,6 +3188,9 @@ @@ -2612,6 +3191,9 @@
public void func_147457_a(TileEntity p_147457_1_) public void func_147457_a(TileEntity p_147457_1_)
{ {
@ -1190,7 +1193,7 @@
this.field_147483_b.add(p_147457_1_); this.field_147483_b.add(p_147457_1_);
} }
@@ -2718,7 +3297,15 @@ @@ -2718,7 +3300,15 @@
if (i <= 0) if (i <= 0)
{ {
@ -1207,7 +1210,7 @@
} }
} }
@@ -2754,7 +3341,15 @@ @@ -2754,7 +3344,15 @@
if (j <= 0) if (j <= 0)
{ {
@ -1224,7 +1227,7 @@
} }
} }
@@ -2777,8 +3372,41 @@ @@ -2777,8 +3375,41 @@
protected void setActivePlayerChunksAndCheckLight() protected void setActivePlayerChunksAndCheckLight()
{ {
this.activeChunkSet.clear(); this.activeChunkSet.clear();
@ -1267,7 +1270,7 @@
int i; int i;
EntityPlayer entityplayer; EntityPlayer entityplayer;
int j; int j;
@@ -2788,17 +3416,28 @@ @@ -2788,17 +3419,28 @@
for (i = 0; i < this.playerEntities.size(); ++i) for (i = 0; i < this.playerEntities.size(); ++i)
{ {
entityplayer = (EntityPlayer)this.playerEntities.get(i); entityplayer = (EntityPlayer)this.playerEntities.get(i);
@ -1302,7 +1305,7 @@
} }
this.theProfiler.endSection(); this.theProfiler.endSection();
@@ -2810,7 +3449,7 @@ @@ -2810,7 +3452,7 @@
this.theProfiler.startSection("playerCheckLight"); this.theProfiler.startSection("playerCheckLight");
@ -1311,7 +1314,7 @@
{ {
i = this.rand.nextInt(this.playerEntities.size()); i = this.rand.nextInt(this.playerEntities.size());
entityplayer = (EntityPlayer)this.playerEntities.get(i); entityplayer = (EntityPlayer)this.playerEntities.get(i);
@@ -3034,9 +3673,9 @@ @@ -3034,9 +3676,9 @@
} }
} }
@ -1323,7 +1326,7 @@
{ {
return false; return false;
} }
@@ -3166,6 +3805,16 @@ @@ -3166,6 +3808,16 @@
} }
} }
@ -1340,7 +1343,7 @@
this.theProfiler.endSection(); this.theProfiler.endSection();
return true; return true;
} }
@@ -3284,8 +3933,21 @@ @@ -3284,8 +3936,21 @@
{ {
Entity entity = (Entity)this.loadedEntityList.get(j); Entity entity = (Entity)this.loadedEntityList.get(j);
@ -1363,7 +1366,7 @@
++i; ++i;
} }
} }
@@ -3298,6 +3960,7 @@ @@ -3298,6 +3963,7 @@
for (int i = 0; i < p_72868_1_.size(); ++i) for (int i = 0; i < p_72868_1_.size(); ++i)
{ {
Entity entity = (Entity)p_72868_1_.get(i); Entity entity = (Entity)p_72868_1_.get(i);
@ -1371,7 +1374,7 @@
if (!MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(entity, this))) if (!MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(entity, this)))
{ {
loadedEntityList.add(entity); loadedEntityList.add(entity);
@@ -3314,8 +3977,17 @@ @@ -3314,8 +3980,17 @@
public boolean canPlaceEntityOnSide(Block p_147472_1_, int p_147472_2_, int p_147472_3_, int p_147472_4_, boolean p_147472_5_, int p_147472_6_, Entity p_147472_7_, ItemStack p_147472_8_) public boolean canPlaceEntityOnSide(Block p_147472_1_, int p_147472_2_, int p_147472_3_, int p_147472_4_, boolean p_147472_5_, int p_147472_6_, Entity p_147472_7_, ItemStack p_147472_8_)
{ {
Block block1 = this.getBlock(p_147472_2_, p_147472_3_, p_147472_4_); Block block1 = this.getBlock(p_147472_2_, p_147472_3_, p_147472_4_);
@ -1390,7 +1393,7 @@
} }
public PathEntity getPathEntityToEntity(Entity p_72865_1_, Entity p_72865_2_, float p_72865_3_, boolean p_72865_4_, boolean p_72865_5_, boolean p_72865_6_, boolean p_72865_7_) public PathEntity getPathEntityToEntity(Entity p_72865_1_, Entity p_72865_2_, float p_72865_3_, boolean p_72865_4_, boolean p_72865_5_, boolean p_72865_6_, boolean p_72865_7_)
@@ -3464,6 +4136,12 @@ @@ -3464,6 +4139,12 @@
for (int i = 0; i < this.playerEntities.size(); ++i) for (int i = 0; i < this.playerEntities.size(); ++i)
{ {
EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i); EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i);
@ -1403,7 +1406,7 @@
double d5 = entityplayer1.getDistanceSq(p_72977_1_, p_72977_3_, p_72977_5_); double d5 = entityplayer1.getDistanceSq(p_72977_1_, p_72977_3_, p_72977_5_);
if ((p_72977_7_ < 0.0D || d5 < p_72977_7_ * p_72977_7_) && (d4 == -1.0D || d5 < d4)) if ((p_72977_7_ < 0.0D || d5 < p_72977_7_ * p_72977_7_) && (d4 == -1.0D || d5 < d4))
@@ -3489,7 +4167,12 @@ @@ -3489,7 +4170,12 @@
for (int i = 0; i < this.playerEntities.size(); ++i) for (int i = 0; i < this.playerEntities.size(); ++i)
{ {
EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i); EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i);
@ -1417,7 +1420,7 @@
if (!entityplayer1.capabilities.disableDamage && entityplayer1.isEntityAlive()) if (!entityplayer1.capabilities.disableDamage && entityplayer1.isEntityAlive())
{ {
double d5 = entityplayer1.getDistanceSq(p_72846_1_, p_72846_3_, p_72846_5_); double d5 = entityplayer1.getDistanceSq(p_72846_1_, p_72846_3_, p_72846_5_);
@@ -3660,6 +4343,18 @@ @@ -3660,6 +4346,18 @@
public void updateAllPlayersSleepingFlag() {} public void updateAllPlayersSleepingFlag() {}
@ -1436,7 +1439,7 @@
public float getWeightedThunderStrength(float p_72819_1_) public float getWeightedThunderStrength(float p_72819_1_)
{ {
return (this.prevThunderingStrength + (this.thunderingStrength - this.prevThunderingStrength) * p_72819_1_) * this.getRainStrength(p_72819_1_); return (this.prevThunderingStrength + (this.thunderingStrength - this.prevThunderingStrength) * p_72819_1_) * this.getRainStrength(p_72819_1_);
@@ -3932,8 +4627,8 @@ @@ -3932,8 +4630,8 @@
*/ */
public void addTileEntity(TileEntity entity) public void addTileEntity(TileEntity entity)
{ {
@ -1447,7 +1450,7 @@
{ {
dest.add(entity); dest.add(entity);
} }
@@ -4029,4 +4724,122 @@ @@ -4029,4 +4727,122 @@
} }
return count; return count;
} }

View File

@ -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 kcauldron.ChunkManager chunkManager = new kcauldron.ChunkManager(); +
+ 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 = new kcauldron.wrapper.VanillaChunkHashMap(chunkManager); // KCauldron - vanilla/mystcraft compatibility + public LongHashMap loadedChunkHashMap = new LongHashMap();
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_)
@ -80,12 +80,8 @@
this.defaultEmptyChunk = new EmptyChunk(p_i1520_1_, 0, 0); this.defaultEmptyChunk = new EmptyChunk(p_i1520_1_, 0, 0);
this.worldObj = p_i1520_1_; this.worldObj = p_i1520_1_;
this.currentChunkLoader = p_i1520_2_; this.currentChunkLoader = p_i1520_2_;
@@ -57,16 +94,22 @@ @@ -60,13 +97,19 @@
return this.loadedChunkHashMap.containsItem(ChunkCoordIntPair.chunkXZ2Int(p_73149_1_, 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.chunkManager.chunkExists(p_73149_1_, p_73149_2_); // KCauldron
} }
- public List func_152380_a() - public List func_152380_a()
@ -97,7 +93,7 @@
public void unloadChunksIfNotNearSpawn(int p_73241_1_, int p_73241_2_) public void unloadChunksIfNotNearSpawn(int p_73241_1_, int p_73241_2_)
{ {
+ // PaperSpigot start - Asynchronous lighting updates + // 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)) { + if (chunk != null && chunk.worldObj.spigotConfig.useAsyncLighting && (chunk.pendingLightUpdates.get() > 0 || chunk.worldObj.getTotalWorldTime() - chunk.lightUpdateTime < 20)) {
+ return; + return;
+ } + }
@ -105,7 +101,7 @@
if (this.worldObj.provider.canRespawnHere() && DimensionManager.shouldLoadSpawn(this.worldObj.provider.dimensionId)) if (this.worldObj.provider.canRespawnHere() && DimensionManager.shouldLoadSpawn(this.worldObj.provider.dimensionId))
{ {
ChunkCoordinates chunkcoordinates = this.worldObj.getSpawnPoint(); ChunkCoordinates chunkcoordinates = this.worldObj.getSpawnPoint();
@@ -74,26 +117,52 @@ @@ -74,14 +117,33 @@
int l = p_73241_2_ * 16 + 8 - chunkcoordinates.posZ; int l = p_73241_2_ * 16 + 8 - chunkcoordinates.posZ;
short short1 = 128; short short1 = 128;
@ -141,32 +137,18 @@
} }
} }
public void unloadAllChunks() @@ -96,6 +158,10 @@
{ }
- 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
} }
+ 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_) 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) public Chunk loadChunk(int par1, int par2, Runnable runnable)
{ {
@ -174,12 +156,12 @@
- 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.chunkManager.getChunk(par1, par2); // KCauldron + Chunk chunk = this.getChunkIfLoaded(par1,par2);
+ boolean newChunk = false; + boolean newChunk = false;
AnvilChunkLoader loader = null; AnvilChunkLoader loader = null;
if (this.currentChunkLoader instanceof AnvilChunkLoader) if (this.currentChunkLoader instanceof AnvilChunkLoader)
@@ -113,6 +182,8 @@ @@ -113,6 +179,8 @@
loader = (AnvilChunkLoader) this.currentChunkLoader; loader = (AnvilChunkLoader) this.currentChunkLoader;
} }
@ -188,7 +170,7 @@
// We can only use the queue for already generated chunks // We can only use the queue for already generated chunks
if (chunk == null && loader != null && loader.chunkExists(this.worldObj, par1, par2)) if (chunk == null && loader != null && loader.chunkExists(this.worldObj, par1, par2))
{ {
@@ -128,6 +199,12 @@ @@ -128,6 +196,12 @@
} }
else if (chunk == null) else if (chunk == null)
{ {
@ -201,7 +183,7 @@
chunk = this.originalLoadChunk(par1, par2); chunk = this.originalLoadChunk(par1, par2);
} }
@@ -142,18 +219,20 @@ @@ -142,18 +216,20 @@
public Chunk originalLoadChunk(int p_73158_1_, int p_73158_2_) public Chunk originalLoadChunk(int p_73158_1_, int p_73158_2_)
{ {
@ -210,7 +192,7 @@
- Chunk chunk = (Chunk)this.loadedChunkHashMap.getValueByKey(k); - Chunk chunk = (Chunk)this.loadedChunkHashMap.getValueByKey(k);
+ generatorLock.lock(); try { // KCauldron + generatorLock.lock(); try { // KCauldron
+ this.chunksToUnload.remove(p_73158_1_, p_73158_2_); + 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 + boolean newChunk = false; // CraftBukkit
if (chunk == null) if (chunk == null)
@ -227,7 +209,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,30 +255,84 @@ @@ -176,30 +252,84 @@
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_)}));
@ -245,7 +227,7 @@
- this.loadedChunks.add(chunk); - this.loadedChunks.add(chunk);
- loadingChunks.remove(k); - loadingChunks.remove(k);
- chunk.onChunkLoad(); - 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 + this.loadedChunks.add(chunk); // Cauldron - vanilla 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
+ +
@ -294,7 +276,7 @@
- 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 = 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) + 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)
@ -320,7 +302,7 @@
{ {
if (this.currentChunkLoader == null) if (this.currentChunkLoader == null)
{ {
@@ -209,6 +342,7 @@ @@ -209,6 +339,7 @@
{ {
try try
{ {
@ -328,7 +310,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 +351,11 @@ @@ -217,8 +348,11 @@
if (this.currentChunkProvider != null) if (this.currentChunkProvider != null)
{ {
@ -340,7 +322,7 @@
} }
return chunk; return chunk;
@@ -231,7 +368,7 @@ @@ -231,7 +365,7 @@
} }
} }
@ -349,7 +331,7 @@
{ {
if (this.currentChunkLoader != null) if (this.currentChunkLoader != null)
{ {
@@ -246,7 +383,7 @@ @@ -246,7 +380,7 @@
} }
} }
@ -358,7 +340,7 @@
{ {
if (this.currentChunkLoader != null) if (this.currentChunkLoader != null)
{ {
@@ -254,15 +391,18 @@ @@ -254,15 +388,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_);
@ -378,7 +360,7 @@
} }
} }
@@ -277,6 +417,35 @@ @@ -277,6 +414,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_);
@ -414,7 +396,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 +455,13 @@ @@ -286,11 +452,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;
@ -431,7 +413,7 @@
if (p_73151_1_) if (p_73151_1_)
{ {
@@ -325,36 +496,73 @@ @@ -325,36 +493,73 @@
{ {
if (!this.worldObj.levelSaving) if (!this.worldObj.levelSaving)
{ {
@ -454,7 +436,7 @@
{ {
- if (!this.chunksToUnload.isEmpty()) - if (!this.chunksToUnload.isEmpty())
+ long chunkcoordinates = this.chunksToUnload.popFirst(); + 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) + if (chunk == null)
{ {
@ -509,10 +491,10 @@
- -
- this.chunksToUnload.remove(olong); - this.chunksToUnload.remove(olong);
- this.loadedChunkHashMap.remove(olong.longValue()); - 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 + this.loadedChunks.remove(chunk); // Cauldron - vanilla compatibility
+ ForgeChunkManager.putDormantChunk(chunkcoordinates, chunk); + 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); + DimensionManager.unloadWorld(this.worldObj.provider.dimensionId);
+ return currentChunkProvider.unloadQueuedChunks(); + return currentChunkProvider.unloadQueuedChunks();
+ } + }
@ -524,21 +506,16 @@
if (this.currentChunkLoader != null) if (this.currentChunkLoader != null)
{ {
this.currentChunkLoader.chunkTick(); this.currentChunkLoader.chunkTick();
@@ -371,7 +579,7 @@ @@ -371,7 +576,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.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_) public List getPossibleCreatures(EnumCreatureType p_73155_1_, int p_73155_2_, int p_73155_3_, int p_73155_4_)
@@ -386,8 +594,53 @@ @@ -390,4 +595,49 @@
public int getLoadedChunkCount()
{
- return this.loadedChunkHashMap.getNumHashElements();
+ return this.chunkManager.size(); // KCauldron
} }
public void recreateStructures(int p_82695_1_, int p_82695_2_) {} public void recreateStructures(int p_82695_1_, int p_82695_2_) {}
@ -554,7 +531,7 @@
+ +
+ public long lastAccessed(int x, int z) + 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 + return chunk == null ? 0 : chunk.lastAccessedTick; // KCauldron
+ } + }
+ +

View File

@ -17,7 +17,7 @@
MinecraftForge.EVENT_BUS.post(new ChunkDataEvent.Load(chunk, queuedChunk.compound)); // Don't call ChunkDataEvent.Load async MinecraftForge.EVENT_BUS.post(new ChunkDataEvent.Load(chunk, queuedChunk.compound)); // Don't call ChunkDataEvent.Load async
chunk.lastSaveTime = queuedChunk.provider.worldObj.getTotalWorldTime(); chunk.lastSaveTime = queuedChunk.provider.worldObj.getTotalWorldTime();
- queuedChunk.provider.loadedChunkHashMap.add(ChunkCoordIntPair.chunkXZ2Int(queuedChunk.x, queuedChunk.z), chunk); - queuedChunk.provider.loadedChunkHashMap.add(ChunkCoordIntPair.chunkXZ2Int(queuedChunk.x, queuedChunk.z), chunk);
+ queuedChunk.provider.chunkManager.putChunk(chunk, queuedChunk.x, queuedChunk.z); // KCauldron + queuedChunk.provider.loadedChunkHashMap.add(ChunkCoordIntPair.chunkXZ2Int(queuedChunk.x, queuedChunk.z),chunk);
queuedChunk.provider.loadedChunks.add(chunk); queuedChunk.provider.loadedChunks.add(chunk);
chunk.onChunkLoad(); chunk.onChunkLoad();

View File

@ -24,8 +24,6 @@ import net.minecraftforge.event.world.BlockEvent.PlaceEvent;
public class CaptureBlock extends ACapture{ public class CaptureBlock extends ACapture{
/** 是否为还原模式 */
public boolean mRestoring=false;
/** 当前物品 */ /** 当前物品 */
public ItemStack mUseItem=null; public ItemStack mUseItem=null;
/** 当前物品所在的快捷栏位置,如果为-1表示不存在,或者不是从背包取出的物品 */ /** 当前物品所在的快捷栏位置,如果为-1表示不存在,或者不是从背包取出的物品 */
@ -117,10 +115,10 @@ public class CaptureBlock extends ACapture{
} }
if(!this.mCapturedBlocks.isEmpty()){ if(!this.mCapturedBlocks.isEmpty()){
for(int i=this.mCapturedBlocks.size();i>0;){ for(int i=this.mCapturedBlocks.size();i>0;){
this.mRestoring=true; this.mWorld.restoringBlockSnapshots=true;
BlockSnapshot tSnapshot=this.mCapturedBlocks.get(--i); BlockSnapshot tSnapshot=this.mCapturedBlocks.get(--i);
tSnapshot.restore(true,false); tSnapshot.restore(true,false);
this.mRestoring=false; this.mWorld.restoringBlockSnapshots=false;
} }
} }
for(EntitySnapshot sSnapshot : this.mCapturedEntitys){ for(EntitySnapshot sSnapshot : this.mCapturedEntitys){

View File

@ -353,7 +353,7 @@ public class CauldronHooks
writer.name("name").value(world.getWorld().getName()); writer.name("name").value(world.getWorld().getName());
writer.name("dimensionId").value(world.provider.dimensionId); writer.name("dimensionId").value(world.provider.dimensionId);
writer.name("players").value(world.playerEntities.size()); writer.name("players").value(world.playerEntities.size());
writer.name("loadedChunks").value(world.theChunkProviderServer.chunkManager.size()); writer.name("loadedChunks").value(world.theChunkProviderServer.getLoadedChunkCount());
writer.name("activeChunks").value(world.activeChunkSet.size()); writer.name("activeChunks").value(world.activeChunkSet.size());
writer.name("entities").value(world.loadedEntityList.size()); writer.name("entities").value(world.loadedEntityList.size());
writer.name("tiles").value(world.loadedTileEntityList.size()); writer.name("tiles").value(world.loadedTileEntityList.size());

View File

@ -110,7 +110,7 @@ public class CauldronCommand extends Command
for (net.minecraft.world.WorldServer world : MinecraftServer.getServer().worlds) for (net.minecraft.world.WorldServer world : MinecraftServer.getServer().worlds)
{ {
sender.sendMessage(ChatColor.GOLD + "Dimension: " + ChatColor.GRAY + world.provider.dimensionId + sender.sendMessage(ChatColor.GOLD + "Dimension: " + ChatColor.GRAY + world.provider.dimensionId +
ChatColor.GOLD + " Loaded Chunks: " + ChatColor.GRAY + world.theChunkProviderServer.chunkManager.size() + ChatColor.GOLD + " Loaded Chunks: " + ChatColor.GRAY + world.theChunkProviderServer.getLoadedChunkCount() +
ChatColor.GOLD + " Active Chunks: " + ChatColor.GRAY + world.activeChunkSet.size() + ChatColor.GOLD + " Active Chunks: " + ChatColor.GRAY + world.activeChunkSet.size() +
ChatColor.GOLD + " Entities: " + ChatColor.GRAY + world.loadedEntityList.size() + ChatColor.GOLD + " Entities: " + ChatColor.GRAY + world.loadedEntityList.size() +
ChatColor.GOLD + " Tile Entities: " + ChatColor.GRAY + world.loadedTileEntityList.size() ChatColor.GOLD + " Tile Entities: " + ChatColor.GRAY + world.loadedTileEntityList.size()

View File

@ -46,6 +46,7 @@ public class CauldronConfig extends ConfigBase
public final IntSetting largeBoundingBoxLogSize = new IntSetting(this, "settings.entity-bounding-box-max-size", 1000, "Max size of an entity's bounding box before removing it (either being too large or bugged and 'moving' too fast)"); public final IntSetting largeBoundingBoxLogSize = new IntSetting(this, "settings.entity-bounding-box-max-size", 1000, "Max size of an entity's bounding box before removing it (either being too large or bugged and 'moving' too fast)");
public final IntSetting entityMaxSpeed = new IntSetting(this, "settings.entity-max-speed", 100, "Square of the max speed of an entity before removing it"); public final IntSetting entityMaxSpeed = new IntSetting(this, "settings.entity-max-speed", 100, "Square of the max speed of an entity before removing it");
public final BoolSetting removeErroringBlocks=new BoolSetting(this,"setting.remove-erroring-blocks",true,"Set this to true to remove any Blocks that throws an error in its update method instead of closing the server and reporting a crash log."); public final BoolSetting removeErroringBlocks=new BoolSetting(this,"setting.remove-erroring-blocks",true,"Set this to true to remove any Blocks that throws an error in its update method instead of closing the server and reporting a crash log.");
public final BoolSetting tickTEOnlyChunkActive=new BoolSetting(this,"setting.tick-tileentity-only-chunk-active",false,"Set this to true,only if the chunk is active, tileentity can be tick.");
// Debug settings // Debug settings
public final BoolSetting enableThreadContentionMonitoring = new BoolSetting(this, "debug.thread-contention-monitoring", false, "Set true to enable Java's thread contention monitoring for thread dumps"); public final BoolSetting enableThreadContentionMonitoring = new BoolSetting(this, "debug.thread-contention-monitoring", false, "Set true to enable Java's thread contention monitoring for thread dumps");
@ -108,6 +109,10 @@ public class CauldronConfig extends ConfigBase
settings.put(modPacketPlace.path,modPacketPlace); settings.put(modPacketPlace.path,modPacketPlace);
settings.put(modPacketInteract.path,modPacketInteract); settings.put(modPacketInteract.path,modPacketInteract);
settings.put(removeErroringBlocks.path,removeErroringBlocks);
settings.put(tickTEOnlyChunkActive.path,tickTEOnlyChunkActive);
load(); load();
} }

View File

@ -112,6 +112,7 @@ import cc.capture.type.CaptureTree;
import cpw.mods.fml.common.registry.EntityRegistry; // Cauldron import cpw.mods.fml.common.registry.EntityRegistry; // Cauldron
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.IEntityLivingData; import net.minecraft.entity.IEntityLivingData;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraftforge.common.util.BlockSnapshot; import net.minecraftforge.common.util.BlockSnapshot;
public class CraftWorld implements World { public class CraftWorld implements World {
@ -194,18 +195,12 @@ public class CraftWorld implements World {
} }
public Chunk[] getLoadedChunks() { public Chunk[] getLoadedChunks() {
// KCauldron start List tLoadedChunk = world.theChunkProviderServer.loadedChunks;
final kcauldron.ChunkManager chunkManager = world.theChunkProviderServer.chunkManager; final org.bukkit.Chunk[] craftChunks = new CraftChunk[tLoadedChunk.size()];
final org.bukkit.Chunk[] craftChunks = new CraftChunk[chunkManager.size()];
chunkManager.forEach(new cern.colt.function.ObjectProcedure() {
int i = 0; int i = 0;
@Override for(Object sObj : tLoadedChunk){
public boolean apply(Object arg) { craftChunks[i++]=((net.minecraft.world.chunk.Chunk) sObj).bukkitChunk;
craftChunks[i++] = ((net.minecraft.world.chunk.Chunk) arg).bukkitChunk;
return true;
} }
});
// KCauldron end
return craftChunks; return craftChunks;
} }
@ -322,7 +317,7 @@ public class CraftWorld implements World {
} }
world.theChunkProviderServer.chunksToUnload.remove(x, z); world.theChunkProviderServer.chunksToUnload.remove(x, z);
net.minecraft.world.chunk.Chunk chunk = world.theChunkProviderServer.chunkManager.getChunk(x, z); net.minecraft.world.chunk.Chunk chunk = world.theChunkProviderServer.getChunkIfLoaded(x,z);
if (chunk == null) { if (chunk == null) {
world.timings.syncChunkLoadTimer.startTiming(); // Spigot world.timings.syncChunkLoadTimer.startTiming(); // Spigot
@ -336,7 +331,7 @@ public class CraftWorld implements World {
private void chunkLoadPostProcess(net.minecraft.world.chunk.Chunk chunk, int x, int z) { private void chunkLoadPostProcess(net.minecraft.world.chunk.Chunk chunk, int x, int z) {
if (chunk != null) { if (chunk != null) {
world.theChunkProviderServer.chunkManager.putChunk(chunk, x, z); // KCauldron world.theChunkProviderServer.loadedChunkHashMap.add(ChunkCoordIntPair.chunkXZ2Int(x, z),chunk);
world.theChunkProviderServer.loadedChunks.add(chunk); // Cauldron - vanilla compatibility world.theChunkProviderServer.loadedChunks.add(chunk); // Cauldron - vanilla compatibility
chunk.onChunkLoad(); chunk.onChunkLoad();
@ -1450,25 +1445,22 @@ public class CraftWorld implements World {
} }
final net.minecraft.world.gen.ChunkProviderServer cps = world.theChunkProviderServer; final net.minecraft.world.gen.ChunkProviderServer cps = world.theChunkProviderServer;
cps.chunkManager.forEach(new cern.colt.function.ObjectProcedure() { List tLoadedChunk = world.theChunkProviderServer.loadedChunks;
@Override for(Object sObj : tLoadedChunk){
public boolean apply(Object arg) { net.minecraft.world.chunk.Chunk chunk = (net.minecraft.world.chunk.Chunk)sObj;
net.minecraft.world.chunk.Chunk chunk = (net.minecraft.world.chunk.Chunk) arg;
// If in use, skip it // If in use, skip it
if (isChunkInUse(chunk.xPosition, chunk.zPosition)) { if (isChunkInUse(chunk.xPosition, chunk.zPosition)) {
return true; continue;
} }
// Already unloading? // Already unloading?
if (cps.chunksToUnload.contains(chunk.xPosition, chunk.zPosition)) { if (cps.chunksToUnload.contains(chunk.xPosition, chunk.zPosition)) {
return true; continue;
} }
// Add unload request // Add unload request
cps.unloadChunksIfNotNearSpawn(chunk.xPosition, chunk.zPosition); cps.unloadChunksIfNotNearSpawn(chunk.xPosition, chunk.zPosition);
return true;
} }
});
} }
// Spigot start // Spigot start

View File

@ -89,7 +89,7 @@ public class WatchdogThread extends Thread
{ {
log.log(Level.SEVERE, " Dimension:" + world.provider.dimensionId); log.log(Level.SEVERE, " Dimension:" + world.provider.dimensionId);
log.log(Level.SEVERE, log.log(Level.SEVERE,
" Loaded Chunks: " + world.theChunkProviderServer.chunkManager.size() + " Active Chunks: " + world.activeChunkSet.size() " Loaded Chunks: " + world.theChunkProviderServer.getLoadedChunkCount() + " Active Chunks: " + world.activeChunkSet.size()
+ " Entities: " + world.loadedEntityList.size() + " Tile Entities: " + world.loadedTileEntityList.size()); + " Entities: " + world.loadedEntityList.size() + " Tile Entities: " + world.loadedTileEntityList.size());
log.log(Level.SEVERE, " Entities Last Tick: " + world.entitiesTicked); log.log(Level.SEVERE, " Entities Last Tick: " + world.entitiesTicked);
log.log(Level.SEVERE, " Tiles Last Tick: " + world.tilesTicked); log.log(Level.SEVERE, " Tiles Last Tick: " + world.tilesTicked);
@ -153,7 +153,7 @@ public class WatchdogThread extends Thread
for (net.minecraft.world.WorldServer world : MinecraftServer.getServer().worlds) for (net.minecraft.world.WorldServer world : MinecraftServer.getServer().worlds)
{ {
log.log(Level.WARNING, " Dimension:" + world.provider.dimensionId); log.log(Level.WARNING, " Dimension:" + world.provider.dimensionId);
log.log(Level.WARNING, " Loaded Chunks: " + world.theChunkProviderServer.chunkManager.size() + log.log(Level.WARNING, " Loaded Chunks: " + world.theChunkProviderServer.getLoadedChunkCount() +
" Active Chunks: " + world.activeChunkSet.size() + " Active Chunks: " + world.activeChunkSet.size() +
" Entities: " + world.loadedEntityList.size() + " Entities: " + world.loadedEntityList.size() +
" Tile Entities: " + world.loadedTileEntityList.size()); " Tile Entities: " + world.loadedTileEntityList.size());