// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode fieldsfirst 

package net.minecraft.server;

import java.util.Random;

// Referenced classes of package net.minecraft.src:
//            Block, Material, World, BlockGrass, 
//            mod_decor, Item, AxisAlignedBB

public class flgar extends Block
{

    protected flgar(int i, int j)
    {
        super(i, Material.PLANT);
        textureId = j;
        a(true);
        float f = 0.2F;
        a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 3F, 0.5F + f);
    }

    public boolean canPlace(World world, int i, int j, int k)
    {
        return super.canPlace(world, i, j, k) && canThisPlantGrowOnThisBlockID(world.getTypeId(i, j - 1, k));
    }

    protected boolean canThisPlantGrowOnThisBlockID(int i)
    {
        return i == Block.GRASS.id || i == Block.DIRT.id || i == Block.SOIL.id;
    }

    public void doPhysics(World world, int i, int j, int k, int l)
    {
        super.doPhysics(world, i, j, k, l);
        checkFlowerChange(world, i, j, k);
    }

    public void a(World world, int i, int j, int k, Random random)
    {
        byte byte0 = 4;
        int l = 5;
        for(int i1 = i - byte0; i1 <= i + byte0; i1++)
        {
            for(int k1 = k - byte0; k1 <= k + byte0; k1++)
            {
                for(int i2 = j - 1; i2 <= j + 1; i2++)
                {
                    if(world.getTypeId(i1, i2, k1) == id && --l <= 0)
                    {
                        return;
                    }
                }

            }

        }

        int j1 = (i + random.nextInt(3)) - 1;
        int l1 = (j + random.nextInt(2)) - random.nextInt(2);
        int j2 = (k + random.nextInt(3)) - 1;
        for(int k2 = 0; k2 < 4; k2++)
        {
            if(world.isEmpty(j1, l1, j2) && f(world, j1, l1, j2))
            {
                i = j1;
                j = l1;
                k = j2;
            }
            j1 = (i + random.nextInt(3)) - 1;
            l1 = (j + random.nextInt(2)) - random.nextInt(2);
            j2 = (k + random.nextInt(3)) - 1;
        }

        if(world.isEmpty(j1, l1, j2) && f(world, j1, l1, j2) && random.nextInt(10) == 0)
        {
            world.setTypeId(j1, l1, j2, mod_decor.flgar.id);
        }
        checkFlowerChange(world, i, j, k);
    }

    protected final void checkFlowerChange(World world, int i, int j, int k)
    {
        if(!f(world, i, j, k))
        {
            b(world, i, j, k, world.getData(i, j, k), 0);
            world.setTypeId(i, j, k, 0);
        }
    }

    public boolean f(World world, int i, int j, int k)
    {
        return (world.k(i, j, k) >= 8 || world.isChunkLoaded(i, j, k)) && canThisPlantGrowOnThisBlockID(world.getTypeId(i, j - 1, k));
    }

    public AxisAlignedBB e(World world, int i, int j, int k)
    {
        return null;
    }

    public int getDropType(int i, Random random, int j)
    {
        return mod_decor.flgarItem.id;
    }

    public boolean a()
    {
        return false;
    }

    public boolean renderAsNormalBlock()
    {
        return false;
    }

    public int c()
    {
        return 1;
    }
}
