package com.khorn.terraincontrol.forge;

import java.io.File;

import net.minecraft.src.IChunkProvider;
import net.minecraft.src.World;
import net.minecraft.src.WorldChunkManager;
import net.minecraft.src.WorldClient;
import net.minecraft.src.WorldType;

import com.khorn.terraincontrol.configuration.WorldConfig;

public class TCWorldType extends WorldType
{
    public SingleWorld worldTC;
    private TCPlugin plugin;

    public TCWorldType(TCPlugin plugin, int paramInt, String paramString)
    {
        super(paramInt, paramString);
        this.plugin = plugin;
    }

    @Override
    public WorldChunkManager getChunkManager(World world)
    {
        if (world instanceof WorldClient)
            return super.getChunkManager(world);
        
        // Restore old biomes
        SingleWorld.restoreBiomes();

        // Load everything
        File worldDirectory = new File(plugin.terrainControlDirectory, "worlds" + File.separator + world.getSaveHandler().getSaveDirectoryName());

        if (!worldDirectory.exists())
        {
            System.out.println("TerrainControl: settings does not exist, creating defaults");

            if (!worldDirectory.mkdirs())
                System.out.println("TerrainControl: cant create folder " + worldDirectory.getAbsolutePath());
        }

        this.worldTC = new SingleWorld(world.getSaveHandler().getSaveDirectoryName());
        WorldConfig config = new WorldConfig(worldDirectory, worldTC, false);
        this.worldTC.Init(world, config);

        WorldChunkManager ChunkManager = null;

        switch (this.worldTC.getSettings().ModeBiome)
        {
        case FromImage:
        case Normal:
            ChunkManager = new BiomeManager(this.worldTC);
            this.worldTC.setBiomeManager((BiomeManager) ChunkManager);
            break;
        case OldGenerator:
            ChunkManager = new BiomeManagerOld(this.worldTC);
            this.worldTC.setOldBiomeManager((BiomeManagerOld) ChunkManager);
            break;
        case Default:
            ChunkManager = super.getChunkManager(world);
            break;
        }

        return ChunkManager;
    }

    @Override
    public IChunkProvider getChunkGenerator(World world, String generatorOptions)
    {
        if (this.worldTC.getSettings().ModeTerrain != WorldConfig.TerrainMode.Default)
        {
            return this.worldTC.getChunkGenerator();
        } else
            return super.getChunkGenerator(world, generatorOptions);
    }

}

@@ -666,32 +666,60 @@
  world)%0D%0A    %7B%0D%0A
+        try%0D%0A        %7B%0D%0A    
         if (worl
@@ -741,24 +741,43 @@
 rldClient)%0D%0A
+            %7B%0D%0A    
             
@@ -822,16 +822,206 @@
         
+    %7D%0D%0A        %7D catch (NoClassDefFoundError e)%0D%0A        %7B%0D%0A            // There isn't a WorldClient class, so we are on a stand-alone%0D%0A            // server. Continue normally.%0D%0A        %7D%0D%0A
 %0D%0A      

Fix another dependency on the client