mojira.dev
MC-1685

Unable to write in a new blank Book and Quill after renaming it in an anvil

The bug

When I use an anvil (repair & name) on "Book and Quill" after naming I can't write something in this book. I can sign it but it stay are not writed.

How to reproduce

  1. Get a new blank book and quill.

  2. Rename it.

  3. Try to type in it, it won't work.

Code analysis

Based on 1.11 decompiled using MCP 9.35 rc1

The constructor net.minecraft.client.gui.GuiScreenBook.GuiScreenBook(EntityPlayer, ItemStack, boolean) tests if the book has the tag tag and if this is the case tries to use its pages value. Because this tag does not exist an empty list is returned. The problem is that the test for bookTotalPages < 1 (= empty list) only sets the bookTotalPages attribute value to 1, but does not add an empty string to the pages. Because of this the player is unable to write something.

Suggested fix (1.11)

public GuiScreenBook(EntityPlayer player, ItemStack book, boolean isUnsigned)
{
    this.editingPlayer = player;
    this.bookObj = book;
    this.bookIsUnsigned = isUnsigned;

    if (book.hasTagCompound())
    {
        NBTTagCompound nbttagcompound = book.getTagCompound();
        this.bookPages = nbttagcompound.getTagList("pages", 8).copy();
        this.bookTotalPages = this.bookPages.tagCount();

        if (this.bookTotalPages < 1)
        {
            // Added the following line
            this.bookPages.appendTag(new NBTTagString(""));
            this.bookTotalPages = 1;
        }
    }

    if (this.bookPages == null && isUnsigned)
    {
        this.bookPages = new NBTTagList();
        this.bookPages.appendTag(new NBTTagString(""));
        this.bookTotalPages = 1;
    }
}

Linked issues

MC-1958 i cant write a book when i named it with a anvil Resolved MC-2048 You cannon type in a renamed Book and Quill that you have renamed in the anvil. Resolved MC-6864 Book and Quill requires update when renamed Resolved MC-7114 11 January 2013 Resolved MC-12441 Unable to write in Book and Quill after being renamed in an Anvil. Resolved

Comments 44

Daedalus Young

Could somebody please edit the title of this issue?

[edit] Thank you very much, it's easier to find now πŸ™‚

This still applies in 1.4.5.

Also, it does not apply to books that have already been written in. Only new, un-edited books.

Can confirm.

can confirm. sucks

Alexander Spielvogel

As a small sidenote: It would be great if you could use the cursorkeys to move the input cursor, when you need to edit something on top you have to delete all text and type it again. 😞

34 more comments
Samuel Ohlsson

Confirmed for 1.11.2

QwertyuiopThePie

Confirmed for 17w17b

Confirmed for 1.12.1

Just happened to me on 1.12.2

Affects 17w43b

tomekch6

migrated

Confirmed

display-Name, item-renaming, writable_book

Minecraft 1.4.3, Minecraft 1.4.5, Minecraft 1.4.6, Minecraft 1.4.7, Snapshot 13w02a, ..., Minecraft 1.12.1 Pre-Release 1, Minecraft 1.12.1, Minecraft 1.12.2, Minecraft 17w43a, Minecraft 17w43b

Minecraft 17w48a

Retrieved