public void func_50031_b(String par1Str)
    {
        String var2 = "";
        String var3 = ChatAllowedCharacters.filerAllowedCharacters(par1Str);
        int var4 = this.field_50042_o < this.field_50048_p ? this.field_50042_o : this.field_50048_p;
        int var5 = this.field_50042_o < this.field_50048_p ? this.field_50048_p : this.field_50042_o;
        int var6 = this.maxStringLength - this.text.length() - (var4 - this.field_50048_p);
        boolean var7 = false;

        if (this.text.length() > 0)
        {
            var2 = var2 + this.text.substring(0, var4);
        }

        int var8;

        if (var6 < var3.length())
        {
            var2 = var2 + var3.substring(0, var6);
            var8 = var6;
        }
        else
        {
            var2 = var2 + var3;
            var8 = var3.length();
        }

        if (this.text.length() > 0 && var5 < this.text.length())
        {
            var2 = var2 + this.text.substring(var5);
        }

        this.text = var2;
        this.func_50023_d(var4 - this.field_50048_p + var8);
    }