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