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