package com.scottkillen.mod.dendrology.world.gen;

import com.google.common.base.Objects;
import com.google.common.collect.ImmutableSet;
import com.scottkillen.mod.dendrology.config.Settings;
import com.scottkillen.mod.dendrology.util.log.Logger;
import com.scottkillen.mod.dendrology.util.world.BiomeDictionaryProxy;
import com.scottkillen.mod.dendrology.world.gen.feature.Cypress;
import cpw.mods.fml.common.IWorldGenerator;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenAbstractTree;
import net.minecraftforge.common.BiomeDictionary;
import java.util.Random;

import static net.minecraftforge.common.BiomeDictionary.Type.SWAMP;

@SuppressWarnings("NonSerializableFieldInSerializableClass")
public enum CypressGenerator implements IWorldGenerator
{
    INSTANCE;

    private final WorldGenAbstractTree treeGen = new Cypress(false);

    @SuppressWarnings("SimplifiableIfStatement")
    private static boolean isIdealHabitat(ImmutableSet<BiomeDictionary.Type> biomeTags)
    {
        return biomeTags.contains(SWAMP);
    }

    public static void init()
    {
        GameRegistry.registerWorldGenerator(INSTANCE, 30);
    }

    @Override
    public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
    {
        if (!Settings.TreeGen.doCypressTreeGeneration()) return;

        final ImmutableSet<BiomeDictionary.Type> biomeTags = ImmutableSet.copyOf(BiomeDictionaryProxy.getBiomeTags(world, chunkX, chunkZ));

        if (isIdealHabitat(biomeTags))
        {
            generateCypress(world, random, chunkX, chunkZ);
        }
    }

    private void generateCypress(World world, Random rand, int chunkX, int chunkZ)
    {
        final int numAttempts = rand.nextInt(7);

        for (int attempt = 0; attempt < numAttempts; attempt++)
        {
            final int x = chunkX + rand.nextInt(16) + 8;
            final int z = chunkZ + rand.nextInt(16) + 8;
            final int y = world.getHeightValue(x, z);

            if (treeGen.generate(world, rand, x, y, z))
            {
                treeGen.func_150524_b(world, rand, x, y, z);
                Logger.info("Cypress: %d, %d, %d", x, y, z);
            }
        }
    }

    @Override
    public String toString()
    {
        return Objects.toStringHelper(this).add("treeGen", treeGen).toString();
    }
}

@@ -451,29 +451,35 @@
 mon.
-registry.GameRegistry
+eventhandler.SubscribeEvent
 ;%0Aim
@@ -681,93 +681,299 @@
 ort 
-java.util.Random;%0A%0Aimport static net.minecraftforge.common.BiomeDictionary.Type.SWAMP
+net.minecraftforge.common.MinecraftForge;%0Aimport net.minecraftforge.event.terraingen.DecorateBiomeEvent;%0Aimport java.util.Random;%0A%0Aimport static net.minecraftforge.common.BiomeDictionary.Type.SWAMP;%0Aimport static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.TREE
 ;%0A%0A@
@@ -1415,56 +1415,280 @@
     
-GameRegistry.registerWorldGenerator(INSTANCE, 30
+MinecraftForge.TERRAIN_GEN_BUS.register(INSTANCE);%0A    %7D%0A%0A    @SubscribeEvent%0A    public void onDecorateBiome(DecorateBiomeEvent.Decorate event)%0A    %7B%0A        if (event.type != TREE) return;%0A%0A        generate(event.rand, event.chunkX, event.chunkZ, event.world, null, null
 );%0A 
@@ -2265,32 +2265,75 @@
 t chunkZ)%0A    %7B%0A
+        if (rand.nextInt(10) %3E 1) return;%0A%0A
         final in

Change cypress tree to use Terrain Gen event.