    001    package net.minecraft.src;
    002
    003    import java.util.Random;
    004
    005    public class BlockCommandBlock extends BlockContainer
    006    {
    007        public BlockCommandBlock(int par1)
    008        {
    009            super(par1, 184, Material.iron);
    010        }
    011
    012        /**
    013         * Returns a new instance of a block's tile entity class. Called on placing the block.
    014         */
    015        public TileEntity createNewTileEntity(World par1World)
    016        {
    017            return new TileEntityCommandBlock();
    018        }
    019
    020        /**
    021         * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
    022         * their own) Args: x, y, z, neighbor blockID
    023         */
    024        public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
    025        {
    026            if (!par1World.isRemote)
    027            {
    028                boolean var6 = par1World.isBlockIndirectlyGettingPowered(par2, par3, par4);
    029                int var7 = par1World.getBlockMetadata(par2, par3, par4);
    030                boolean var8 = (var7 & 1) != 0;
    031
    032                if (var6 && !var8)
    033                {
    034                    par1World.setBlockMetadata(par2, par3, par4, var7 | 1);
    035                    par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate());
    036                }
    037                else if (!var6 && var8)
    038                {
    039                    par1World.setBlockMetadata(par2, par3, par4, var7 & -2);
    040                }
    041            }
    042        }
    043
    044        /**
    045         * Ticks the block if it's been scheduled
    046         */
    047        public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
    048        {
    049            TileEntity var6 = par1World.getBlockTileEntity(par2, par3, par4);
    050
    051            if (var6 != null && var6 instanceof TileEntityCommandBlock)
    052            {
    053                ((TileEntityCommandBlock)var6).executeCommandOnPowered(par1World);
    054            }
    055        }
    056
    057        /**
    058         * How many world ticks before ticking
    059         */
    060        public int tickRate()
    061        {
    062            return 1;
    063        }
    064
    065        /**
    066         * Called upon block activation (right click on the block.)
    067         */
    068        public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
    069        {
    070            TileEntityCommandBlock var10 = (TileEntityCommandBlock)par1World.getBlockTileEntity(par2, par3, par4);
    071
    072            if (var10 != null)
    073            {
    074                par5EntityPlayer.displayGUIEditSign(var10);
    075            }
    076
    077            return true;
    078        }
    079    }