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