Posted December 3, 20213 yr In 1.15 and before, you could get the item being held/dragged by the cursor using PlayerInventory#getItemStack. This no longer seems to be the case. How do we do this now?
December 4, 20213 yr It's still there with the same name, if you are using 1.16 MCP mappings. Otherwise it will be AbstractContainerMenu#getCarried. Edited December 4, 20213 yr by poopoodice
December 4, 20213 yr Author Thank you! I did notice AbstractContainerMenu#getCarried and was able use that. Sorry, I am maintaining my mods in 1.16.5, 1.17.1 and 1.18 right now, and I just noticed that PlayerInventory#getItemStack does indeed exist in 1.16.5 but not 1.17.1 which doesn't have PlayerInventory at all, just Inventory which does not have getItemStack. My title should have said 1.17.1+. Sorry for the confusion.
December 4, 20213 yr Author 4 hours ago, diesieben07 said: 1.17 uses Mojang names, not MCP names. Good to know, so is there a PlayerInventory#getItemStack equivalent in the Mojang mappings, or is AbstractContainerMenu#getCarried the way to go? I don't actually need to know at this point, and I'm not sure of any scenario where you'd need it and not have a container menu available. I'm just curious and also wondering for the benefit of someone else with the same question who finds this post.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.