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