Skip to content

Extra-lazy parsing for custom book items#793

Merged
artemisSystem merged 3 commits intoVazkiiMods:1.21.xfrom
TheRealWormbo:1.21-lazy-book-item-parsing
Aug 2, 2025
Merged

Extra-lazy parsing for custom book items#793
artemisSystem merged 3 commits intoVazkiiMods:1.21.xfrom
TheRealWormbo:1.21-lazy-book-item-parsing

Conversation

@TheRealWormbo
Copy link
Contributor

Since parsing uses registry-based vanilla logic now, it will not work before the book's mod has finished loading.

Fixes #790 at the expense of potentially delayed error reporting.

@TheRealWormbo TheRealWormbo marked this pull request as draft March 15, 2025 22:08
@TheRealWormbo TheRealWormbo force-pushed the 1.21-lazy-book-item-parsing branch from 4fe81c7 to ad88da3 Compare March 16, 2025 06:49
Since parsing uses registry-based vanilla logic now, it will not work before the book's mod has finished loading.

Fixes VazkiiMods#790 at the expense of potentially delayed error reporting.
@TheRealWormbo TheRealWormbo force-pushed the 1.21-lazy-book-item-parsing branch from ad88da3 to fde9c95 Compare March 16, 2025 06:52
@TheRealWormbo TheRealWormbo marked this pull request as ready for review March 16, 2025 06:57
@TheRealWormbo
Copy link
Contributor Author

Tested against https://github.com/TheRealWormbo/Botania/tree/1.21.1-patchouli-snapshot – Botania's boot item still works and opens the book, even though Patchouli fails to parse the item string.

Example exception:

[07:47:58] [Render thread/ERROR] (patchouli) Failed to parse item "botania:lexicon[foo]" for book botania:lexicon defined by mod botania, skipping
 java.lang.RuntimeException: com.mojang.brigadier.exceptions.CommandSyntaxException: Unknown item component 'minecraft:foo' at position 16: ...a:lexicon[<--[HERE]
	at knot/vazkii.patchouli.common.util.ItemStackUtil.deserializeStack(ItemStackUtil.java:50) ~[Patchouli-1.21-89-FABRIC-SNAPSHOT.jar:?]
	at knot/vazkii.patchouli.common.book.Book.lambda$new$1(Book.java:165) ~[Patchouli-1.21-89-FABRIC-SNAPSHOT.jar:?]
	at knot/com.google.common.base.Suppliers$NonSerializableMemoizingSupplier.get(Suppliers.java:181) ~[guava-32.1.2-jre.jar:?]
	at knot/vazkii.patchouli.common.book.Book.getBookItem(Book.java:183) ~[Patchouli-1.21-89-FABRIC-SNAPSHOT.jar:?]
	at knot/vazkii.patchouli.common.util.ItemStackUtil.getBookFromStack(ItemStackUtil.java:106) ~[Patchouli-1.21-89-FABRIC-SNAPSHOT.jar:?]
	at knot/vazkii.patchouli.client.handler.BookRightClickHandler.onRenderHUD(BookRightClickHandler.java:35) ~[Patchouli-1.21-89-FABRIC-SNAPSHOT.jar:?]
	at knot/net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback.lambda$static$0(HudRenderCallback.java:28) ~[fabric-rendering-v1-5.0.5+df16efd019.jar:?]
	at knot/net.minecraft.client.gui.Gui.handler$zpf000$fabric-rendering-v1$render(Gui.java:1538) [minecraft-merged-14fb05758b-1.21.1-loom.mappings.1_21_1.layered+hash.730628366-v2.jar:?]
	at knot/net.minecraft.client.gui.Gui.render(Gui.java:220) [minecraft-merged-14fb05758b-1.21.1-loom.mappings.1_21_1.layered+hash.730628366-v2.jar:?]
	at knot/net.minecraft.client.renderer.GameRenderer.render(GameRenderer.java:896) [minecraft-merged-14fb05758b-1.21.1-loom.mappings.1_21_1.layered+hash.730628366-v2.jar:?]
	at knot/net.minecraft.client.Minecraft.runTick(Minecraft.java:1285) [minecraft-merged-14fb05758b-1.21.1-loom.mappings.1_21_1.layered+hash.730628366-v2.jar:?]
	at knot/net.minecraft.client.Minecraft.run(Minecraft.java:882) [minecraft-merged-14fb05758b-1.21.1-loom.mappings.1_21_1.layered+hash.730628366-v2.jar:?]
	at knot/net.minecraft.client.main.Main.main(Main.java:256) [minecraft-merged-14fb05758b-1.21.1-loom.mappings.1_21_1.layered+hash.730628366-v2.jar:?]
	at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:480) [fabric-loader-0.16.10.jar:?]
	at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74) [fabric-loader-0.16.10.jar:?]
	at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23) [fabric-loader-0.16.10.jar:?]
	at net.fabricmc.devlaunchinjector.Main.main(Main.java:86) [dev-launch-injector-0.2.1+build.8.jar:?]
Caused by: com.mojang.brigadier.exceptions.CommandSyntaxException: Unknown item component 'minecraft:foo' at position 16: ...a:lexicon[<--[HERE]

@williewillus
Copy link
Member

The comment above parsed probably doesn't apply anymore

@artemisSystem artemisSystem merged commit 190ac2b into VazkiiMods:1.21.x Aug 2, 2025
1 check passed
@TheRealWormbo TheRealWormbo deleted the 1.21-lazy-book-item-parsing branch August 2, 2025 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

CommandSyntaxException on startup with custom book item

3 participants