mojira.dev
MC-111328

Written books selectors and scores don't finalize in offhand (just show literal text (@p, @a, etc.))

How to reproduce

  1. Give yourself a written_book with the following command:

    /give @p written_book{pages:["{\"selector\":\"@p\"}"],title:"",author:""}
  2. Open it
    → ✔ You will see your name written at the top

  3. Remove that book from your inventory and /give you this book again

  4. Place it in your offhand

  5. Open it
    → ❌ You will see @p the first time. Close and reopen it again. This time you will see your name.

This issue concern also @a, @e, @r... and scores display.

Code analysis

Based on 1.11 decompiled using MCP 9.35 rc1

The problem is that the method net.minecraft.item.ItemWrittenBook.resolveContents(ItemStack, EntityPlayer) tests if the player is holding the item in the mainhand and only if this is the case sends a SPacketSetSlot packet.
This condition does not really make sense because the item is modified anyways, the client inventory just won't be updated. This can be seen by dropping the book, picking it back up and opening it in the offhand again.
The best way to fix this would probably be to remove this condition.

Linked issues

Attachments

Comments 3

Confirmed for 1.11. This could be related to MC-84005.

Confirmed issue in 1.13 snapshots

[media]

Cannot reproduce in 1.15.1

Bytenka

(Unassigned)

Confirmed

(Unassigned)

off-hand, score, selector, text-component, written_book

Minecraft 1.11, Minecraft 1.12.1, Minecraft 1.12.2, Minecraft 18w07c, Minecraft 18w11a, Minecraft 1.13, Minecraft 18w30a, Minecraft 18w30b, Minecraft 1.13.1

Retrieved