public static void initDimension(int dim) { if (dim == 0) return; // Cauldron - overworld WorldServer overworld = getWorld(0); if (overworld == null) { throw new RuntimeException("Cannot Hotload Dim: Overworld is not Loaded!"); } try { // Cauldron start - Fixes MultiVerse issue when mods such as Twilight Forest try to hotload their dimension when using its WorldProvider if(net.minecraftforge.cauldron.CauldronHooks.craftWorldLoading) { return; } // Cauldron end DimensionManager.getProviderType(dim); } catch (Exception e) { System.err.println("Cannot Hotload Dim: " + e.getMessage()); return; // If a provider hasn't been registered then we can't hotload the dim } MinecraftServer mcServer = overworld.func_73046_m(); ISaveHandler savehandler = overworld.getSaveHandler(); WorldSettings worldSettings = new WorldSettings(overworld.getWorldInfo()); // Cauldron start - handles hotloading dimensions String worldType; String name; String oldName = ""; Environment env = Environment.getEnvironment(getProviderType(dim)); if (dim >= -1 && dim <= 1) { if ((dim == -1 && !mcServer.getAllowNether()) || (dim == 1 && !mcServer.server.getAllowEnd())) return; worldType = env.toString().toLowerCase(); name = "DIM" + dim; } else { WorldProvider provider = WorldProvider.getProviderForDimension(dim); worldType = provider.getClass().getSimpleName().toLowerCase(); worldType = worldType.replace("worldprovider", ""); oldName = "world_" + worldType; worldType = worldType.replace("provider", ""); if (Environment.getEnvironment(DimensionManager.getProviderType(dim)) == null) env = DimensionManager.registerBukkitEnvironment(DimensionManager.getProviderType(provider.getClass()), worldType); name = provider.getSaveFolder(); if (name == null) name = "DIM0"; } // add ability to disable dimensions if (!MinecraftServer.getServer().cauldronConfig.getBoolean("world-environment-settings." + worldType + ".enabled", true)) return; CauldronUtils.migrateWorlds(worldType, oldName, overworld.getWorldInfo().getWorldName(), name); // Cauldron ChunkGenerator gen = mcServer.server.getGenerator(name); if (mcServer instanceof DedicatedServer) { worldSettings.func_82750_a(((DedicatedServer) mcServer).getStringProperty("generator-settings", "")); } WorldServer world = new WorldServerMulti(mcServer, new AnvilSaveHandler(mcServer.server.getWorldContainer(), name, true), name, dim, worldSettings, overworld, mcServer.theProfiler, env, gen); if (gen != null) { world.getWorld().getPopulators().addAll(gen.getDefaultPopulators(world.getWorld())); } mcServer.getConfigurationManager().setPlayerManager(mcServer.worlds.toArray(new WorldServer[mcServer.worlds.size()])); world.addWorldAccess(new WorldManager(mcServer, world)); MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(world)); mcServer.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(world.getWorld())); // Cauldron end if (!mcServer.isSinglePlayer()) { world.getWorldInfo().setGameType(mcServer.getGameType()); } mcServer.func_147139_a(mcServer.func_147135_j()); }
public static WorldServer initDimension(WorldCreator creator, WorldSettings worldSettings) { WorldServer overworld = getWorld(0); if (overworld == null) { throw new RuntimeException("Cannot Hotload Dim: Overworld is not Loaded!"); } MinecraftServer mcServer = overworld.func_73046_m(); String worldType; String name; int providerId = 0; if (creator.environment() != null) providerId = creator.environment().getId(); try { providerId = getProviderType(providerId); } catch (IllegalArgumentException e) { // do nothing } Environment env = creator.environment(); worldType = env.name().toLowerCase(); name = creator.name(); int dim = 0; // Use saved dimension from level.dat if it exists. This guarantees that after a world is created, the same dimension will be used. Fixes issues with MultiVerse AnvilSaveHandler saveHandler = new AnvilSaveHandler(mcServer.server.getWorldContainer(), name, true); if (saveHandler.loadWorldInfo() != null) { int savedDim = saveHandler.loadWorldInfo().getDimension(); if (savedDim != 0 && savedDim != -1 && savedDim != 1) { dim = savedDim; } } if (dim == 0) { dim = getNextFreeDimId(); } if (!isDimensionRegistered(dim)) // handle reloads properly { registerDimension(dim, providerId); addBukkitDimension(dim); } ChunkGenerator gen = creator.generator(); if (mcServer instanceof DedicatedServer) { worldSettings.func_82750_a(((DedicatedServer) mcServer).getStringProperty("generator-settings", "")); } WorldServer world = new WorldServerMulti(mcServer, saveHandler, name, dim, worldSettings, overworld, mcServer.theProfiler, env, gen); if (gen != null) { world.getWorld().getPopulators().addAll(gen.getDefaultPopulators(world.getWorld())); } world.provider.dimensionId = dim; // Fix for TerrainControl injecting their own WorldProvider mcServer.getConfigurationManager().setPlayerManager(mcServer.worlds.toArray(new WorldServer[mcServer.worlds.size()])); world.addWorldAccess(new WorldManager(mcServer, world)); MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(world)); if (!mcServer.isSinglePlayer()) { world.getWorldInfo().setGameType(mcServer.getGameType()); } mcServer.func_147139_a(mcServer.func_147135_j()); return world; }
public ISaveHandler func_75804_a(String p_75804_1_, boolean p_75804_2_) { return new AnvilSaveHandler(this.field_75808_a, p_75804_1_, p_75804_2_); }