001package net.minecraft.block;
002
003import cpw.mods.fml.relauncher.Side;
004import cpw.mods.fml.relauncher.SideOnly;
005import java.util.List;
006import java.util.Random;
007import net.minecraft.block.material.Material;
008import net.minecraft.client.renderer.texture.IconRegister;
009import net.minecraft.creativetab.CreativeTabs;
010import net.minecraft.entity.monster.EntitySilverfish;
011import net.minecraft.item.ItemStack;
012import net.minecraft.util.Icon;
013import net.minecraft.world.World;
014
015public class BlockSilverfish extends Block
016{
017    /** Block names that can be a silverfish stone. */
018    public static final String[] silverfishStoneTypes = new String[] {"stone", "cobble", "brick"};
019
020    public BlockSilverfish(int par1)
021    {
022        super(par1, Material.clay);
023        this.setHardness(0.0F);
024        this.setCreativeTab(CreativeTabs.tabDecorations);
025    }
026
027    @SideOnly(Side.CLIENT)
028
029    /**
030     * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
031     */
032    public Icon getBlockTextureFromSideAndMetadata(int par1, int par2)
033    {
034        return par2 == 1 ? Block.cobblestone.getBlockTextureFromSide(par1) : (par2 == 2 ? Block.stoneBrick.getBlockTextureFromSide(par1) : Block.stone.getBlockTextureFromSide(par1));
035    }
036
037    @SideOnly(Side.CLIENT)
038    public void func_94332_a(IconRegister par1IconRegister) {}
039
040    /**
041     * Called right before the block is destroyed by a player.  Args: world, x, y, z, metaData
042     */
043    public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5)
044    {
045        if (!par1World.isRemote)
046        {
047            EntitySilverfish entitysilverfish = new EntitySilverfish(par1World);
048            entitysilverfish.setLocationAndAngles((double)par2 + 0.5D, (double)par3, (double)par4 + 0.5D, 0.0F, 0.0F);
049            par1World.spawnEntityInWorld(entitysilverfish);
050            entitysilverfish.spawnExplosionParticle();
051        }
052
053        super.onBlockDestroyedByPlayer(par1World, par2, par3, par4, par5);
054    }
055
056    /**
057     * Returns the quantity of items to drop on block destruction.
058     */
059    public int quantityDropped(Random par1Random)
060    {
061        return 0;
062    }
063
064    /**
065     * Gets the blockID of the block this block is pretending to be according to this block's metadata.
066     */
067    public static boolean getPosingIdByMetadata(int par0)
068    {
069        return par0 == Block.stone.blockID || par0 == Block.cobblestone.blockID || par0 == Block.stoneBrick.blockID;
070    }
071
072    /**
073     * Returns the metadata to use when a Silverfish hides in the block. Sets the block to BlockSilverfish with this
074     * metadata. It changes the displayed texture client side to look like a normal block.
075     */
076    public static int getMetadataForBlockType(int par0)
077    {
078        return par0 == Block.cobblestone.blockID ? 1 : (par0 == Block.stoneBrick.blockID ? 2 : 0);
079    }
080
081    /**
082     * Returns an item stack containing a single instance of the current block type. 'i' is the block's subtype/damage
083     * and is ignored for blocks which do not support subtypes. Blocks which cannot be harvested should return null.
084     */
085    protected ItemStack createStackedBlock(int par1)
086    {
087        Block block = Block.stone;
088
089        if (par1 == 1)
090        {
091            block = Block.cobblestone;
092        }
093
094        if (par1 == 2)
095        {
096            block = Block.stoneBrick;
097        }
098
099        return new ItemStack(block);
100    }
101
102    /**
103     * Get the block's damage value (for use with pick block).
104     */
105    public int getDamageValue(World par1World, int par2, int par3, int par4)
106    {
107        return par1World.getBlockMetadata(par2, par3, par4);
108    }
109
110    @SideOnly(Side.CLIENT)
111
112    /**
113     * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
114     */
115    public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
116    {
117        for (int j = 0; j < 3; ++j)
118        {
119            par3List.add(new ItemStack(par1, 1, j));
120        }
121    }
122}