    001package net.minecraft.world.gen.feature;
    002
    003import java.util.Random;
    004import net.minecraft.world.World;
    005
    006public abstract class WorldGenerator
    007{
    008    /**
    009     * Sets wither or not the generator should notify blocks of blocks it changes. When the world is first generated,
    010     * this is false, when saplings grow, this is true.
    011     */
    012    private final boolean doBlockNotify;
    013
    014    public WorldGenerator()
    015    {
    016        this.doBlockNotify = false;
    017    }
    018
    019    public WorldGenerator(boolean par1)
    020    {
    021        this.doBlockNotify = par1;
    022    }
    023
    024    public abstract boolean generate(World world, Random random, int i, int j, int k);
    025
    026    /**
    027     * Rescales the generator settings, only used in WorldGenBigTree
    028     */
    029    public void setScale(double par1, double par3, double par5) {}
    030
    031    /**
    032     * Sets the block without metadata in the world, notifying neighbors if enabled.
    033     */
    034    protected void setBlock(World par1World, int par2, int par3, int par4, int par5)
    035    {
    036        this.setBlockAndMetadata(par1World, par2, par3, par4, par5, 0);
    037    }
    038
    039    /**
    040     * Sets the block in the world, notifying neighbors if enabled.
    041     */
    042    protected void setBlockAndMetadata(World par1World, int par2, int par3, int par4, int par5, int par6)
    043    {
    044        if (this.doBlockNotify)
    045        {
    046            par1World.setBlock(par2, par3, par4, par5, par6, 3);
    047        }
    048        else
    049        {
    050            par1World.setBlock(par2, par3, par4, par5, par6, 2);
    051        }
    052    }
    053}