diff --git a/patches/net/minecraft/tileentity/TileEntity.java.patch b/patches/net/minecraft/tileentity/TileEntity.java.patch index 8b36b9b..8fb58fd 100644 --- a/patches/net/minecraft/tileentity/TileEntity.java.patch +++ b/patches/net/minecraft/tileentity/TileEntity.java.patch @@ -15,6 +15,7 @@ - protected World worldObj; + public static Map classToNameMap = new HashMap(); // Cauldron - private -> public + public World worldObj; // CraftBukkit - protected -> public ++ private boolean GC = false; public int xCoord; public int yCoord; public int zCoord; @@ -55,6 +56,17 @@ + return null; + } + // CraftBukkit end ++ // KCauldron start ++ public boolean isGC() ++ { ++ return this.GC; //Returns true if the chunk it is inside of has marked it for unloading ++ } ++ ++ public void setGC(boolean state) ++ { ++ this.GC = state; //Should never be touched by a mod. Would make it package-private but not sure if that would still work ++ } ++ // KCauldron end + // -- BEGIN FORGE PATCHES -- /** diff --git a/patches/net/minecraft/world/World.java.patch b/patches/net/minecraft/world/World.java.patch index d10e86c..3ae8092 100644 --- a/patches/net/minecraft/world/World.java.patch +++ b/patches/net/minecraft/world/World.java.patch @@ -923,9 +923,20 @@ - TileEntity tileentity = (TileEntity)iterator.next(); + for (Object tile : field_147483_b) + { -+ ((TileEntity) tile).onChunkUnload(); ++ TileEntity te = (TileEntity)tile; ++ te.setGC(true); ++ te.onChunkUnload(); ++ } ++ List temporary_tile_entity_list = new ArrayList(this.loadedTileEntityList.size()); ++ for(Object tile : loadedTileEntityList) ++ if(!((TileEntity)tile).isGC()) ++ temporary_tile_entity_list.add(tile); ++ this.loadedTileEntityList = temporary_tile_entity_list; ++ for (Object tile : field_147483_b) ++ { ++ TileEntity te = (TileEntity)tile; ++ te.setGC(false); + } -+ this.loadedTileEntityList.removeAll(this.field_147483_b); + this.field_147483_b.clear(); + } + // CraftBukkit end diff --git a/patches/net/minecraft/world/gen/ChunkProviderServer.java.patch b/patches/net/minecraft/world/gen/ChunkProviderServer.java.patch index b482d0d..a1c1f03 100644 --- a/patches/net/minecraft/world/gen/ChunkProviderServer.java.patch +++ b/patches/net/minecraft/world/gen/ChunkProviderServer.java.patch @@ -456,11 +456,11 @@ - DimensionManager.unloadWorld(this.worldObj.provider.dimensionId); - return currentChunkProvider.unloadQueuedChunks(); + // 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) + { + CauldronHooks.logChunkUnload(this, chunk.xPosition, chunk.zPosition, "** Chunk kept from unloading due to recent activity"); + continue; -+ }*/ ++ } + // Cauldron end + + @@ -541,10 +541,10 @@ + return loadedChunkHashMap_KC.get(chunkHash).lastAccessedTick; + } + -+ /*private boolean shouldUnloadChunk(Chunk chunk) ++ private boolean shouldUnloadChunk(Chunk chunk) + { + if (chunk == null) return false; -+ return MinecraftServer.getServer().getTickCounter() - chunk.lastAccessedTick > CauldronConfig.chunkGCGracePeriod.getValue(); -+ }*/ ++ return MinecraftServer.getServer().getTickCounter() - chunk.lastAccessedTick > MinecraftServer.getServer().cauldronConfig.chunkGCGracePeriod.getValue(); ++ } + // Cauldron end } diff --git a/src/main/java/net/minecraftforge/cauldron/configuration/CauldronConfig.java b/src/main/java/net/minecraftforge/cauldron/configuration/CauldronConfig.java index e8a566b..91bdbc4 100644 --- a/src/main/java/net/minecraftforge/cauldron/configuration/CauldronConfig.java +++ b/src/main/java/net/minecraftforge/cauldron/configuration/CauldronConfig.java @@ -45,6 +45,7 @@ public class CauldronConfig extends ConfigBase public final BoolSetting checkEntityMaxSpeeds = new BoolSetting(this, "settings.check-entity-max-speeds", false, "Removes any entity that exceeds max speed."); 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 chunkGCGracePeriod = new IntSetting(this, "settings.chunk-gc-grace-period",0,"Grace period of no-ticks before unload"); // 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"); @@ -100,6 +101,7 @@ public class CauldronConfig extends ConfigBase settings.put(userLogin.path, userLogin); settings.put(allowTntPunishment.path, allowTntPunishment); settings.put(maxPlayersVisible.path, maxPlayersVisible); + settings.put(chunkGCGracePeriod.path,chunkGCGracePeriod); load(); } diff --git a/src/main/java/org/spigotmc/RestartCommand.java b/src/main/java/org/spigotmc/RestartCommand.java index 44691a4..ac7212f 100644 --- a/src/main/java/org/spigotmc/RestartCommand.java +++ b/src/main/java/org/spigotmc/RestartCommand.java @@ -47,8 +47,15 @@ public class RestartCommand extends Command net.minecraft.server.dedicated.DedicatedServer.allowPlayerLogins = false; // Kick all players - for (Player player : Bukkit.getOnlinePlayers()) { - player.kickPlayer(SpigotConfig.restartMessage); + for ( Object p : net.minecraft.server.MinecraftServer.getServer().getConfigurationManager().playerEntityList.toArray() ) + { + if(p instanceof net.minecraft.entity.player.EntityPlayerMP) + { + net.minecraft.entity.player.EntityPlayerMP mp = ( net.minecraft.entity.player.EntityPlayerMP)p; + mp.playerNetServerHandler.kickPlayerFromServer(SpigotConfig.restartMessage); + mp.playerNetServerHandler.netManager.isChannelOpen(); + } + } // Give the socket a chance to send the packets