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