package net.glowstone.generator.decorators.overworld;

import java.util.Random;
import net.glowstone.generator.decorators.BlockDecorator;
import net.glowstone.generator.objects.TallGrass;
import org.bukkit.Chunk;
import org.bukkit.GrassSpecies;
import org.bukkit.World;
import org.bukkit.material.LongGrass;

public class TallGrassDecorator extends BlockDecorator {

    private double fernDensity;

    public final void setFernDensity(double fernDensity) {
        this.fernDensity = fernDensity;
    }

    @Override
    public void decorate(World world, Random random, Chunk source) {
        int sourceX = (source.getX() << 4) + random.nextInt(16);
        int sourceZ = (source.getZ() << 4) + random.nextInt(16);
        int sourceY = random.nextInt(Math.abs(world.getHighestBlockYAt(sourceX, sourceZ) << 1));

        // the grass species can change on each decoration pass
        GrassSpecies species = GrassSpecies.NORMAL;
        if (fernDensity > 0 && random.nextFloat() < fernDensity) {
            species = GrassSpecies.FERN_LIKE;
        }
        new TallGrass(new LongGrass(species)).generate(world, random, sourceX, sourceY, sourceZ);
    }
}

@@ -728,42 +728,19 @@
 int 
-sourceY = random.nextInt(Math.abs(
+topBlock = 
 worl
@@ -777,16 +777,184 @@
 sourceZ)
+;%0A        if (topBlock == 0) %7B%0A            // Nothing to do if this column is empty%0A            return;%0A        %7D%0A        int sourceY = random.nextInt(Math.abs(topBlock
  %3C%3C 1));

Fix TallGrassDecorator exception if there's a hole in bedrock (#631)