--- ../src_base/minecraft_server/net/minecraft/server/MinecraftServer.java 0000-00-00 00:00:00.000000000 -0000 +++ ../src_work/minecraft_server/net/minecraft/server/MinecraftServer.java 0000-00-00 00:00:00.000000000 -0000 @@ -8,6 +8,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.Hashtable; import java.util.Iterator; import java.util.List; import java.util.Random; @@ -44,11 +45,13 @@ import net.minecraft.src.ThreadServerApplication; import net.minecraft.src.ThreadServerSleep; import net.minecraft.src.Vec3D; +import net.minecraft.src.World; import net.minecraft.src.WorldManager; import net.minecraft.src.WorldServer; import net.minecraft.src.WorldServerMulti; import net.minecraft.src.WorldSettings; import net.minecraft.src.WorldType; +import net.minecraft.src.forge.DimensionManager; public class MinecraftServer implements Runnable, ICommandListener, IServer { @@ -69,9 +72,10 @@ public PropertyManager propertyManagerObj; /** The server world manager. */ - public WorldServer[] worldMngr; + //public WorldServer[] worldMngr; public long[] field_40027_f = new long[100]; - public long[][] field_40028_g; + //public long[][] field_40028_g; + public Hashtable worldTickTimes = new Hashtable(); /** the server config manager for this server */ public ServerConfigurationManager configManager; @@ -99,7 +103,7 @@ /** A list containing all the commands entered. */ private List commands = Collections.synchronizedList(new ArrayList()); - public EntityTracker[] entityTracker = new EntityTracker[3]; + //public EntityTracker[] entityTracker = new EntityTracker[3]; /** True if the server is in online mode. */ public boolean onlineMode; @@ -129,6 +133,8 @@ public long[] field_48082_x = new long[100]; private RConThreadQuery rconQueryThread; private RConThreadMain rconMainThread; + + public int spawnProtectionSize = 16; public MinecraftServer() { @@ -163,6 +169,7 @@ this.allowFlight = this.propertyManagerObj.getBooleanProperty("allow-flight", false); this.motd = this.propertyManagerObj.getStringProperty("motd", "A Minecraft Server"); this.motd.replace('\u00a7', '$'); + spawnProtectionSize = this.propertyManagerObj.getIntProperty("spawn-protection-size", 16); InetAddress var2 = null; if (this.hostname.length() > 0) @@ -195,9 +202,11 @@ FMLServerHandler.instance().onLoadComplete(); this.configManager = new ServerConfigurationManager(this); + /* this.entityTracker[0] = new EntityTracker(this, 0); this.entityTracker[1] = new EntityTracker(this, -1); this.entityTracker[2] = new EntityTracker(this, 1); + */ long var3 = System.nanoTime(); String var5 = this.propertyManagerObj.getStringProperty("level-name", "world"); String var6 = this.propertyManagerObj.getStringProperty("level-seed", ""); @@ -265,53 +274,36 @@ logger.info("Converting map!"); par1ISaveFormat.convertMapFormat(par2Str, new ConvertProgressUpdater(this)); } - + /* this.worldMngr = new WorldServer[3]; this.field_40028_g = new long[this.worldMngr.length][100]; + */ int var6 = this.propertyManagerObj.getIntProperty("gamemode", 0); var6 = WorldSettings.validGameType(var6); logger.info("Default game type: " + var6); boolean var7 = this.propertyManagerObj.getBooleanProperty("generate-structures", true); WorldSettings var8 = new WorldSettings(par3, var6, var7, false, par5WorldType); AnvilSaveHandler var9 = new AnvilSaveHandler(new File("."), par2Str, true); - - for (int var10 = 0; var10 < this.worldMngr.length; ++var10) + + WorldServer overWorld = new WorldServer(this, var9, par2Str, 0, var8); + for (Integer id : DimensionManager.getIDs()) { - byte var11 = 0; - - if (var10 == 1) - { - var11 = -1; - } - - if (var10 == 2) - { - var11 = 1; - } - - if (var10 == 0) - { - this.worldMngr[var10] = new WorldServer(this, var9, par2Str, var11, var8); - } - else - { - this.worldMngr[var10] = new WorldServerMulti(this, var9, par2Str, var11, var8, this.worldMngr[0]); - } - - this.worldMngr[var10].addWorldAccess(new WorldManager(this, this.worldMngr[var10])); - this.worldMngr[var10].difficultySetting = this.propertyManagerObj.getIntProperty("difficulty", 1); - this.worldMngr[var10].setAllowedSpawnTypes(this.propertyManagerObj.getBooleanProperty("spawn-monsters", true), this.spawnPeacefulMobs); - this.worldMngr[var10].getWorldInfo().setGameType(var6); - this.configManager.setPlayerManager(this.worldMngr); + WorldServer world = (id == 0 ? overWorld : new WorldServerMulti(this, var9, par2Str, id, var8, overWorld)); + world.addWorldAccess(new WorldManager(this, world)); + world.difficultySetting = propertyManagerObj.getIntProperty("difficulty", 1); + world.setAllowedSpawnTypes(propertyManagerObj.getBooleanProperty("spawn-monsters", true), spawnPeacefulMobs); + world.getWorldInfo().setGameType(var6); + worldTickTimes.put(id, new long[100]); } + configManager.setPlayerManager(new WorldServer[]{ overWorld }); short var22 = 196; long var23 = System.currentTimeMillis(); - for (int var13 = 0; var13 < 1; ++var13) + for (Integer id : DimensionManager.getIDs()) { - logger.info("Preparing start region for level " + var13); - WorldServer var14 = this.worldMngr[var13]; + logger.info("Preparing start region for level " + id); + WorldServer var14 = (WorldServer)DimensionManager.getWorld(id); ChunkCoordinates var15 = var14.getSpawnPoint(); for (int var16 = -var22; var16 <= var22 && this.serverRunning; var16 += 16) @@ -372,9 +364,9 @@ { logger.info("Saving chunks"); - for (int var1 = 0; var1 < this.worldMngr.length; ++var1) + for (World world : DimensionManager.getWorlds()) { - WorldServer var2 = this.worldMngr[var1]; + WorldServer var2 = (WorldServer)world; var2.saveWorld(true, (IProgressUpdate)null); var2.func_30006_w(); } @@ -392,13 +384,14 @@ this.configManager.savePlayerStates(); } - for (int var1 = 0; var1 < this.worldMngr.length; ++var1) + for (World world : DimensionManager.getWorlds()) { - WorldServer var2 = this.worldMngr[var1]; + WorldServer var2 = (WorldServer)world; if (var2 != null) { this.saveServerWorld(); + break; //Added because saveServerWorld() loops through all worlds anyways. } } } @@ -439,7 +432,7 @@ var3 += var7; var1 = var5; - if (this.worldMngr[0].isAllPlayersFullyAsleep()) + if (((WorldServer)DimensionManager.getWorld(0)).isAllPlayersFullyAsleep()) { this.doTick(); var3 = 0L; @@ -542,13 +535,13 @@ Vec3D.initialize(); ++this.deathTime; - for (var9 = 0; var9 < this.worldMngr.length; ++var9) + for (Integer id : DimensionManager.getIDs()) { long var10 = System.nanoTime(); - if (var9 == 0 || this.propertyManagerObj.getBooleanProperty("allow-nether", true)) + if (id == 0 || this.propertyManagerObj.getBooleanProperty("allow-nether", true)) { - WorldServer var7 = this.worldMngr[var9]; + WorldServer var7 = (WorldServer)DimensionManager.getWorld(id); if (this.deathTime % 20 == 0) { @@ -567,15 +560,15 @@ } } - this.field_40028_g[var9][this.deathTime % 100] = System.nanoTime() - var10; + worldTickTimes.get(id)[this.deathTime % 100] = System.nanoTime() - var10; } this.networkServer.handleNetworkListenThread(); this.configManager.onTick(); - for (var9 = 0; var9 < this.entityTracker.length; ++var9) + for (World world : DimensionManager.getWorlds()) { - this.entityTracker[var9].updateTrackedEntities(); + ((WorldServer)world).entityTracker.updateTrackedEntities(); } for (var9 = 0; var9 < this.playersOnline.size(); ++var9) @@ -691,7 +684,8 @@ */ public WorldServer getWorldManager(int par1) { - return par1 == -1 ? this.worldMngr[1] : (par1 == 1 ? this.worldMngr[2] : this.worldMngr[0]); + WorldServer ret = (WorldServer)DimensionManager.getWorld(par1); + return (ret != null ? ret : (WorldServer)DimensionManager.getWorld(0)); } /** @@ -699,7 +693,7 @@ */ public EntityTracker getEntityTracker(int par1) { - return par1 == -1 ? this.entityTracker[1] : (par1 == 1 ? this.entityTracker[2] : this.entityTracker[0]); + return getWorldManager(par1).entityTracker; } /**