You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clicking bottom inventory items while another player's inventory is opened up at the top fires InventoryClickEvent with incorrect items and slots #11245
InventoryClickEvent should not report incorrect slots and/or items on the bottom inventory when another player's inventory is opened up in the top.
Observed/Actual behavior
When having another player's inventory opened up, attempting to click an item from the bottom inventory (our own inventory) will fire an InventoryClickEvent with an incorrect slot/item:
javaw_sRTWvdj4ta.mp4
I have tested the following versions, all of which have the issue:
Paper 1.21.1 build 10
Paper 1.20.6 build 148
Paper 1.18.2 build 388
Paper 1.14.4 build 245
The following versions do NOT have the issue:
Paper 1.13.2 build 657
Paper 1.12.2 build 1620
Steps/models to reproduce
Example repository: https://github.com/xwmi/paper-bug-poc (check the legacy branch for a version of the plugin that works on older Paper versions using a Diamond instead of netherite hoes)
Create an InventoryClickEvent listener that will cancel movement for a specific item (e.g. a netherite hoe):
@EventHandlerpublicvoidonInventoryClickEvent(InventoryClickEventevent) {
ItemStackcurrentItem = event.getCurrentItem();
intslot = event.getSlot();
intrawSlot = event.getRawSlot();
// Broadcast some debug information. We could also just print it to the console.StringitemType = currentItem != null ? currentItem.getType().name() : "none";
Bukkit.broadcast(Component.text("The clicked item type is " + itemType));
Bukkit.broadcast(Component.text("The clicked slot is " + slot));
Bukkit.broadcast(Component.text("The raw slot is " + rawSlot));
// Let's not cancel the event if it isn't a Netherite Hoeif (currentItem == null || currentItem.getType() != Material.NETHERITE_HOE) {
return;
}
@NotNullHumanEntityentity = event.getWhoClicked();
// This should, in theory, prevent a Netherite Hoe from being moved// around the inventory when the top inventory is from another playerif (entity.getOpenInventory().getTopInventory().getType() == InventoryType.PLAYER) {
event.setCancelled(true);
Bukkit.broadcast(Component.text("Cancelled Netherite Hoe movement " +
"because the top inventory is from a player"));
} else {
Bukkit.broadcast(Component.text("Not cancelling Netherite Hoe movement " +
"because the top inventory is not from a player"));
}
}
Create a command that will open another player's inventory like this (EssentialsX has an /invsee command that will also work for this):
Attempt to click the Netherite Hoe or some other slots around it. The event will report as if a completely unrelated slot was being clicked:
Plugin and Datapack List
> pl
[21:22:48 INFO]: Server Plugins (1):
[21:22:48 INFO]: Paper Plugins:
[21:22:48 INFO]: - PaperBugExample
> datapack list
[21:22:51 INFO]: There are 3 data pack(s) enabled: [vanilla (built-in)], [file/bukkit (world)], [paper (built-in)]
[21:22:51 INFO]: There are no more data packs available
Paper version
> ver
[21:23:12 INFO]: This server is running Paper version 1.21.1-10-master@098bd39 (2024-08-11T22:37:37Z) (Implementing API version 1.21.1-R0.1-SNAPSHOT)
You are running the latest version
Expected behavior
InventoryClickEvent should not report incorrect slots and/or items on the bottom inventory when another player's inventory is opened up in the top.
Observed/Actual behavior
When having another player's inventory opened up, attempting to click an item from the bottom inventory (our own inventory) will fire an InventoryClickEvent with an incorrect slot/item:
javaw_sRTWvdj4ta.mp4
I have tested the following versions, all of which have the issue:
The following versions do NOT have the issue:
Steps/models to reproduce
Example repository: https://github.com/xwmi/paper-bug-poc (check the
legacybranch for a version of the plugin that works on older Paper versions using a Diamond instead of netherite hoes)/invseecommand that will also work for this):Plugin and Datapack List
Paper version
Other
No response