3
0

Optimize chunk saving time by holding block updates in chunks directly (fix #299)

This commit is contained in:
Sergey 2016-01-31 18:53:17 +07:00
parent a5277c151e
commit 201b43272f
3 changed files with 47 additions and 13 deletions

View File

@ -380,7 +380,21 @@
}
public boolean isBlockTickScheduledThisTick(int p_147477_1_, int p_147477_2_, int p_147477_3_, Block p_147477_4_)
@@ -474,7 +654,7 @@
@@ -451,6 +631,7 @@
{
this.pendingTickListEntriesHashSet.add(nextticklistentry);
this.pendingTickListEntriesTreeSet.add(nextticklistentry);
+ getChunkFromBlockCoords(p_147454_1_, p_147454_3_).blockUpdates.add(nextticklistentry); // KCauldron
}
}
}
@@ -469,12 +650,13 @@
{
this.pendingTickListEntriesHashSet.add(nextticklistentry);
this.pendingTickListEntriesTreeSet.add(nextticklistentry);
+ getChunkFromBlockCoords(p_147446_1_, p_147446_3_).blockUpdates.add(nextticklistentry); // KCauldron
}
}
public void updateEntities()
{
@ -389,7 +403,7 @@
{
if (this.updateEntityTick++ >= 1200)
{
@@ -487,6 +667,7 @@
@@ -487,6 +669,7 @@
}
super.updateEntities();
@ -397,7 +411,7 @@
}
public void resetUpdateEntityTick()
@@ -506,7 +687,16 @@
@@ -506,7 +689,16 @@
{
if (i > 1000)
{
@ -415,7 +429,15 @@
}
this.theProfiler.startSection("cleaning");
@@ -651,7 +841,37 @@
@@ -523,6 +715,7 @@
this.pendingTickListEntriesTreeSet.remove(nextticklistentry);
this.pendingTickListEntriesHashSet.remove(nextticklistentry);
+ getChunkFromBlockCoords(nextticklistentry.xCoord, nextticklistentry.zCoord).blockUpdates.remove(nextticklistentry); // KCauldron
this.pendingTickListEntriesThisTick.add(nextticklistentry);
}
@@ -651,7 +844,37 @@
protected IChunkProvider createChunkProvider()
{
IChunkLoader ichunkloader = this.saveHandler.getChunkLoader(this.provider);
@ -454,7 +476,7 @@
return this.theChunkProviderServer;
}
@@ -659,29 +879,31 @@
@@ -659,29 +882,31 @@
{
ArrayList arraylist = new ArrayList();
@ -501,7 +523,7 @@
return arraylist;
}
@@ -733,7 +955,28 @@
@@ -733,7 +958,28 @@
int i = 0;
int j = this.provider.getAverageGroundLevel();
int k = 0;
@ -530,7 +552,7 @@
if (chunkposition != null)
{
i = chunkposition.chunkPosX;
@@ -876,6 +1119,20 @@
@@ -876,6 +1122,20 @@
public boolean addWeatherEffect(Entity p_72942_1_)
{
@ -551,7 +573,7 @@
if (super.addWeatherEffect(p_72942_1_))
{
this.mcServer.getConfigurationManager().sendToAllNear(p_72942_1_.posX, p_72942_1_.posY, p_72942_1_.posZ, 512.0D, this.provider.dimensionId, new S2CPacketSpawnGlobalEntity(p_72942_1_));
@@ -894,13 +1151,23 @@
@@ -894,13 +1154,23 @@
public Explosion newExplosion(Entity p_72885_1_, double p_72885_2_, double p_72885_4_, double p_72885_6_, float p_72885_8_, boolean p_72885_9_, boolean p_72885_10_)
{
@ -576,7 +598,7 @@
if (!p_72885_10_)
{
explosion.affectedBlockPositions.clear();
@@ -977,7 +1244,7 @@
@@ -977,7 +1247,7 @@
{
boolean flag = this.isRaining();
super.updateWeather();
@ -585,7 +607,7 @@
if (this.prevRainingStrength != this.rainingStrength)
{
this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(7, this.rainingStrength), this.provider.dimensionId);
@@ -988,10 +1255,6 @@
@@ -988,10 +1258,6 @@
this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(8, this.thunderingStrength), this.provider.dimensionId);
}
@ -596,7 +618,7 @@
if (flag != this.isRaining())
{
if (flag)
@@ -1006,6 +1269,33 @@
@@ -1006,6 +1272,33 @@
this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(7, this.rainingStrength), this.provider.dimensionId);
this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(8, this.thunderingStrength), this.provider.dimensionId);
}
@ -630,7 +652,7 @@
}
protected int func_152379_p()
@@ -1069,4 +1359,51 @@
@@ -1069,4 +1362,51 @@
this();
}
}

View File

@ -354,7 +354,7 @@
}
}
else if (p_76607_4_ && this.storageArrays[l] != null && this.storageArrays[l].getBlockMSBArray() != null)
@@ -1523,4 +1677,21 @@
@@ -1523,4 +1677,24 @@
}
}
}
@ -375,4 +375,7 @@
+ }
+ });
+ }
+
+ // KCauldron hold block updates into each chunk individually
+ public final java.util.Set<net.minecraft.world.NextTickListEntry> blockUpdates = new java.util.TreeSet<net.minecraft.world.NextTickListEntry>();
}

View File

@ -133,6 +133,15 @@
}
nbttaglist.appendTag(nbttagcompound1);
@@ -379,7 +400,7 @@
}
p_75820_3_.setTag("TileEntities", nbttaglist3);
- List list = p_75820_2_.getPendingBlockUpdates(p_75820_1_, false);
+ Set list = p_75820_1_.blockUpdates;
if (list != null)
{
@@ -455,6 +476,7 @@
public void loadEntities(World p_75823_1_, NBTTagCompound p_75823_2_, Chunk chunk)