Closed 0dinD closed 2 months ago
On a somewhat related note (but kind of unrelated to this issue), I had a look at the changes in the above mentioned CraftBukkit commit and it seems like while it doesn't really change anything for us right now, it's a good cleanup of the current API which seems to be in preparation for some more exciting additions that might land in the future. I haven't looked at it in detail, but it seems to me like CraftBukkit PR 1458 (you need stash access to view it) is the motivation for the API cleanup, and I think there's a possibility that it would allow us to implement AnvilGUI using just the Bukkit API. Maybe I shouldn't get my hopes too high just yet, but it would definitely be a welcome surprise if we could finally put an end to years of maintaining NMS wrappers! Fingers crossed :slightly_smiling_face:
After looking into it some more, this looks very promising! The author of these CraftBukkit patches made a post about the new InventoryView APIs on the Spigot forums, and has more or less confirmed that proper anvil menus are one of the goals of their contributions to CraftBukkit, judging by this message in the PaperMC Discord server. Also, I found an old post of theirs which goes into great detail about creating anvil GUIs specifically, using NMS. I am seeing many similarities between that code and the CraftBukkit contributions, so I'm sure that was the inspiration behind it all. Fingers crossed that the last parts needed for the complete Anvil API will be merged at some point in the future, and that AnvilGUI can make use of that effort in order to remove all or at least most of the version wrapper NMS code for future game versions!
On the latest builds of Spigot for Minecraft 1.21, opening an anvil GUI doesn't work and causes a
NoSuchMethodError
to be thrown. The breakage has occurred due to CraftBukkit@9c3bd439054771ce89ed69b8f74f5eba2ff4fc51 which changes the return type ofnet.minecraft.world.inventory.ContainerAnvil#getBukkitInventory()
fromCraftInventoryView
toCraftAnvilView
and therefore breaks the ABI compatibility for AnvilGUI (even if the types would otherwise be compatible).All builds of CraftBukkit, Spigot and derivatives are affected, the latest builds for Minecraft 1.21. Paper is not yet affected because they haven't pulled the latest Spigot patches yet, but I would assume that the problem will also arise on Paper once they do, probably pretty soon. This is not a bug or problem with CraftBukkit/Spigot, just something that broke because, ya know, NMS is not an API and may break at any point.
Here is a full stack trace which I get when opening an anvil GUI on the latest build of Spigot:
Fortunately, this looks pretty easy to work around for now, because we could compile against
net.minecraft.world.inventory.Container#getBukkitInventory()
instead, which hasn't had an ABI breakage. If we do this, AnvilGUI will still be compatible with all server versions, both before and after the problematic CraftBukkit commit.