Open kazigk opened 1 week ago
What happens if you create a valid component, I.e. not using the legacy stuff, as that is just text and is not considered actual formatting by the modern system
On Fri, 21 Jun 2024 at 02:32, Gaweł Kazimierczuk @.***> wrote:
Expected behavior
Components https://jd.advntr.dev/api/4.17.0/net/kyori/adventure/text/Component.html obtained through pages() https://jd.advntr.dev/api/4.17.0/net/kyori/adventure/inventory/Book.html#pages() should be styled the same for WRITABLE_BOOK and WRITTEN_BOOK. Observed/Actual behavior
WRITABLE_BOOK:
[01:57:49 INFO]: [TestPlugin] isSigning: false, hasStyling: true [01:57:49 INFO]: [TestPlugin]
test WRITTEN_BOOK:
[01:57:59 INFO]: [TestPlugin] isSigning: true, hasStyling: false [01:57:59 INFO]: [TestPlugin] §6test
Steps/models to reproduce
public final class Plugin extends JavaPlugin implements Listener { private final Logger logger = getLogger(); private final MiniMessage miniMessage = MiniMessage.miniMessage();
@Override public void onEnable() { Bukkit.getPluginManager().registerEvents(this, this); } @EventHandler public void onPlayerEditBook(PlayerEditBookEvent e) { Component page = e.getNewBookMeta().pages().getFirst(); logger.info(String.format("isSigning: %s, hasStyling: %s", e.isSigning(), page.hasStyling())); logger.info(miniMessage.serialize(page)); }
}
- Give yourself a writable book: /give @p minecraft:writable_book
- Open the book and write formatted text, i.e. §6test, click done
- Open the book again, this time sign the book. It doesn't matter if you change the content of the book.
- Check logs in console
Plugin and Datapack List
plugins [02:04:43 INFO]: Server Plugins (1): [02:04:43 INFO]: Bukkit Plugins: [02:04:43 INFO]: - TestPlugin datapack list [02:04:47 INFO]: There are 3 data pack(s) enabled: [vanilla (built-in)], [file/bukkit (world)], [paper (built-in)] [02:04:47 INFO]: There are no more data packs available
Paper version
Paper version @.*** (2024-06-17T19:24:35Z) (Implementing API version 1.20.6-R0.1-SNAPSHOT) Other
This also happens with other serializers, MiniMessage was used as an example.
— Reply to this email directly, view it on GitHub https://github.com/PaperMC/Paper/issues/10943, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJMAZEKQPVRMG4MHGW6DEDZIN7CRAVCNFSM6AAAAABJU7GL2GVHI2DSMVQWIX3LMV43ASLTON2WKOZSGM3DKNJSGY2DIMA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
@electronicboy I just tried that and writable_book
does not support it!
Looks like it's not a bug in Paper or Adventure, but rather a "feature" in Minecraft: MC-272175
Out of curiosity, I tried creating a writable book using components:
ItemStack is = new ItemStack(Material.WRITABLE_BOOK);
BookMeta meta = (BookMeta) is.getItemMeta();
meta.addPages(
Component.empty().color(NamedTextColor.GOLD).content("test")
);
is.setItemMeta(meta);
Note: BookMeta
is used instead of WritableBookMeta
, as the latter doesn't support components.
To my surprise, the book is displaying correctly in game and looks like it was converted to legacy styling:
So it looks like there is some conversion in place, but only one-way.
For the sake of completion, if we replace Material.WRITABLE_BOOK
with Material.WRITTEN_BOOK
, we will get this:
In minecraft 1.21 writable books do not support styling at all. while written books contain components, writable books just contain plain strings and afaik the legacy formatings (if existing) are removed when the client tries to update a book on the server.
https://minecraft.wiki/w/Data_component_format#writable_book_content
Expected behavior
Components obtained through [pages()](https://jd.advntr.dev/api/4.17.0/net/kyori/adventure/inventory/Book.html#pages()) should be styled the same for WRITABLE_BOOK and WRITTEN_BOOK.
Observed/Actual behavior
WRITABLE_BOOK:
WRITTEN_BOOK:
Steps/models to reproduce
/give @p minecraft:writable_book
§6test
, click donePlugin and Datapack List
Paper version
Paper version 1.20.6-147-ver/1.20.6@e41d44f (2024-06-17T19:24:35Z) (Implementing API version 1.20.6-R0.1-SNAPSHOT)
Other
This also happens with other serializers, MiniMessage was used as an example.