--- ../src-base/minecraft/net/minecraft/world/biome/BiomeDecorator.java
+++ ../src-work/minecraft/net/minecraft/world/biome/BiomeDecorator.java
@@ -23,6 +23,11 @@
 import net.minecraft.world.gen.feature.WorldGenWaterlily;
 import net.minecraft.world.gen.feature.WorldGenerator;
 
+import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.*;
+import static net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.*;
+import net.minecraftforge.common.*;
+import net.minecraftforge.event.terraingen.*;
+
 public class BiomeDecorator
 {
     public World field_76815_a;
@@ -125,26 +130,30 @@
 
     protected void func_150513_a(BiomeGenBase p_150513_1_)
     {
+        MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Pre(field_76815_a, field_76813_b, field_180294_c));
         this.func_76797_b();
         int i;
         int j;
         int k;
 
-        for (i = 0; i < this.field_76805_H; ++i)
+        boolean doGen = TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, SAND);
+        for (i = 0; doGen && i < this.field_76805_H; ++i)
         {
             j = this.field_76813_b.nextInt(16) + 8;
             k = this.field_76813_b.nextInt(16) + 8;
             this.field_76810_g.func_180709_b(this.field_76815_a, this.field_76813_b, this.field_76815_a.func_175672_r(this.field_180294_c.func_177982_a(j, 0, k)));
         }
 
-        for (i = 0; i < this.field_76806_I; ++i)
+        doGen = TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, CLAY);
+        for (i = 0; doGen && i < this.field_76806_I; ++i)
         {
             j = this.field_76813_b.nextInt(16) + 8;
             k = this.field_76813_b.nextInt(16) + 8;
             this.field_76809_f.func_180709_b(this.field_76815_a, this.field_76813_b, this.field_76815_a.func_175672_r(this.field_180294_c.func_177982_a(j, 0, k)));
         }
 
-        for (i = 0; i < this.field_76801_G; ++i)
+        doGen = TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, SAND_PASS2);
+        for (i = 0; doGen && i < this.field_76801_G; ++i)
         {
             j = this.field_76813_b.nextInt(16) + 8;
             k = this.field_76813_b.nextInt(16) + 8;
@@ -161,7 +170,8 @@
         int l;
         BlockPos blockpos;
 
-        for (j = 0; j < i; ++j)
+        doGen = TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, TREE);
+        for (j = 0; doGen && j < i; ++j)
         {
             k = this.field_76813_b.nextInt(16) + 8;
             l = this.field_76813_b.nextInt(16) + 8;
@@ -175,7 +185,8 @@
             }
         }
 
-        for (j = 0; j < this.field_76807_J; ++j)
+        doGen = TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, BIG_SHROOM);
+        for (j = 0; doGen && j < this.field_76807_J; ++j)
         {
             k = this.field_76813_b.nextInt(16) + 8;
             l = this.field_76813_b.nextInt(16) + 8;
@@ -184,11 +195,12 @@
 
         int i1;
 
-        for (j = 0; j < this.field_76802_A; ++j)
+        doGen = TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, FLOWERS);
+        for (j = 0; doGen && j < this.field_76802_A; ++j)
         {
             k = this.field_76813_b.nextInt(16) + 8;
             l = this.field_76813_b.nextInt(16) + 8;
-            i1 = this.field_76813_b.nextInt(this.field_76815_a.func_175645_m(this.field_180294_c.func_177982_a(k, 0, l)).func_177956_o() + 32);
+            i1 = nextInt(this.field_76815_a.func_175645_m(this.field_180294_c.func_177982_a(k, 0, l)).func_177956_o() + 32);
             blockpos = this.field_180294_c.func_177982_a(k, i1, l);
             BlockFlower.EnumFlowerType enumflowertype = p_150513_1_.func_180623_a(this.field_76813_b, blockpos);
             BlockFlower blockflower = enumflowertype.func_176964_a().func_180346_a();
@@ -200,29 +212,32 @@
             }
         }
 
-        for (j = 0; j < this.field_76803_B; ++j)
+        doGen = TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, GRASS);
+        for (j = 0; doGen && j < this.field_76803_B; ++j)
         {
             k = this.field_76813_b.nextInt(16) + 8;
             l = this.field_76813_b.nextInt(16) + 8;
-            i1 = this.field_76813_b.nextInt(this.field_76815_a.func_175645_m(this.field_180294_c.func_177982_a(k, 0, l)).func_177956_o() * 2);
+            i1 = nextInt(this.field_76815_a.func_175645_m(this.field_180294_c.func_177982_a(k, 0, l)).func_177956_o() * 2);
             p_150513_1_.func_76730_b(this.field_76813_b).func_180709_b(this.field_76815_a, this.field_76813_b, this.field_180294_c.func_177982_a(k, i1, l));
         }
 
-        for (j = 0; j < this.field_76804_C; ++j)
+        doGen = TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, DEAD_BUSH);
+        for (j = 0; doGen && j < this.field_76804_C; ++j)
         {
             k = this.field_76813_b.nextInt(16) + 8;
             l = this.field_76813_b.nextInt(16) + 8;
-            i1 = this.field_76813_b.nextInt(this.field_76815_a.func_175645_m(this.field_180294_c.func_177982_a(k, 0, l)).func_177956_o() * 2);
+            i1 = nextInt(this.field_76815_a.func_175645_m(this.field_180294_c.func_177982_a(k, 0, l)).func_177956_o() * 2);
             (new WorldGenDeadBush()).func_180709_b(this.field_76815_a, this.field_76813_b, this.field_180294_c.func_177982_a(k, i1, l));
         }
 
         j = 0;
 
-        while (j < this.field_76833_y)
+        doGen = TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, LILYPAD);
+        while (doGen && j < this.field_76833_y)
         {
             k = this.field_76813_b.nextInt(16) + 8;
             l = this.field_76813_b.nextInt(16) + 8;
-            i1 = this.field_76813_b.nextInt(this.field_76815_a.func_175645_m(this.field_180294_c.func_177982_a(k, 0, l)).func_177956_o() * 2);
+            i1 = nextInt(this.field_76815_a.func_175645_m(this.field_180294_c.func_177982_a(k, 0, l)).func_177956_o() * 2);
             blockpos = this.field_180294_c.func_177982_a(k, i1, l);
 
             while (true)
@@ -244,7 +259,8 @@
             }
         }
 
-        for (j = 0; j < this.field_76798_D; ++j)
+        doGen = TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, SHROOM);
+        for (j = 0; doGen && j < this.field_76798_D; ++j)
         {
             if (this.field_76813_b.nextInt(4) == 0)
             {
@@ -258,57 +274,60 @@
             {
                 k = this.field_76813_b.nextInt(16) + 8;
                 l = this.field_76813_b.nextInt(16) + 8;
-                i1 = this.field_76813_b.nextInt(this.field_76815_a.func_175645_m(this.field_180294_c.func_177982_a(k, 0, l)).func_177956_o() * 2);
+                i1 = nextInt(this.field_76815_a.func_175645_m(this.field_180294_c.func_177982_a(k, 0, l)).func_177956_o() * 2);
                 blockpos = this.field_180294_c.func_177982_a(k, i1, l);
                 this.field_76827_t.func_180709_b(this.field_76815_a, this.field_76813_b, blockpos);
             }
         }
 
-        if (this.field_76813_b.nextInt(4) == 0)
+        if (doGen && this.field_76813_b.nextInt(4) == 0)
         {
             j = this.field_76813_b.nextInt(16) + 8;
             k = this.field_76813_b.nextInt(16) + 8;
-            l = this.field_76813_b.nextInt(this.field_76815_a.func_175645_m(this.field_180294_c.func_177982_a(j, 0, k)).func_177956_o() * 2);
+            l = nextInt(this.field_76815_a.func_175645_m(this.field_180294_c.func_177982_a(j, 0, k)).func_177956_o() * 2);
             this.field_76828_s.func_180709_b(this.field_76815_a, this.field_76813_b, this.field_180294_c.func_177982_a(j, l, k));
         }
 
-        if (this.field_76813_b.nextInt(8) == 0)
+        if (doGen && this.field_76813_b.nextInt(8) == 0)
         {
             j = this.field_76813_b.nextInt(16) + 8;
             k = this.field_76813_b.nextInt(16) + 8;
-            l = this.field_76813_b.nextInt(this.field_76815_a.func_175645_m(this.field_180294_c.func_177982_a(j, 0, k)).func_177956_o() * 2);
+            l = nextInt(this.field_76815_a.func_175645_m(this.field_180294_c.func_177982_a(j, 0, k)).func_177956_o() * 2);
             this.field_76827_t.func_180709_b(this.field_76815_a, this.field_76813_b, this.field_180294_c.func_177982_a(j, l, k));
         }
 
-        for (j = 0; j < this.field_76799_E; ++j)
+        doGen = TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, REED);
+        for (j = 0; doGen && j < this.field_76799_E; ++j)
         {
             k = this.field_76813_b.nextInt(16) + 8;
             l = this.field_76813_b.nextInt(16) + 8;
-            i1 = this.field_76813_b.nextInt(this.field_76815_a.func_175645_m(this.field_180294_c.func_177982_a(k, 0, l)).func_177956_o() * 2);
+            i1 = nextInt(this.field_76815_a.func_175645_m(this.field_180294_c.func_177982_a(k, 0, l)).func_177956_o() * 2);
             this.field_76825_v.func_180709_b(this.field_76815_a, this.field_76813_b, this.field_180294_c.func_177982_a(k, i1, l));
         }
 
-        for (j = 0; j < 10; ++j)
+        for (j = 0; doGen && j < 10; ++j)
         {
             k = this.field_76813_b.nextInt(16) + 8;
             l = this.field_76813_b.nextInt(16) + 8;
-            i1 = this.field_76813_b.nextInt(this.field_76815_a.func_175645_m(this.field_180294_c.func_177982_a(k, 0, l)).func_177956_o() * 2);
+            i1 = nextInt(this.field_76815_a.func_175645_m(this.field_180294_c.func_177982_a(k, 0, l)).func_177956_o() * 2);
             this.field_76825_v.func_180709_b(this.field_76815_a, this.field_76813_b, this.field_180294_c.func_177982_a(k, i1, l));
         }
 
-        if (this.field_76813_b.nextInt(32) == 0)
+        doGen = TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, PUMPKIN);
+        if (doGen && this.field_76813_b.nextInt(32) == 0)
         {
             j = this.field_76813_b.nextInt(16) + 8;
             k = this.field_76813_b.nextInt(16) + 8;
-            l = this.field_76813_b.nextInt(this.field_76815_a.func_175645_m(this.field_180294_c.func_177982_a(j, 0, k)).func_177956_o() * 2);
+            l = nextInt(this.field_76815_a.func_175645_m(this.field_180294_c.func_177982_a(j, 0, k)).func_177956_o() * 2);
             (new WorldGenPumpkin()).func_180709_b(this.field_76815_a, this.field_76813_b, this.field_180294_c.func_177982_a(j, l, k));
         }
 
-        for (j = 0; j < this.field_76800_F; ++j)
+        doGen = TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, CACTUS);
+        for (j = 0; doGen && j < this.field_76800_F; ++j)
         {
             k = this.field_76813_b.nextInt(16) + 8;
             l = this.field_76813_b.nextInt(16) + 8;
-            i1 = this.field_76813_b.nextInt(this.field_76815_a.func_175645_m(this.field_180294_c.func_177982_a(k, 0, l)).func_177956_o() * 2);
+            i1 = nextInt(this.field_76815_a.func_175645_m(this.field_180294_c.func_177982_a(k, 0, l)).func_177956_o() * 2);
             this.field_76824_w.func_180709_b(this.field_76815_a, this.field_76813_b, this.field_180294_c.func_177982_a(k, i1, l));
         }
 
@@ -316,18 +335,22 @@
         {
             BlockPos blockpos1;
 
-            for (j = 0; j < 50; ++j)
+            doGen = TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, LAKE_WATER);
+            for (j = 0; doGen && j < 50; ++j)
             {
                 blockpos1 = this.field_180294_c.func_177982_a(this.field_76813_b.nextInt(16) + 8, this.field_76813_b.nextInt(this.field_76813_b.nextInt(248) + 8), this.field_76813_b.nextInt(16) + 8);
                 (new WorldGenLiquids(Blocks.field_150358_i)).func_180709_b(this.field_76815_a, this.field_76813_b, blockpos1);
             }
 
-            for (j = 0; j < 20; ++j)
+            doGen = TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, LAKE_LAVA);
+            for (j = 0; doGen && j < 20; ++j)
             {
                 blockpos1 = this.field_180294_c.func_177982_a(this.field_76813_b.nextInt(16) + 8, this.field_76813_b.nextInt(this.field_76813_b.nextInt(this.field_76813_b.nextInt(240) + 8) + 8), this.field_76813_b.nextInt(16) + 8);
                 (new WorldGenLiquids(Blocks.field_150356_k)).func_180709_b(this.field_76815_a, this.field_76813_b, blockpos1);
             }
         }
+
+        MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Post(field_76815_a, field_76813_b, field_180294_c));
     }
 
     protected void func_76795_a(int p_76795_1_, WorldGenerator p_76795_2_, int p_76795_3_, int p_76795_4_)
@@ -370,16 +393,35 @@
 
     protected void func_76797_b()
     {
+        MinecraftForge.ORE_GEN_BUS.post(new OreGenEvent.Pre(field_76815_a, field_76813_b, field_180294_c));
+        if (TerrainGen.generateOre(field_76815_a, field_76813_b, field_76823_i, field_180294_c, DIRT))
         this.func_76795_a(this.field_180293_d.field_177790_J, this.field_76823_i, this.field_180293_d.field_177791_K, this.field_180293_d.field_177784_L);
+        if (TerrainGen.generateOre(field_76815_a, field_76813_b, field_76820_j, field_180294_c, GRAVEL))
         this.func_76795_a(this.field_180293_d.field_177786_N, this.field_76820_j, this.field_180293_d.field_177787_O, this.field_180293_d.field_177797_P);
+        if (TerrainGen.generateOre(field_76815_a, field_76813_b, field_180297_k, field_180294_c, DIORITE))
         this.func_76795_a(this.field_180293_d.field_177795_V, this.field_180297_k, this.field_180293_d.field_177794_W, this.field_180293_d.field_177801_X);
+        if (TerrainGen.generateOre(field_76815_a, field_76813_b, field_180296_j, field_180294_c, GRANITE))
         this.func_76795_a(this.field_180293_d.field_177799_R, this.field_180296_j, this.field_180293_d.field_177798_S, this.field_180293_d.field_177793_T);
+        if (TerrainGen.generateOre(field_76815_a, field_76813_b, field_180295_l, field_180294_c, ANDESITE))
         this.func_76795_a(this.field_180293_d.field_177802_Z, this.field_180295_l, this.field_180293_d.field_177846_aa, this.field_180293_d.field_177847_ab);
+        if (TerrainGen.generateOre(field_76815_a, field_76813_b, field_76821_k, field_180294_c, COAL))
         this.func_76795_a(this.field_180293_d.field_177845_ad, this.field_76821_k, this.field_180293_d.field_177851_ae, this.field_180293_d.field_177853_af);
+        if (TerrainGen.generateOre(field_76815_a, field_76813_b, field_76818_l, field_180294_c, IRON))
         this.func_76795_a(this.field_180293_d.field_177849_ah, this.field_76818_l, this.field_180293_d.field_177832_ai, this.field_180293_d.field_177834_aj);
+        if (TerrainGen.generateOre(field_76815_a, field_76813_b, field_76819_m, field_180294_c, GOLD))
         this.func_76795_a(this.field_180293_d.field_177830_al, this.field_76819_m, this.field_180293_d.field_177840_am, this.field_180293_d.field_177842_an);
+        if (TerrainGen.generateOre(field_76815_a, field_76813_b, field_180299_p, field_180294_c, REDSTONE))
         this.func_76795_a(this.field_180293_d.field_177838_ap, this.field_180299_p, this.field_180293_d.field_177818_aq, this.field_180293_d.field_177816_ar);
+        if (TerrainGen.generateOre(field_76815_a, field_76813_b, field_180298_q, field_180294_c, DIAMOND))
         this.func_76795_a(this.field_180293_d.field_177812_at, this.field_180298_q, this.field_180293_d.field_177826_au, this.field_180293_d.field_177824_av);
+        if (TerrainGen.generateOre(field_76815_a, field_76813_b, field_76831_p, field_180294_c, LAPIS))
         this.func_76793_b(this.field_180293_d.field_177820_ax, this.field_76831_p, this.field_180293_d.field_177807_ay, this.field_180293_d.field_177805_az);
+        MinecraftForge.ORE_GEN_BUS.post(new OreGenEvent.Post(field_76815_a, field_76813_b, field_180294_c));
     }
+
+    private int nextInt(int i) { //Safety wrapper to prevent exceptions.
+        if (i <= 1)
+            return 0;
+        return this.field_76813_b.nextInt(i);
+   }
 }
