001    package net.minecraft.src;
002    
003    public class BlockNote extends BlockContainer
004    {
005        public BlockNote(int par1)
006        {
007            super(par1, 74, Material.wood);
008            this.setCreativeTab(CreativeTabs.tabRedstone);
009        }
010    
011        /**
012         * Returns the block texture based on the side being looked at.  Args: side
013         */
014        public int getBlockTextureFromSide(int par1)
015        {
016            return this.blockIndexInTexture;
017        }
018    
019        /**
020         * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
021         * their own) Args: x, y, z, neighbor blockID
022         */
023        public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
024        {
025            if (par5 > 0)
026            {
027                boolean var6 = par1World.isBlockIndirectlyGettingPowered(par2, par3, par4);
028                TileEntityNote var7 = (TileEntityNote)par1World.getBlockTileEntity(par2, par3, par4);
029    
030                if (var7 != null && var7.previousRedstoneState != var6)
031                {
032                    if (var6)
033                    {
034                        var7.triggerNote(par1World, par2, par3, par4);
035                    }
036    
037                    var7.previousRedstoneState = var6;
038                }
039            }
040        }
041    
042        /**
043         * Called upon block activation (right click on the block.)
044         */
045        public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
046        {
047            if (par1World.isRemote)
048            {
049                return true;
050            }
051            else
052            {
053                TileEntityNote var10 = (TileEntityNote)par1World.getBlockTileEntity(par2, par3, par4);
054    
055                if (var10 != null)
056                {
057                    var10.changePitch();
058                    var10.triggerNote(par1World, par2, par3, par4);
059                }
060    
061                return true;
062            }
063        }
064    
065        /**
066         * Called when the block is clicked by a player. Args: x, y, z, entityPlayer
067         */
068        public void onBlockClicked(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
069        {
070            if (!par1World.isRemote)
071            {
072                TileEntityNote var6 = (TileEntityNote)par1World.getBlockTileEntity(par2, par3, par4);
073    
074                if (var6 != null)
075                {
076                    var6.triggerNote(par1World, par2, par3, par4);
077                }
078            }
079        }
080    
081        /**
082         * Returns a new instance of a block's tile entity class. Called on placing the block.
083         */
084        public TileEntity createNewTileEntity(World par1World)
085        {
086            return new TileEntityNote();
087        }
088    
089        /**
090         * Called when the block receives a BlockEvent - see World.addBlockEvent. By default, passes it on to the tile
091         * entity at this location. Args: world, x, y, z, blockID, EventID, event parameter
092         */
093        public void onBlockEventReceived(World par1World, int par2, int par3, int par4, int par5, int par6)
094        {
095            float var7 = (float)Math.pow(2.0D, (double)(par6 - 12) / 12.0D);
096            String var8 = "harp";
097    
098            if (par5 == 1)
099            {
100                var8 = "bd";
101            }
102    
103            if (par5 == 2)
104            {
105                var8 = "snare";
106            }
107    
108            if (par5 == 3)
109            {
110                var8 = "hat";
111            }
112    
113            if (par5 == 4)
114            {
115                var8 = "bassattack";
116            }
117    
118            par1World.playSoundEffect((double)par2 + 0.5D, (double)par3 + 0.5D, (double)par4 + 0.5D, "note." + var8, 3.0F, var7);
119            par1World.spawnParticle("note", (double)par2 + 0.5D, (double)par3 + 1.2D, (double)par4 + 0.5D, (double)par6 / 24.0D, 0.0D, 0.0D);
120        }
121    }