 +        		}
 +        	}
 +        }
-         while (this.field_146253_i.size() > 100)
-         {
-             this.field_146253_i.remove(this.field_146253_i.size() - 1);
++        while (this.field_146253_i.size() > 100)
++        {
++            this.field_146253_i.remove(this.field_146253_i.size() - 1);
++        }
++
++        if (!p_146237_4_)
++        {
++            this.chatLines.add(0, new ChatLine(p_146237_3_, p_146237_1_, p_146237_2_));
++
++            while (this.chatLines.size() > 100)
++            {
++                this.chatLines.remove(this.chatLines.size() - 1);
++            }
++        }
++    }
++
++    public void refreshChat()
++    {
++        this.field_146253_i.clear();
++        this.resetScroll();
++
++        for (int var1 = this.chatLines.size() - 1; var1 >= 0; --var1)
++        {
++            ChatLine var2 = (ChatLine)this.chatLines.get(var1);
++            this.setChatLine(var2.getChatComponent(), var2.getChatLineID(), var2.getUpdatedCounter(), true);
++        }
++    }
++
++    /**
++     * Gets the list of messages previously sent through the chat GUI
++     */
++    public List getSentMessages()
++    {
++        return this.sentMessages;
++    }
++
++    /**
++     * Adds this string to the list of sent messages, for recall using the up/down arrow keys
++     */
++    public void addToSentMessages(String p_146239_1_)
++    {
++        if (this.sentMessages.isEmpty() || !((String)this.sentMessages.get(this.sentMessages.size() - 1)).equals(p_146239_1_))
++        {
++            this.sentMessages.add(p_146239_1_);
++        }
++    }
++
++    /**
++     * Resets the chat scroll (executed when the GUI is closed, among others)
++     */
++    public void resetScroll()
++    {
++        this.scrollPos = 0;
++        this.isScrolled = false;
++    }
++
++    /**
++     * Scrolls the chat by the given number of lines.
++     */
++    public void scroll(int p_146229_1_)
++    {
++        this.scrollPos += p_146229_1_;
++        int var2 = this.field_146253_i.size();
++
++        if (this.scrollPos > var2 - this.getLineCount())
++        {
++            this.scrollPos = var2 - this.getLineCount();
++        }
++
++        if (this.scrollPos <= 0)
++        {
++            this.scrollPos = 0;
++            this.isScrolled = false;
++        }
++    }
++
++    /**
++     * Gets the chat component under the mouse
++     */
++    public IChatComponent getChatComponent(int p_146236_1_, int p_146236_2_)
++    {
++        if (!this.getChatOpen())
++        {
++            return null;
++        }
++        else
++        {
++            ScaledResolution var3 = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight);
++            int var4 = var3.getScaleFactor();
++            float var5 = this.getChatScale();
++            int var6 = p_146236_1_ / var4 - 3;
++            int var7 = p_146236_2_ / var4 - 27;
++            var6 = MathHelper.floor_float((float)var6 / var5);
++            var7 = MathHelper.floor_float((float)var7 / var5);
++
++            if (var6 >= 0 && var7 >= 0)
++            {
++                int var8 = Math.min(this.getLineCount(), this.field_146253_i.size());
++
++                if (var6 <= MathHelper.floor_float((float)this.getChatWidth() / this.getChatScale()) && var7 < this.mc.fontRendererObj.FONT_HEIGHT * var8 + var8)
++                {
++                    int var9 = var7 / this.mc.fontRendererObj.FONT_HEIGHT + this.scrollPos;
++
++                    if (var9 >= 0 && var9 < this.field_146253_i.size())
++                    {
++                        ChatLine var10 = (ChatLine)this.field_146253_i.get(var9);
++                        int var11 = 0;
++                        Iterator var12 = var10.getChatComponent().iterator();
++
++                        while (var12.hasNext())
++                        {
++                            IChatComponent var13 = (IChatComponent)var12.next();
++
++                            if (var13 instanceof ChatComponentText)
++                            {
++                                var11 += this.mc.fontRendererObj.getStringWidth(GuiUtilRenderComponents.func_178909_a(((ChatComponentText)var13).getChatComponentText_TextValue(), false));
++
++                                if (var11 > var6)
++                                {
++                                    return var13;
++                                }
++                            }
++                        }
++                    }
++
++                    return null;
++                }
++                else
++                {
++                    return null;
++                }
++            }
++            else
++            {
++                return null;
++            }
++        }
++    }
++
++    /**
++     * Returns true if the chat GUI is open
++     */
++    public boolean getChatOpen()
++    {
++        return this.mc.currentScreen instanceof GuiChat;
++    }
++
++    /**
++     * finds and deletes a Chat line by ID
++     */
++    public void deleteChatLine(int p_146242_1_)
++    {
++        Iterator var2 = this.field_146253_i.iterator();
++        ChatLine var3;
++
++        while (var2.hasNext())
++        {
++            var3 = (ChatLine)var2.next();
++
++            if (var3.getChatLineID() == p_146242_1_)
++            {
++                var2.remove();
++            }
++        }
++
++        var2 = this.chatLines.iterator();
++
++        while (var2.hasNext())
++        {
++            var3 = (ChatLine)var2.next();
++
++            if (var3.getChatLineID() == p_146242_1_)
++            {
++                var2.remove();
++                break;
++            }
++        }
++    }
++
++    public int getChatWidth()
++    {
++        return calculateChatboxWidth(this.mc.gameSettings.chatWidth);
++    }
++
++    public int getChatHeight()
++    {
++        return calculateChatboxHeight(this.getChatOpen() ? this.mc.gameSettings.chatHeightFocused : this.mc.gameSettings.chatHeightUnfocused);
++    }
++
++    /**
++     * Returns the chatscale from mc.gameSettings.chatScale
++     */
++    public float getChatScale()
++    {
++        return this.mc.gameSettings.chatScale;
++    }
++
++    public static int calculateChatboxWidth(float p_146233_0_)
++    {
++        short var1 = 320;
++        byte var2 = 40;
++        return MathHelper.floor_float(p_146233_0_ * (float)(var1 - var2) + (float)var2);
++    }
++
++    public static int calculateChatboxHeight(float p_146243_0_)
++    {
++        short var1 = 180;
++        byte var2 = 20;
++        return MathHelper.floor_float(p_146243_0_ * (float)(var1 - var2) + (float)var2);
++    }
++
++    public int getLineCount()
++    {
++        return this.getChatHeight() / 9;
++    }
++}
 diff --git a/src/net/minecraft/client/gui/GuiOptionButton.java b/src/net/minecraft/client/gui/GuiOptionButton.java
 index 833c342..91e7357 100644
 --- a/src/net/minecraft/client/gui/GuiOptionButton.java

 .../minecraft/client/gui/GuiMemoryErrorScreen.java |    2 +
 src/net/minecraft/client/gui/GuiMerchant.java      |    4 +
 src/net/minecraft/client/gui/GuiMultiplayer.java   |  197 +-
 src/net/minecraft/client/gui/GuiNewChat.java       |   42 +-
 src/net/minecraft/client/gui/GuiOptionButton.java  |    1 +
 src/net/minecraft/client/gui/GuiOptionSlider.java  |    1 +
 src/net/minecraft/client/gui/GuiOptions.java       |    2 +

 .../minecraft/world/gen/ChunkProviderServer.java   |    3 +
 src/net/minecraft/world/gen/layer/GenLayer.java    |    1 +
 .../world/gen/structure/MapGenStructure.java       |    2 +
 202 files changed, 10781 insertions(+), 9130 deletions(-)

diff --git a/src/net/minecraft/block/Block.java b/src/net/minecraft/block/Block.java
index 5c07aa4..c8adf19 100644
