    001package net.minecraft.client.gui;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import net.minecraft.client.multiplayer.NetClientHandler;
    006import net.minecraft.network.packet.Packet0KeepAlive;
    007import net.minecraft.util.StringTranslate;
    008
    009@SideOnly(Side.CLIENT)
    010public class GuiDownloadTerrain extends GuiScreen
    011{
    012    /** Network object that downloads the terrain data. */
    013    private NetClientHandler netHandler;
    014
    015    /** Counts the number of screen updates. */
    016    private int updateCounter = 0;
    017
    018    public GuiDownloadTerrain(NetClientHandler par1NetClientHandler)
    019    {
    020        this.netHandler = par1NetClientHandler;
    021    }
    022
    023    /**
    024     * Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e).
    025     */
    026    protected void keyTyped(char par1, int par2) {}
    027
    028    /**
    029     * Adds the buttons (and other controls) to the screen in question.
    030     */
    031    public void initGui()
    032    {
    033        this.buttonList.clear();
    034    }
    035
    036    /**
    037     * Called from the main game loop to update the screen.
    038     */
    039    public void updateScreen()
    040    {
    041        ++this.updateCounter;
    042
    043        if (this.updateCounter % 20 == 0)
    044        {
    045            this.netHandler.addToSendQueue(new Packet0KeepAlive());
    046        }
    047
    048        if (this.netHandler != null)
    049        {
    050            this.netHandler.processReadPackets();
    051        }
    052    }
    053
    054    /**
    055     * Draws the screen and all the components in it.
    056     */
    057    public void drawScreen(int par1, int par2, float par3)
    058    {
    059        this.drawBackground(0);
    060        StringTranslate stringtranslate = StringTranslate.getInstance();
    061        this.drawCenteredString(this.fontRenderer, stringtranslate.translateKey("multiplayer.downloadingTerrain"), this.width / 2, this.height / 2 - 50, 16777215);
    062        super.drawScreen(par1, par2, par3);
    063    }
    064}