Java 类net.minecraft.world.ServerWorldEventHandler 实例源码

项目:CustomWorldGen    文件:DimensionManager.java   
public static void initDimension(int dim)
{
    WorldServer overworld = getWorld(0);
    if (overworld == null)
    {
        throw new RuntimeException("Cannot Hotload Dim: Overworld is not Loaded!");
    }
    try
    {
        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.getMinecraftServer();
    ISaveHandler savehandler = overworld.getSaveHandler();
    //WorldSettings worldSettings = new WorldSettings(overworld.getWorldInfo());

    WorldServer world = (dim == 0 ? overworld : (WorldServer)(new WorldServerMulti(mcServer, savehandler, dim, overworld, mcServer.theProfiler).init()));
    world.addEventListener(new ServerWorldEventHandler(mcServer, world));
    MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(world));
    if (!mcServer.isSinglePlayer())
    {
        world.getWorldInfo().setGameType(mcServer.getGameType());
    }

    mcServer.setDifficultyForAllWorlds(mcServer.getDifficulty());
}
项目:Simple-Dimensions    文件:DimensionHandler.java   
private void loadDimension(int dimensionID, WorldInfo worldInfo)
{
    WorldServer overworld = (WorldServer) FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld();
    if (overworld == null)
    {
        throw new RuntimeException("Cannot Hotload Dim: Overworld is not Loaded!");
    }
    try
    {
        DimensionManager.getProviderType(dimensionID);
    }
    catch (Exception e)
    {
        System.err.println("Cannot Hotload Dim: " + e.getMessage());
        return;
    }

    MinecraftServer mcServer = overworld.getMinecraftServer();
    ISaveHandler savehandler = overworld.getSaveHandler();
    EnumDifficulty difficulty = mcServer.getEntityWorld().getDifficulty();

    WorldServer world = (WorldServer) (new WorldCustom(worldInfo, mcServer, savehandler, dimensionID, overworld, mcServer.profiler).init());
    world.addEventListener(new ServerWorldEventHandler(mcServer, world));
    MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(world));

    if (!mcServer.isSinglePlayer())
    {
        world.getWorldInfo().setGameType(mcServer.getGameType());
    }

    mcServer.setDifficultyForAllWorlds(difficulty);
}