Browse Source

Fixed, should build now!

master
Robotia 9 years ago
parent
commit
7362e5ff4e
  1. 53
      patches/net/minecraft/world/WorldServer.java.patch
  2. 90
      patches/net/minecraft/world/gen/ChunkProviderServer.java.patch
  3. 6
      patches/net/minecraftforge/common/chunkio/ChunkIOProvider.java.patch

53
patches/net/minecraft/world/WorldServer.java.patch

@ -1,5 +1,5 @@
--- ../src-base/minecraft/net/minecraft/world/WorldServer.java --- a/../src-base/minecraft/net/minecraft/world/WorldServer.java
+++ ../src-work/minecraft/net/minecraft/world/WorldServer.java +++ b/../src-work/minecraft/net/minecraft/world/WorldServer.java
@@ -1,8 +1,10 @@ @@ -1,8 +1,10 @@
package net.minecraft.world; package net.minecraft.world;
@ -278,10 +278,10 @@
+ if (entityplayer.isPlayerFullyAsleep()) + if (entityplayer.isPlayerFullyAsleep())
+ { + {
+ foundActualSleepers = true; + foundActualSleepers = true;
} + }
}
- while (entityplayer.isPlayerFullyAsleep()); - while (entityplayer.isPlayerFullyAsleep());
- -
+ }
+ while (entityplayer.isPlayerFullyAsleep() || entityplayer.fauxSleeping); + while (entityplayer.isPlayerFullyAsleep() || entityplayer.fauxSleeping);
+ // CraftBukkit end + // CraftBukkit end
return false; return false;
@ -297,17 +297,17 @@
- while (iterator.hasNext()) - while (iterator.hasNext())
+ // Spigot start + // Spigot start
+ for (gnu.trove.iterator.TLongShortIterator iter = activeChunkSet_CB.iterator(); iter.hasNext();) + for (gnu.trove.iterator.TLongShortIterator iter = activeChunkSet_CB.iterator(); iter.hasNext();)
+ { {
- ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair)iterator.next();
- int k = chunkcoordintpair.chunkXPos * 16;
- int l = chunkcoordintpair.chunkZPos * 16;
+ iter.advance(); + iter.advance();
+ long chunkCoord = iter.key(); + long chunkCoord = iter.key();
+ int chunkX = World.keyToX(chunkCoord); + int chunkX = World.keyToX(chunkCoord);
+ int chunkZ = World.keyToZ(chunkCoord); + int chunkZ = World.keyToZ(chunkCoord);
+ // If unloaded, or in process of being unloaded, drop it + // If unloaded, or in process of being unloaded, drop it
+ if ((!this.chunkExists(chunkX, chunkZ)) || (this.theChunkProviderServer.chunksToUnload.contains(chunkX, chunkZ))) + if ((!this.chunkExists(chunkX, chunkZ)) || (this.theChunkProviderServer.chunksToUnload.contains(chunkX, chunkZ)))
{ + {
- ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair)iterator.next();
- int k = chunkcoordintpair.chunkXPos * 16;
- int l = chunkcoordintpair.chunkZPos * 16;
+ activeChunkSet.remove(new ChunkCoordIntPair(chunkX, chunkZ)); // Cauldron - vanilla compatibility + activeChunkSet.remove(new ChunkCoordIntPair(chunkX, chunkZ)); // Cauldron - vanilla compatibility
+ iter.remove(); + iter.remove();
+ continue; + continue;
@ -406,10 +406,11 @@
{ {
throw new IllegalStateException("TickNextTick list out of synch"); throw new IllegalStateException("TickNextTick list out of synch");
} }
@@ -506,8 +687,17 @@ @@ -506,7 +687,16 @@
{ {
if (i > 1000) if (i > 1000)
{ {
- i = 1000;
+ // CraftBukkit start - If the server has too much to process over time, try to alleviate that + // CraftBukkit start - If the server has too much to process over time, try to alleviate that
+ if (i > 20 * 1000) + if (i > 20 * 1000)
+ { + {
@ -417,17 +418,17 @@
+ } + }
+ else + else
+ { + {
i = 1000; + i = 1000;
} + }
+ // CraftBukkit end + // CraftBukkit end
+ } }
this.theProfiler.startSection("cleaning"); this.theProfiler.startSection("cleaning");
NextTickListEntry nextticklistentry;
@@ -651,7 +841,37 @@ @@ -651,7 +841,37 @@
protected IChunkProvider createChunkProvider() protected IChunkProvider createChunkProvider()
{ {
IChunkLoader ichunkloader = this.saveHandler.getChunkLoader(this.provider); IChunkLoader ichunkloader = this.saveHandler.getChunkLoader(this.provider);
- this.theChunkProviderServer = new ChunkProviderServer(this, ichunkloader, this.provider.createChunkGenerator());
+ // Cauldron start - if provider is vanilla, proceed to create a bukkit compatible chunk generator + // Cauldron start - if provider is vanilla, proceed to create a bukkit compatible chunk generator
+ if (this.provider.getClass().toString().length() <= 3 || this.provider.getClass().toString().contains("net.minecraft")) + if (this.provider.getClass().toString().length() <= 3 || this.provider.getClass().toString().contains("net.minecraft"))
+ { + {
@ -456,7 +457,7 @@
+ else + else
+ // custom provider, load normally for forge compatibility + // custom provider, load normally for forge compatibility
+ { + {
this.theChunkProviderServer = new ChunkProviderServer(this, ichunkloader, this.provider.createChunkGenerator()); + this.theChunkProviderServer = new ChunkProviderServer(this, ichunkloader, this.provider.createChunkGenerator());
+ } + }
+ // Cauldron end + // Cauldron end
return this.theChunkProviderServer; return this.theChunkProviderServer;
@ -475,34 +476,35 @@
{ {
- Chunk chunk = getChunkFromChunkCoords(x, z); - Chunk chunk = getChunkFromChunkCoords(x, z);
- if (chunk != null) - if (chunk != null)
- {
- for(Object obj : chunk.chunkTileEntityMap.values())
+ Chunk chunk = getChunkFromChunkCoords(chunkX, chunkZ); + Chunk chunk = getChunkFromChunkCoords(chunkX, chunkZ);
+ +
+ if (chunk == null) + if (chunk == null)
{ {
- TileEntity entity = (TileEntity)obj; - for(Object obj : chunk.chunkTileEntityMap.values())
- if (!entity.isInvalid())
+ continue; + continue;
+ } + }
+ +
+ for (Object te : chunk.chunkTileEntityMap.values()) + for (Object te : chunk.chunkTileEntityMap.values())
{ + {
- if (entity.xCoord >= p_147486_1_ && entity.yCoord >= p_147486_2_ && entity.zCoord >= p_147486_3_ &&
- entity.xCoord <= p_147486_4_ && entity.yCoord <= p_147486_5_ && entity.zCoord <= p_147486_6_)
+ TileEntity tileentity = (TileEntity) te; + TileEntity tileentity = (TileEntity) te;
+ +
+ if ((tileentity.xCoord >= p_147486_1_) && (tileentity.yCoord >= p_147486_2_) && (tileentity.zCoord >= p_147486_3_) + if ((tileentity.xCoord >= p_147486_1_) && (tileentity.yCoord >= p_147486_2_) && (tileentity.zCoord >= p_147486_3_)
+ && (tileentity.xCoord < p_147486_4_) && (tileentity.yCoord < p_147486_5_) && (tileentity.zCoord < p_147486_6_)) + && (tileentity.xCoord < p_147486_4_) && (tileentity.yCoord < p_147486_5_) && (tileentity.zCoord < p_147486_6_))
{ {
- TileEntity entity = (TileEntity)obj;
- if (!entity.isInvalid())
- {
- if (entity.xCoord >= p_147486_1_ && entity.yCoord >= p_147486_2_ && entity.zCoord >= p_147486_3_ &&
- entity.xCoord <= p_147486_4_ && entity.yCoord <= p_147486_5_ && entity.zCoord <= p_147486_6_)
- {
- arraylist.add(entity); - arraylist.add(entity);
- }
- }
+ arraylist.add(tileentity); + arraylist.add(tileentity);
} }
} }
} }
} }
- }
- }
- -
+ // CraftBukkit end + // CraftBukkit end
return arraylist; return arraylist;
@ -641,6 +643,7 @@
this(); this();
} }
} }
-}
+ +
+ // CraftBukkit start - Compatibility methods for BlockChangeDelegate + // CraftBukkit start - Compatibility methods for BlockChangeDelegate
+ public boolean setRawTypeId(int x, int y, int z, int typeId) + public boolean setRawTypeId(int x, int y, int z, int typeId)
@ -688,4 +691,4 @@
+ return this.getBlock(x, y, z); + return this.getBlock(x, y, z);
+ } + }
+ // CraftBukkit end + // CraftBukkit end
} +}

90
patches/net/minecraft/world/gen/ChunkProviderServer.java.patch

@ -1,5 +1,5 @@
--- ../src-base/minecraft/net/minecraft/world/gen/ChunkProviderServer.java --- a/../src-base/minecraft/net/minecraft/world/gen/ChunkProviderServer.java
+++ ../src-work/minecraft/net/minecraft/world/gen/ChunkProviderServer.java +++ b/../src-work/minecraft/net/minecraft/world/gen/ChunkProviderServer.java
@@ -1,7 +1,13 @@ @@ -1,7 +1,13 @@
package net.minecraft.world.gen; package net.minecraft.world.gen;
@ -121,9 +121,9 @@
+ if (c != null) + if (c != null)
+ { + {
+ c.mustSave = true; + c.mustSave = true;
} + }
+ CauldronHooks.logChunkUnload(this, p_73241_1_, p_73241_2_, "Chunk added to unload queue"); + CauldronHooks.logChunkUnload(this, p_73241_1_, p_73241_2_, "Chunk added to unload queue");
+ } }
+ +
+ // CraftBukkit end + // CraftBukkit end
} }
@ -163,11 +163,9 @@
+ if(chunk == null || !chunk.isChunkLoaded) + if(chunk == null || !chunk.isChunkLoaded)
+ { + {
+ if(chunk != null) + if(chunk != null)
{ + {
- Chunk chunk = (Chunk)iterator.next();
- this.unloadChunksIfNotNearSpawn(chunk.xPosition, chunk.zPosition);
+ cachet_KC.remove(hash); + cachet_KC.remove(hash);
} + }
+ chunk = (Chunk) chunk_get(x, z); + chunk = (Chunk) chunk_get(x, z);
+ if(chunk != null) + if(chunk != null)
+ { + {
@ -175,9 +173,11 @@
+ } + }
+ } + }
+ if(cachet_KC.size() > 500) + if(cachet_KC.size() > 500)
+ { {
- Chunk chunk = (Chunk)iterator.next();
- this.unloadChunksIfNotNearSpawn(chunk.xPosition, chunk.zPosition);
+ cachet_KC.clear(); + cachet_KC.clear();
+ } }
+ return chunk; + return chunk;
} }
@ -246,6 +246,7 @@
- this.loadedChunkHashMap.add(k, chunk); - this.loadedChunkHashMap.add(k, chunk);
- this.loadedChunks.add(chunk); - this.loadedChunks.add(chunk);
- loadingChunks.remove(k); - loadingChunks.remove(k);
- chunk.onChunkLoad();
+ this.loadedChunkHashMap_KC.put(LongHash.toLong(p_73158_1_, p_73158_2_), chunk); + this.loadedChunkHashMap_KC.put(LongHash.toLong(p_73158_1_, p_73158_2_), chunk);
+ Chunk[][] temp_chunk_bunch = chunk_array_get(p_73158_1_, p_73158_2_); + Chunk[][] temp_chunk_bunch = chunk_array_get(p_73158_1_, p_73158_2_);
+ if(temp_chunk_bunch != null) + if(temp_chunk_bunch != null)
@ -263,7 +264,7 @@
+ +
+ if (chunk != null) + if (chunk != null)
+ { + {
chunk.onChunkLoad(); + chunk.onChunkLoad();
+ } + }
+ // CraftBukkit start + // CraftBukkit start
+ Server server = this.worldObj.getServer(); + Server server = this.worldObj.getServer();
@ -330,9 +331,8 @@
+ if (chunk == this.defaultEmptyChunk) + if (chunk == this.defaultEmptyChunk)
+ { + {
+ return chunk; + return chunk;
} + }
+
- private Chunk safeLoadChunk(int p_73239_1_, int p_73239_2_)
+ if ((p_73154_1_ != chunk.xPosition || p_73154_2_ != chunk.zPosition) && !worldObj.isProfilingWorld()) + if ((p_73154_1_ != chunk.xPosition || p_73154_2_ != chunk.zPosition) && !worldObj.isProfilingWorld())
+ { + {
+ logger.error("Chunk (" + chunk.xPosition + ", " + chunk.zPosition + ") stored at (" + p_73154_1_ + ", " + p_73154_2_ + ") in world '" + worldObj.getWorld().getName() + "'"); + logger.error("Chunk (" + chunk.xPosition + ", " + chunk.zPosition + ") stored at (" + p_73154_1_ + ", " + p_73154_2_ + ") in world '" + worldObj.getWorld().getName() + "'");
@ -344,8 +344,9 @@
+ chunk.lastAccessedTick = MinecraftServer.getServer().getTickCounter(); // Cauldron + chunk.lastAccessedTick = MinecraftServer.getServer().getTickCounter(); // Cauldron
+ return chunk; + return chunk;
+ // CraftBukkit end + // CraftBukkit end
+ } }
+
- private Chunk safeLoadChunk(int p_73239_1_, int p_73239_2_)
+ public Chunk safeLoadChunk(int p_73239_1_, int p_73239_2_) // CraftBukkit - private -> public + public Chunk safeLoadChunk(int p_73239_1_, int p_73239_2_) // CraftBukkit - private -> public
{ {
if (this.currentChunkLoader == null) if (this.currentChunkLoader == null)
@ -468,10 +469,10 @@
- for (ChunkCoordIntPair forced : this.worldObj.getPersistentChunks().keySet()) - for (ChunkCoordIntPair forced : this.worldObj.getPersistentChunks().keySet())
+ // Cauldron start - remove any chunk that has a ticket associated with it + // Cauldron start - remove any chunk that has a ticket associated with it
+ if (!this.chunksToUnload.isEmpty()) + if (!this.chunksToUnload.isEmpty())
+ { {
+ for (ChunkCoordIntPair forcedChunk : this.worldObj.getPersistentChunks().keys())
{
- this.chunksToUnload.remove(ChunkCoordIntPair.chunkXZ2Int(forced.chunkXPos, forced.chunkZPos)); - this.chunksToUnload.remove(ChunkCoordIntPair.chunkXZ2Int(forced.chunkXPos, forced.chunkZPos));
+ for (ChunkCoordIntPair forcedChunk : this.worldObj.getPersistentChunks().keys())
+ {
+ this.chunksToUnload.remove(forcedChunk.chunkXPos, forcedChunk.chunkZPos); + this.chunksToUnload.remove(forcedChunk.chunkXPos, forcedChunk.chunkZPos);
+ } + }
} }
@ -487,21 +488,30 @@
+ Chunk chunk = this.loadedChunkHashMap_KC.get(chunkcoordinates); //Not using the IntMap for this + Chunk chunk = this.loadedChunkHashMap_KC.get(chunkcoordinates); //Not using the IntMap for this
+ +
+ if (chunk == null) + if (chunk == null)
{ + {
- Long olong = (Long)this.chunksToUnload.iterator().next();
- Chunk chunk = (Chunk)this.loadedChunkHashMap.getValueByKey(olong.longValue());
+ continue; + continue;
+ } + }
+
- if (chunk != null)
+ // Cauldron static - check if the chunk was accessed recently and keep it loaded if there are players in world + // Cauldron static - check if the chunk was accessed recently and keep it loaded if there are players in world
+ if (!shouldUnloadChunk(chunk) && this.worldObj.playerEntities.size() > 0) + if (!shouldUnloadChunk(chunk) && this.worldObj.playerEntities.size() > 0)
{ {
- Long olong = (Long)this.chunksToUnload.iterator().next();
- Chunk chunk = (Chunk)this.loadedChunkHashMap.getValueByKey(olong.longValue());
+ CauldronHooks.logChunkUnload(this, chunk.xPosition, chunk.zPosition, "** Chunk kept from unloading due to recent activity"); + CauldronHooks.logChunkUnload(this, chunk.xPosition, chunk.zPosition, "** Chunk kept from unloading due to recent activity");
+ continue; + continue;
+ } + }
+ // Cauldron end + // Cauldron end
+
- if (chunk != null)
- {
- chunk.onChunkUnload();
- this.safeSaveChunk(chunk);
- this.safeSaveExtraChunkData(chunk);
- this.loadedChunks.remove(chunk);
- ForgeChunkManager.putDormantChunk(ChunkCoordIntPair.chunkXZ2Int(chunk.xPosition, chunk.zPosition), chunk);
- if(loadedChunks.size() == 0 && ForgeChunkManager.getPersistentChunksFor(this.worldObj).size() == 0 && !DimensionManager.shouldLoadSpawn(this.worldObj.provider.dimensionId)){
- DimensionManager.unloadWorld(this.worldObj.provider.dimensionId);
- return currentChunkProvider.unloadQueuedChunks();
+ +
+ ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk); + ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk);
+ server.getPluginManager().callEvent(event); + server.getPluginManager().callEvent(event);
@ -510,9 +520,9 @@
+ { + {
+ CauldronHooks.logChunkUnload(this, chunk.xPosition, chunk.zPosition, "Unloading Chunk at"); + CauldronHooks.logChunkUnload(this, chunk.xPosition, chunk.zPosition, "Unloading Chunk at");
+ +
chunk.onChunkUnload(); + chunk.onChunkUnload();
this.safeSaveChunk(chunk); + this.safeSaveChunk(chunk);
this.safeSaveExtraChunkData(chunk); + this.safeSaveExtraChunkData(chunk);
+ // Update neighbor counts + // Update neighbor counts
+ for (int x = -2; x < 3; x++) { + for (int x = -2; x < 3; x++) {
+ for (int z = -2; z < 3; z++) { + for (int z = -2; z < 3; z++) {
@ -525,12 +535,13 @@
+ neighbor.setNeighborUnloaded(-x, -z); + neighbor.setNeighborUnloaded(-x, -z);
+ chunk.setNeighborUnloaded(x, z); + chunk.setNeighborUnloaded(x, z);
+ } + }
+ } }
+ } }
-
- this.chunksToUnload.remove(olong);
- this.loadedChunkHashMap.remove(olong.longValue());
+ this.loadedChunkHashMap_KC.remove(chunkcoordinates); // CraftBukkit + this.loadedChunkHashMap_KC.remove(chunkcoordinates); // CraftBukkit
this.loadedChunks.remove(chunk); + this.loadedChunks.remove(chunk);
- ForgeChunkManager.putDormantChunk(ChunkCoordIntPair.chunkXZ2Int(chunk.xPosition, chunk.zPosition), chunk);
- if(loadedChunks.size() == 0 && ForgeChunkManager.getPersistentChunksFor(this.worldObj).size() == 0 && !DimensionManager.shouldLoadSpawn(this.worldObj.provider.dimensionId)){
+ Chunk[][] temp_bunch_array = chunk_array_get(chunk.xPosition, chunk.zPosition); + Chunk[][] temp_bunch_array = chunk_array_get(chunk.xPosition, chunk.zPosition);
+ if(temp_bunch_array != null) + if(temp_bunch_array != null)
+ { + {
@ -542,14 +553,10 @@
+ } + }
+ ForgeChunkManager.putDormantChunk(chunkcoordinates, chunk); + ForgeChunkManager.putDormantChunk(chunkcoordinates, chunk);
+ if(this.loadedChunkHashMap_KC.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();
} + }
} }
-
- this.chunksToUnload.remove(olong);
- this.loadedChunkHashMap.remove(olong.longValue());
- }
} }
+ // CraftBukkit end + // CraftBukkit end
@ -575,6 +582,7 @@
} }
public void recreateStructures(int p_82695_1_, int p_82695_2_) {} public void recreateStructures(int p_82695_1_, int p_82695_2_) {}
-}
+ +
+ // Cauldron start + // Cauldron start
+ private boolean shouldLoadChunk() + private boolean shouldLoadChunk()
@ -641,4 +649,4 @@
+ } + }
+ } + }
+ // Cauldron end + // Cauldron end
} +}

6
patches/net/minecraftforge/common/chunkio/ChunkIOProvider.java.patch

@ -47,3 +47,9 @@
} }
chunk.populateChunk(queuedChunk.provider, queuedChunk.provider, queuedChunk.x, queuedChunk.z); chunk.populateChunk(queuedChunk.provider, queuedChunk.provider, queuedChunk.x, queuedChunk.z);
@@ -61,4 +87,4 @@
thread.setDaemon(true);
return thread;
}
-}
+}

Loading…
Cancel
Save