Browse Source

Unofficial Fixes Merge 1

- Start using GC Flag TileEntities
- Introduce TileEntity GC (GarbageCollection) Flag
- Reintroduce Chunk Unload Stopping
- Restart Command avoid ConcurrentModification
- Move comments
- Change to void
master
Yive 9 years ago
parent
commit
100a4ac11a
  1. 12
      patches/net/minecraft/tileentity/TileEntity.java.patch
  2. 15
      patches/net/minecraft/world/World.java.patch
  3. 10
      patches/net/minecraft/world/gen/ChunkProviderServer.java.patch
  4. 2
      src/main/java/net/minecraftforge/cauldron/configuration/CauldronConfig.java
  5. 11
      src/main/java/org/spigotmc/RestartCommand.java

12
patches/net/minecraft/tileentity/TileEntity.java.patch

@ -15,6 +15,7 @@
- protected World worldObj; - protected World worldObj;
+ public static Map classToNameMap = new HashMap(); // Cauldron - private -> public + public static Map classToNameMap = new HashMap(); // Cauldron - private -> public
+ public World worldObj; // CraftBukkit - protected -> public + public World worldObj; // CraftBukkit - protected -> public
+ private boolean GC = false;
public int xCoord; public int xCoord;
public int yCoord; public int yCoord;
public int zCoord; public int zCoord;
@ -55,6 +56,17 @@
+ return null; + return null;
+ } + }
+ // CraftBukkit end + // 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 -- // -- BEGIN FORGE PATCHES --
/** /**

15
patches/net/minecraft/world/World.java.patch

@ -923,9 +923,20 @@
- TileEntity tileentity = (TileEntity)iterator.next(); - TileEntity tileentity = (TileEntity)iterator.next();
+ for (Object tile : field_147483_b) + 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(); + this.field_147483_b.clear();
+ } + }
+ // CraftBukkit end + // CraftBukkit end

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

@ -456,11 +456,11 @@
- DimensionManager.unloadWorld(this.worldObj.provider.dimensionId); - DimensionManager.unloadWorld(this.worldObj.provider.dimensionId);
- return currentChunkProvider.unloadQueuedChunks(); - return currentChunkProvider.unloadQueuedChunks();
+ // 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)
+ { + {
+ 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
+ +
+ +
@ -541,10 +541,10 @@
+ return loadedChunkHashMap_KC.get(chunkHash).lastAccessedTick; + return loadedChunkHashMap_KC.get(chunkHash).lastAccessedTick;
+ } + }
+ +
+ /*private boolean shouldUnloadChunk(Chunk chunk) + private boolean shouldUnloadChunk(Chunk chunk)
+ { + {
+ if (chunk == null) return false; + 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 + // Cauldron end
} }

2
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 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 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 IntSetting chunkGCGracePeriod = new IntSetting(this, "settings.chunk-gc-grace-period",0,"Grace period of no-ticks before unload");
// 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");
@ -100,6 +101,7 @@ public class CauldronConfig extends ConfigBase
settings.put(userLogin.path, userLogin); settings.put(userLogin.path, userLogin);
settings.put(allowTntPunishment.path, allowTntPunishment); settings.put(allowTntPunishment.path, allowTntPunishment);
settings.put(maxPlayersVisible.path, maxPlayersVisible); settings.put(maxPlayersVisible.path, maxPlayersVisible);
settings.put(chunkGCGracePeriod.path,chunkGCGracePeriod);
load(); load();
} }

11
src/main/java/org/spigotmc/RestartCommand.java

@ -47,8 +47,15 @@ public class RestartCommand extends Command
net.minecraft.server.dedicated.DedicatedServer.allowPlayerLogins = false; net.minecraft.server.dedicated.DedicatedServer.allowPlayerLogins = false;
// Kick all players // Kick all players
for (Player player : Bukkit.getOnlinePlayers()) { for ( Object p : net.minecraft.server.MinecraftServer.getServer().getConfigurationManager().playerEntityList.toArray() )
player.kickPlayer(SpigotConfig.restartMessage); {
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 // Give the socket a chance to send the packets

Loading…
Cancel
Save