Repository navigation
Fix incorrect InventoryClickEvent slots when clicking your own inventory during invsee - #14060
gunjanjaswal wants to merge 2 commits into
Conversation
Opening another player's inventory renders their inventory as a generic 9x4 chest (36 slots), but a player inventory reports a size of 41 since it also counts the armour and off-hand slots. The view's slot math used that reported size, so clicks in the bottom (viewer's own) inventory were mapped five slots off, making InventoryClickEvent report an unrelated slot and item. Route the top-slot count through an overridable helper and, for a player inventory shown in a container, use the number of slots actually laid out so the raw-to-inventory slot mapping lines up again.
|
Small nudge on this. It corrects the InventoryClickEvent slot values for the reported case and carries a test; still mergeable against current. If it's fallen behind I can rebase. Just flagging it's ready for a review pass when someone has time. |
|
Closing this one out — it's sat a while without a review, so cleaning up rather than leaving it stale. The fix still holds if there's interest later (correcting the InventoryClickEvent raw/converted slots when clicking your own inventory while viewing another), and I'm glad to reopen or freshen it up. Thanks! |
|
Just rebase it for main if needed and when the team will have time, they will review it. |
|
Good call, @YnsanitY16 — reopened, and thanks for the nudge. You're right that it's worth keeping around; the fix still applies cleanly. Bringing the branch up to date with main now so it's fresh for whenever the team has a window. |
|
Gentle nudge on this one, @YnsanitY16. It's been a few weeks since the reopen and rebase — branch is still current with main, CI's green, and the slot-mapping fix applies cleanly. Whenever someone has a moment for a review pass, I'm around to address anything that comes up. |
|
Following up again — it's been about a month since the last bump and this is still waiting for a review slot. It's a contained fix for the InventoryClickEvent slot indices being reported wrong for the affected menu type. No urgency, just keeping it on the radar whenever someone has the time. |
Fixes #11245
When you open another player's inventory (invsee-style, via
player.openInventory(target.getInventory())) and then click an item in your own inventory at the bottom,InventoryClickEventreports a completely unrelated slot and item. It has been broken since around 1.14.The top inventory in that case is drawn as a generic 9x4 chest, so it only shows 36 slots. A player inventory, though, reports a size of 41 because it also counts the four armour slots and the off-hand. The slot conversion in
CraftAbstractInventoryViewkeyed off that reported size, so every raw slot in the bottom inventory ended up five out. The first few slots of your own inventory were even treated as part of the top.This adds a small
getTopSlots()hook (it defaults to the current behaviour, so nothing else changes) and, for a player inventory opened in a container, returns the slot count that is actually laid out. With that,convertSlot,getSlotType, andcountSlotsline up with the real container again.I worked the mapping through by hand (raw slot 36 maps to main inventory slot 9, raw 71 to hotbar 8, and so on) and it checks out, but I have not been able to run it against a live server build yet, so a second look there would be welcome.