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    
007    public class BlockAnvil extends BlockSand
008    {
009        /** List of types/statues the Anvil can be in. */
010        public static final String[] statuses = new String[] {"intact", "slightlyDamaged", "veryDamaged"};
011        public int field_82521_b = 0;
012    
013        protected BlockAnvil(int par1)
014        {
015            super(par1, 215, Material.anvil);
016            this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.75F, 1.0F);
017            this.setLightOpacity(0);
018            this.setCreativeTab(CreativeTabs.tabDecorations);
019        }
020    
021        /**
022         * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
023         */
024        public boolean renderAsNormalBlock()
025        {
026            return false;
027        }
028    
029        /**
030         * Is this block (a) opaque and (b) a full 1m cube?  This determines whether or not to render the shared face of two
031         * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
032         */
033        public boolean isOpaqueCube()
034        {
035            return false;
036        }
037    
038        /**
039         * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
040         */
041        public int getBlockTextureFromSideAndMetadata(int par1, int par2)
042        {
043            if (this.field_82521_b == 3 && par1 == 1)
044            {
045                int var3 = par2 >> 2;
046    
047                switch (var3)
048                {
049                    case 1:
050                        return this.blockIndexInTexture + 1;
051                    case 2:
052                        return this.blockIndexInTexture + 16 + 1;
053                    default:
054                        return this.blockIndexInTexture + 16;
055                }
056            }
057            else
058            {
059                return this.blockIndexInTexture;
060            }
061        }
062    
063        /**
064         * Returns the block texture based on the side being looked at.  Args: side
065         */
066        public int getBlockTextureFromSide(int par1)
067        {
068            return super.getBlockTextureFromSide(par1);
069        }
070    
071        /**
072         * Called when the block is placed in the world.
073         */
074        public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving)
075        {
076            int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
077            int var7 = par1World.getBlockMetadata(par2, par3, par4) >> 2;
078            ++var6;
079            var6 %= 4;
080    
081            if (var6 == 0)
082            {
083                par1World.setBlockMetadataWithNotify(par2, par3, par4, 2 | var7 << 2);
084            }
085    
086            if (var6 == 1)
087            {
088                par1World.setBlockMetadataWithNotify(par2, par3, par4, 3 | var7 << 2);
089            }
090    
091            if (var6 == 2)
092            {
093                par1World.setBlockMetadataWithNotify(par2, par3, par4, 0 | var7 << 2);
094            }
095    
096            if (var6 == 3)
097            {
098                par1World.setBlockMetadataWithNotify(par2, par3, par4, 1 | var7 << 2);
099            }
100        }
101    
102        /**
103         * Called upon block activation (right click on the block.)
104         */
105        public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
106        {
107            if (par1World.isRemote)
108            {
109                return true;
110            }
111            else
112            {
113                par5EntityPlayer.displayGUIAnvil(par2, par3, par4);
114                return true;
115            }
116        }
117    
118        /**
119         * The type of render function that is called for this block
120         */
121        public int getRenderType()
122        {
123            return 35;
124        }
125    
126        /**
127         * Determines the damage on the item the block drops. Used in cloth and wood.
128         */
129        public int damageDropped(int par1)
130        {
131            return par1 >> 2;
132        }
133    
134        @SideOnly(Side.CLIENT)
135    
136        /**
137         * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
138         */
139        public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
140        {
141            par3List.add(new ItemStack(par1, 1, 0));
142            par3List.add(new ItemStack(par1, 1, 1));
143            par3List.add(new ItemStack(par1, 1, 2));
144        }
145    
146        /**
147         * Called when the falling block entity for this block is created
148         */
149        protected void onStartFalling(EntityFallingSand par1EntityFallingSand)
150        {
151            par1EntityFallingSand.func_82154_e(true);
152        }
153    
154        /**
155         * Called when the falling block entity for this block hits the ground and turns back into a block
156         */
157        public void onFinishFalling(World par1World, int par2, int par3, int par4, int par5)
158        {
159            par1World.playAuxSFX(1022, par2, par3, par4, 0);
160        }
161    
162        @SideOnly(Side.CLIENT)
163    
164        /**
165         * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given
166         * coordinates.  Args: blockAccess, x, y, z, side
167         */
168        public boolean shouldSideBeRendered(IBlockAccess var1, int var2, int var3, int var4, int var5)
169        {
170            return true;
171        }
172    }