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.Random;
006    
007    public class BlockRedstoneLight extends Block
008    {
009        /** Whether this lamp block is the powered version. */
010        private final boolean powered;
011    
012        public BlockRedstoneLight(int par1, boolean par2)
013        {
014            super(par1, 211, Material.redstoneLight);
015            this.powered = par2;
016    
017            if (par2)
018            {
019                this.setLightValue(1.0F);
020                ++this.blockIndexInTexture;
021            }
022        }
023    
024        /**
025         * Called whenever the block is added into the world. Args: world, x, y, z
026         */
027        public void onBlockAdded(World par1World, int par2, int par3, int par4)
028        {
029            if (!par1World.isRemote)
030            {
031                if (this.powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
032                {
033                    par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, 4);
034                }
035                else if (!this.powered && par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
036                {
037                    par1World.setBlockWithNotify(par2, par3, par4, Block.redstoneLampActive.blockID);
038                }
039            }
040        }
041    
042        /**
043         * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
044         * their own) Args: x, y, z, neighbor blockID
045         */
046        public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
047        {
048            if (!par1World.isRemote)
049            {
050                if (this.powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
051                {
052                    par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, 4);
053                }
054                else if (!this.powered && par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
055                {
056                    par1World.setBlockWithNotify(par2, par3, par4, Block.redstoneLampActive.blockID);
057                }
058            }
059        }
060    
061        /**
062         * Ticks the block if it's been scheduled
063         */
064        public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
065        {
066            if (!par1World.isRemote && this.powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
067            {
068                par1World.setBlockWithNotify(par2, par3, par4, Block.redstoneLampIdle.blockID);
069            }
070        }
071    
072        /**
073         * Returns the ID of the items to drop on destruction.
074         */
075        public int idDropped(int par1, Random par2Random, int par3)
076        {
077            return Block.redstoneLampIdle.blockID;
078        }
079    
080        @SideOnly(Side.CLIENT)
081    
082        /**
083         * only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
084         */
085        public int idPicked(World par1World, int par2, int par3, int par4)
086        {
087            return Block.redstoneLampIdle.blockID;
088        }
089    }