Fix vanilla bug where the player would load chunks outside its range that would be 'abandoned' and never unloaded.

This commit is contained in:
LexManos 2012-09-27 23:58:40 -07:00
parent 49f263eb63
commit d373632275
3 changed files with 39 additions and 1 deletions

View File

@ -78,3 +78,5 @@ public abu.a # ComponentVillageHouse2.villageBlacksmithChestContents
default wy.d
# ChunkProviderServer.currentChunkLoader
default gq.e
# PlayerManager
default go.a(IIZ)Lgp; # getOrCreateChunkWatcher

View File

@ -29,7 +29,19 @@
this.setLocationAndAngles((double)var6 + 0.5D, (double)var8, (double)var7 + 0.5D, 0.0F, 0.0F);
this.mcServer = par1MinecraftServer;
@@ -336,8 +332,27 @@
@@ -193,7 +189,10 @@
if (var4 != null && this.worldObj.blockExists(var4.chunkXPos << 4, 0, var4.chunkZPos << 4))
{
var6.add(this.worldObj.getChunkFromChunkCoords(var4.chunkXPos, var4.chunkZPos));
- var3.addAll(((WorldServer)this.worldObj).getAllTileEntityInBox(var4.chunkXPos * 16, 0, var4.chunkZPos * 16, var4.chunkXPos * 16 + 16, 256, var4.chunkZPos * 16 + 16));
+ //BugFix: 16 makes it load an extra chunk, which isn't associated with a player, which makes it not unload unless a player walks near it.
+ //ToDo: Find a way to efficiently clean abandoned chunks.
+ //var3.addAll(((WorldServer)this.worldObj).getAllTileEntityInBox(var4.chunkXPos * 16, 0, var4.chunkZPos * 16, var4.chunkXPos * 16 + 16, 256, var4.chunkZPos * 16 + 16));
+ var3.addAll(((WorldServer)this.worldObj).getAllTileEntityInBox(var4.chunkXPos * 16, 0, var4.chunkZPos * 16, var4.chunkXPos * 16 + 15, 256, var4.chunkZPos * 16 + 15));
}
}
@@ -336,8 +335,27 @@
*/
public void onDeath(DamageSource par1DamageSource)
{

View File

@ -0,0 +1,24 @@
--- ../src_base/common/net/minecraft/src/PlayerInstance.java
+++ ../src_work/common/net/minecraft/src/PlayerInstance.java
@@ -3,6 +3,9 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+
+import cpw.mods.fml.common.FMLCommonHandler;
+import cpw.mods.fml.common.Side;
class PlayerInstance
{
@@ -140,7 +143,10 @@
if ((this.field_73260_f & 1 << var3) != 0)
{
var4 = var3 << 4;
- List var5 = PlayerManager.getWorldServer(this.myManager).getAllTileEntityInBox(var1, var4, var2, var1 + 16, var4 + 16, var2 + 16);
+ //BugFix: 16 makes it load an extra chunk, which isn't associated with a player, which makes it not unload unless a player walks near it.
+ //ToDo: Find a way to efficiently clean abandoned chunks.
+ List var5 = PlayerManager.getWorldServer(this.myManager).getAllTileEntityInBox(var1, var4, var2, var1 + 15, var4 + 16, var2 + 15);
+ List var5 = PlayerManager.getWorldServer(this.myManager).getAllTileEntityInBox(var1, var4, var2, var1 + 15, var4 + 16, var2 + 15);
Iterator var6 = var5.iterator();
while (var6.hasNext())