    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.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.displayGUIAnvil(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        /**
    134         * Updates the blocks bounds based on its current state. Args: world, x, y, z
    135         */
    136        public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
    137        {
    138            int var5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4) & 3;
    139
    140            if (var5 != 3 && var5 != 1)
    141            {
    142                this.setBlockBounds(0.125F, 0.0F, 0.0F, 0.875F, 1.0F, 1.0F);
    143            }
    144            else
    145            {
    146                this.setBlockBounds(0.0F, 0.0F, 0.125F, 1.0F, 1.0F, 0.875F);
    147            }
    148        }
    149
    150        @SideOnly(Side.CLIENT)
    151
    152        /**
    153         * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
    154         */
    155        public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
    156        {
    157            par3List.add(new ItemStack(par1, 1, 0));
    158            par3List.add(new ItemStack(par1, 1, 1));
    159            par3List.add(new ItemStack(par1, 1, 2));
    160        }
    161
    162        /**
    163         * Called when the falling block entity for this block is created
    164         */
    165        protected void onStartFalling(EntityFallingSand par1EntityFallingSand)
    166        {
    167            par1EntityFallingSand.func_82154_e(true);
    168        }
    169
    170        /**
    171         * Called when the falling block entity for this block hits the ground and turns back into a block
    172         */
    173        public void onFinishFalling(World par1World, int par2, int par3, int par4, int par5)
    174        {
    175            par1World.playAuxSFX(1022, par2, par3, par4, 0);
    176        }
    177
    178        @SideOnly(Side.CLIENT)
    179
    180        /**
    181         * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given
    182         * coordinates.  Args: blockAccess, x, y, z, side
    183         */
    184        public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
    185        {
    186            return true;
    187        }
    188    }