SPIGOT-6513: Placing ItemStack in Inventory causes InventoryAction.NOTHING

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2021-06-12 15:23:44 +10:00
parent 1daedfe082
commit 8797975de5

View file

@ -1265,7 +1265,7 @@
+ if (packetplayinwindowclick.d() == 0 || packetplayinwindowclick.d() == 1) {
+ action = InventoryAction.NOTHING; // Don't want to repeat ourselves
+ if (packetplayinwindowclick.c() == -999) {
+ if (!player.inventoryMenu.getCarried().isEmpty()) {
+ if (!player.containerMenu.getCarried().isEmpty()) {
+ action = packetplayinwindowclick.d() == 0 ? InventoryAction.DROP_ALL_CURSOR : InventoryAction.DROP_ONE_CURSOR;
+ }
+ } else if (packetplayinwindowclick.c() < 0) {
@ -1274,7 +1274,7 @@
+ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.c());
+ if (slot != null) {
+ ItemStack clickedItem = slot.getItem();
+ ItemStack cursor = player.inventoryMenu.getCarried();
+ ItemStack cursor = player.containerMenu.getCarried();
+ if (clickedItem.isEmpty()) {
+ if (!cursor.isEmpty()) {
+ action = packetplayinwindowclick.d() == 0 ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE;
@ -1362,7 +1362,7 @@
+ action = InventoryAction.NOTHING;
+ } else {
+ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.c());
+ if (slot != null && slot.hasItem() && player.getAbilities().instabuild && player.inventoryMenu.getCarried().isEmpty()) {
+ if (slot != null && slot.hasItem() && player.getAbilities().instabuild && player.containerMenu.getCarried().isEmpty()) {
+ action = InventoryAction.CLONE_STACK;
+ } else {
+ action = InventoryAction.NOTHING;
@ -1407,8 +1407,8 @@
+ case PICKUP_ALL:
+ click = ClickType.DOUBLE_CLICK;
+ action = InventoryAction.NOTHING;
+ if (packetplayinwindowclick.c() >= 0 && !this.player.inventoryMenu.getCarried().isEmpty()) {
+ ItemStack cursor = this.player.inventoryMenu.getCarried();
+ if (packetplayinwindowclick.c() >= 0 && !this.player.containerMenu.getCarried().isEmpty()) {
+ ItemStack cursor = this.player.containerMenu.getCarried();
+ action = InventoryAction.NOTHING;
+ // Quick check for if we have any of the item
+ if (inventory.getTopInventory().contains(CraftMagicNumbers.getMaterial(cursor.getItem())) || inventory.getBottomInventory().contains(CraftMagicNumbers.getMaterial(cursor.getItem()))) {
@ -1492,7 +1492,7 @@
+ case PLACE_SOME:
+ case PLACE_ONE:
+ case SWAP_WITH_CURSOR:
+ this.player.connection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.player.inventoryMenu.getCarried()));
+ this.player.connection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.player.containerMenu.getCarried()));
+ this.player.connection.sendPacket(new PacketPlayOutSetSlot(this.player.containerMenu.containerId, packetplayinwindowclick.c(), this.player.containerMenu.getSlot(packetplayinwindowclick.c()).getItem()));
+ break;
+ // Modified clicked only
@ -1504,7 +1504,7 @@
+ case DROP_ALL_CURSOR:
+ case DROP_ONE_CURSOR:
+ case CLONE_STACK:
+ this.player.connection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.player.inventoryMenu.getCarried()));
+ this.player.connection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.player.containerMenu.getCarried()));
+ break;
+ // Nothing
+ case NOTHING: