// 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.src;

import java.util.Random;

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

public class Nastperskaver extends Block
{

    public Nastperskaver(int i, int j)
    {
        super(i, j, Material.cloth);
    }

    public int idDropped(int i, Random random)
    {
        return mod_decor.nastperskaver.blockID;
    }

    public int quantityDropped(Random random)
    {
        return 1;
    }

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

    public boolean isOpaqueCube()
    {
        return false;
    }

    public boolean renderAsNormalBlock()
    {
        return false;
    }

    public boolean canPlaceBlockOnSide(World world, int i, int j, int k, int l)
    {
        if(l == 2 && world.isBlockNormalCube(i, j, k + 1))
        {
            return true;
        }
        if(l == 3 && world.isBlockNormalCube(i, j, k - 1))
        {
            return true;
        }
        if(l == 4 && world.isBlockNormalCube(i + 1, j, k))
        {
            return true;
        } else
        {
            return l == 5 && world.isBlockNormalCube(i - 1, j, k);
        }
    }

    public boolean canPlaceBlockAt(World world, int i, int j, int k)
    {
        if(world.isBlockNormalCube(i - 1, j, k))
        {
            return true;
        }
        if(world.isBlockNormalCube(i + 1, j, k))
        {
            return true;
        }
        if(world.isBlockNormalCube(i, j, k - 1))
        {
            return true;
        } else
        {
            return world.isBlockNormalCube(i, j, k + 1);
        }
    }

    public void onBlockPlaced(World world, int i, int j, int k, int l)
    {
        int i1 = world.getBlockMetadata(i, j, k);
        int j1 = i1 & 8;
        i1 &= 7;
        if(l == 2 && world.isBlockNormalCube(i, j, k + 1))
        {
            i1 = 4;
        } else
        if(l == 3 && world.isBlockNormalCube(i, j, k - 1))
        {
            i1 = 3;
        } else
        if(l == 4 && world.isBlockNormalCube(i + 1, j, k))
        {
            i1 = 2;
        } else
        if(l == 5 && world.isBlockNormalCube(i - 1, j, k))
        {
            i1 = 1;
        } else
        {
            i1 = getOrientation(world, i, j, k);
        }
        world.setBlockMetadataWithNotify(i, j, k, i1 + j1);
    }

    private int getOrientation(World world, int i, int j, int k)
    {
        if(world.isBlockNormalCube(i - 1, j, k))
        {
            return 1;
        }
        if(world.isBlockNormalCube(i + 1, j, k))
        {
            return 2;
        }
        if(world.isBlockNormalCube(i, j, k - 1))
        {
            return 3;
        } else
        {
            return world.isBlockNormalCube(i, j, k + 1) ? 4 : 1;
        }
    }

    public void onNeighborBlockChange(World world, int i, int j, int k, int l)
    {
        if(func_305_h(world, i, j, k))
        {
            int i1 = world.getBlockMetadata(i, j, k) & 7;
            boolean flag = false;
            if(!world.isBlockNormalCube(i - 1, j, k) && i1 == 1)
            {
                flag = true;
            }
            if(!world.isBlockNormalCube(i + 1, j, k) && i1 == 2)
            {
                flag = true;
            }
            if(!world.isBlockNormalCube(i, j, k - 1) && i1 == 3)
            {
                flag = true;
            }
            if(!world.isBlockNormalCube(i, j, k + 1) && i1 == 4)
            {
                flag = true;
            }
            if(flag)
            {
                dropBlockAsItem(world, i, j, k, world.getBlockMetadata(i, j, k), 0);
                world.setBlockWithNotify(i, j, k, 0);
            }
        }
    }

    private boolean func_305_h(World world, int i, int j, int k)
    {
        if(!canPlaceBlockAt(world, i, j, k))
        {
            dropBlockAsItem(world, i, j, k, world.getBlockMetadata(i, j, k), 0);
            world.setBlockWithNotify(i, j, k, 0);
            return false;
        } else
        {
            return true;
        }
    }

    public void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, int i, int j, int k)
    {
        int l = iblockaccess.getBlockMetadata(i, j, k);
        int i1 = l & 7;
        boolean flag = (l & 8) > 0;
        float f = 0.0F;
        float f1 = 1.0F;
        float f2 = 0.5F;
        float f3 = 0.1F;
        if(flag)
        {
            f3 = 0.0625F;
        }
        if(i1 == 1)
        {
            setBlockBounds(0.0F, f, 0.5F - f2, f3, f1, 0.5F + f2);
        } else
        if(i1 == 2)
        {
            setBlockBounds(1.0F - f3, f, 0.5F - f2, 1.0F, f1, 0.5F + f2);
        } else
        if(i1 == 3)
        {
            setBlockBounds(0.5F - f2, f, 0.0F, 0.5F + f2, f1, f3);
        } else
        if(i1 == 4)
        {
            setBlockBounds(0.5F - f2, f, 1.0F - f3, 0.5F + f2, f1, 1.0F);
        }
    }

    public void setBlockBoundsForItemRender()
    {
        float f = 0.1F;
        float f1 = 0.6F;
        float f2 = 0.6F;
        setBlockBounds(0.5F - f, 0.5F - f1, 0.5F - f2, 0.5F + f, 0.5F + f1, 0.5F + f2);
    }
}
