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