    001package net.minecraft.block;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import java.util.List;
    006import net.minecraft.block.material.Material;
    007import net.minecraft.client.renderer.texture.IconRegister;
    008import net.minecraft.creativetab.CreativeTabs;
    009import net.minecraft.item.ItemStack;
    010import net.minecraft.util.Icon;
    011import net.minecraft.world.World;
    012
    013public class BlockQuartz extends Block
    014{
    015    public static final String[] field_94420_a = new String[] {"default", "chiseled", "lines"};
    016    private static final String[] field_94418_b = new String[] {"quartzblock_side", "quartzblock_chiseled", "quartzblock_lines", null, null};
    017    @SideOnly(Side.CLIENT)
    018    private Icon[] field_94419_c;
    019    @SideOnly(Side.CLIENT)
    020    private Icon field_94414_cO;
    021    @SideOnly(Side.CLIENT)
    022    private Icon field_94415_cP;
    023    @SideOnly(Side.CLIENT)
    024    private Icon field_94416_cQ;
    025    @SideOnly(Side.CLIENT)
    026    private Icon field_94417_cR;
    027
    028    public BlockQuartz(int par1)
    029    {
    030        super(par1, Material.rock);
    031        this.setCreativeTab(CreativeTabs.tabBlock);
    032    }
    033
    034    @SideOnly(Side.CLIENT)
    035
    036    /**
    037     * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
    038     */
    039    public Icon getBlockTextureFromSideAndMetadata(int par1, int par2)
    040    {
    041        if (par2 != 2 && par2 != 3 && par2 != 4)
    042        {
    043            if (par1 != 1 && (par1 != 0 || par2 != 1))
    044            {
    045                if (par1 == 0)
    046                {
    047                    return this.field_94417_cR;
    048                }
    049                else
    050                {
    051                    if (par2 < 0 || par2 >= this.field_94419_c.length)
    052                    {
    053                        par2 = 0;
    054                    }
    055
    056                    return this.field_94419_c[par2];
    057                }
    058            }
    059            else
    060            {
    061                return par2 == 1 ? this.field_94414_cO : this.field_94416_cQ;
    062            }
    063        }
    064        else
    065        {
    066            return par2 == 2 && (par1 == 1 || par1 == 0) ? this.field_94415_cP : (par2 == 3 && (par1 == 5 || par1 == 4) ? this.field_94415_cP : (par2 == 4 && (par1 == 2 || par1 == 3) ? this.field_94415_cP : this.field_94419_c[par2]));
    067        }
    068    }
    069
    070    /**
    071     * Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata
    072     */
    073    public int onBlockPlaced(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9)
    074    {
    075        if (par9 == 2)
    076        {
    077            switch (par5)
    078            {
    079                case 0:
    080                case 1:
    081                    par9 = 2;
    082                    break;
    083                case 2:
    084                case 3:
    085                    par9 = 4;
    086                    break;
    087                case 4:
    088                case 5:
    089                    par9 = 3;
    090            }
    091        }
    092
    093        return par9;
    094    }
    095
    096    /**
    097     * Determines the damage on the item the block drops. Used in cloth and wood.
    098     */
    099    public int damageDropped(int par1)
    100    {
    101        return par1 != 3 && par1 != 4 ? par1 : 2;
    102    }
    103
    104    /**
    105     * Returns an item stack containing a single instance of the current block type. 'i' is the block's subtype/damage
    106     * and is ignored for blocks which do not support subtypes. Blocks which cannot be harvested should return null.
    107     */
    108    protected ItemStack createStackedBlock(int par1)
    109    {
    110        return par1 != 3 && par1 != 4 ? super.createStackedBlock(par1) : new ItemStack(this.blockID, 1, 2);
    111    }
    112
    113    /**
    114     * The type of render function that is called for this block
    115     */
    116    public int getRenderType()
    117    {
    118        return 39;
    119    }
    120
    121    @SideOnly(Side.CLIENT)
    122
    123    /**
    124     * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
    125     */
    126    public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
    127    {
    128        par3List.add(new ItemStack(par1, 1, 0));
    129        par3List.add(new ItemStack(par1, 1, 1));
    130        par3List.add(new ItemStack(par1, 1, 2));
    131    }
    132
    133    @SideOnly(Side.CLIENT)
    134    public void func_94332_a(IconRegister par1IconRegister)
    135    {
    136        this.field_94419_c = new Icon[field_94418_b.length];
    137
    138        for (int i = 0; i < this.field_94419_c.length; ++i)
    139        {
    140            if (field_94418_b[i] == null)
    141            {
    142                this.field_94419_c[i] = this.field_94419_c[i - 1];
    143            }
    144            else
    145            {
    146                this.field_94419_c[i] = par1IconRegister.func_94245_a(field_94418_b[i]);
    147            }
    148        }
    149
    150        this.field_94416_cQ = par1IconRegister.func_94245_a("quartzblock_top");
    151        this.field_94414_cO = par1IconRegister.func_94245_a("quartzblock_chiseled_top");
    152        this.field_94415_cP = par1IconRegister.func_94245_a("quartzblock_lines_top");
    153        this.field_94417_cR = par1IconRegister.func_94245_a("quartzblock_bottom");
    154    }
    155}