    001    package net.minecraft.src;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005    import net.minecraft.server.MinecraftServer;
    006
    007    public class TileEntityCommandBlock extends TileEntity implements ICommandSender
    008    {
    009        private String field_82354_a = "";
    010
    011        public void func_82352_b(String par1Str)
    012        {
    013            this.field_82354_a = par1Str;
    014            this.onInventoryChanged();
    015        }
    016
    017        @SideOnly(Side.CLIENT)
    018        public String func_82353_c()
    019        {
    020            return this.field_82354_a;
    021        }
    022
    023        public void func_82351_a(World par1World)
    024        {
    025            if (!par1World.isRemote)
    026            {
    027                MinecraftServer var2 = MinecraftServer.getServer();
    028
    029                if (var2 != null && var2.func_82356_Z())
    030                {
    031                    ICommandManager var3 = var2.getCommandManager();
    032                    var3.executeCommand(this, this.field_82354_a);
    033                }
    034            }
    035        }
    036
    037        /**
    038         * Gets the name of this command sender (usually username, but possibly "Rcon")
    039         */
    040        public String getCommandSenderName()
    041        {
    042            return "@";
    043        }
    044
    045        public void sendChatToPlayer(String par1Str) {}
    046
    047        /**
    048         * Returns true if the command sender is allowed to use the given command.
    049         */
    050        public boolean canCommandSenderUseCommand(int par1, String par2Str)
    051        {
    052            return par1 <= 2;
    053        }
    054
    055        /**
    056         * Translates and formats the given string key with the given arguments.
    057         */
    058        public String translateString(String par1Str, Object ... par2ArrayOfObj)
    059        {
    060            return par1Str;
    061        }
    062
    063        /**
    064         * Writes a tile entity to NBT.
    065         */
    066        public void writeToNBT(NBTTagCompound par1NBTTagCompound)
    067        {
    068            super.writeToNBT(par1NBTTagCompound);
    069            par1NBTTagCompound.setString("Command", this.field_82354_a);
    070        }
    071
    072        /**
    073         * Reads a tile entity from NBT.
    074         */
    075        public void readFromNBT(NBTTagCompound par1NBTTagCompound)
    076        {
    077            super.readFromNBT(par1NBTTagCompound);
    078            this.field_82354_a = par1NBTTagCompound.getString("Command");
    079        }
    080
    081        public ChunkCoordinates func_82114_b()
    082        {
    083            return new ChunkCoordinates(this.xCoord, this.yCoord, this.zCoord);
    084        }
    085
    086        /**
    087         * Overriden in a sign to provide the text.
    088         */
    089        public Packet getDescriptionPacket()
    090        {
    091            NBTTagCompound var1 = new NBTTagCompound();
    092            this.writeToNBT(var1);
    093            return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 2, var1);
    094        }
    095    }