From f9e044059f493363621a6feb931c17eb9f5e1904 Mon Sep 17 00:00:00 2001 From: md_5 Date: Tue, 27 Dec 2016 12:14:55 +1100 Subject: SPIGOT-2960: Fire HOTBAR_MOVE_AND_READD in more cases --- nms-patches/PlayerConnection.patch | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/nms-patches/PlayerConnection.patch b/nms-patches/PlayerConnection.patch index 65c8206f..2b0731ab 100644 --- a/nms-patches/PlayerConnection.patch +++ b/nms-patches/PlayerConnection.patch @@ -1136,7 +1136,7 @@ NonNullList nonnulllist = NonNullList.a(); for (int i = 0; i < this.player.activeContainer.c.size(); ++i) { -@@ -836,8 +1567,279 @@ +@@ -836,8 +1567,274 @@ this.player.a(this.player.activeContainer, nonnulllist); } else { @@ -1243,12 +1243,7 @@ + if (canCleanSwap) { + action = InventoryAction.HOTBAR_SWAP; + } else { -+ int firstEmptySlot = player.inventory.getFirstEmptySlotIndex(); -+ if (firstEmptySlot > -1) { -+ action = InventoryAction.HOTBAR_MOVE_AND_READD; -+ } else { -+ action = InventoryAction.NOTHING; // This is not sane! Mojang: You should test for other slots of same type -+ } ++ action = InventoryAction.HOTBAR_MOVE_AND_READD; + } + } else if (!clickedSlot.hasItem() && !hotbar.isEmpty() && clickedSlot.isAllowed(hotbar)) { + action = InventoryAction.HOTBAR_SWAP; @@ -1417,7 +1412,7 @@ if (ItemStack.matches(packetplayinwindowclick.e(), itemstack)) { this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.a(), packetplayinwindowclick.d(), true)); this.player.f = true; -@@ -866,6 +1868,7 @@ +@@ -866,6 +1863,7 @@ public void a(PacketPlayInEnchantItem packetplayinenchantitem) { PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.x()); @@ -1425,7 +1420,7 @@ this.player.resetIdleTimer(); if (this.player.activeContainer.windowId == packetplayinenchantitem.a() && this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { this.player.activeContainer.a(this.player, packetplayinenchantitem.b()); -@@ -899,7 +1902,46 @@ +@@ -899,7 +1897,46 @@ } boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() <= 45; @@ -1473,7 +1468,7 @@ if (flag1 && flag2) { if (itemstack.isEmpty()) { -@@ -923,6 +1965,7 @@ +@@ -923,6 +1960,7 @@ public void a(PacketPlayInTransaction packetplayintransaction) { PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.x()); @@ -1481,7 +1476,7 @@ Short oshort = (Short) this.k.get(this.player.activeContainer.windowId); if (oshort != null && packetplayintransaction.b() == oshort.shortValue() && this.player.activeContainer.windowId == packetplayintransaction.a() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { -@@ -933,6 +1976,7 @@ +@@ -933,6 +1971,7 @@ public void a(PacketPlayInUpdateSign packetplayinupdatesign) { PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.x()); @@ -1489,7 +1484,7 @@ this.player.resetIdleTimer(); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); BlockPosition blockposition = packetplayinupdatesign.a(); -@@ -949,14 +1993,30 @@ +@@ -949,14 +1988,30 @@ if (!tileentitysign.a() || tileentitysign.e() != this.player) { this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign"); @@ -1521,7 +1516,7 @@ tileentitysign.update(); worldserver.notify(blockposition, iblockdata, iblockdata, 3); -@@ -979,11 +2039,27 @@ +@@ -979,11 +2034,27 @@ public void a(PacketPlayInAbilities packetplayinabilities) { PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.x()); @@ -1550,7 +1545,7 @@ ArrayList arraylist = Lists.newArrayList(); Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b(), packetplayintabcomplete.c()).iterator(); -@@ -1027,10 +2103,13 @@ +@@ -1027,10 +2098,13 @@ } if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) { @@ -1564,7 +1559,7 @@ } } else { String s1; -@@ -1069,10 +2148,11 @@ +@@ -1069,10 +2143,11 @@ } itemstack2.a("pages", (NBTBase) nbttaglist); @@ -1577,7 +1572,7 @@ } } else if ("MC|TrSel".equals(s)) { try { -@@ -1084,6 +2164,7 @@ +@@ -1084,6 +2159,7 @@ } } catch (Exception exception2) { PlayerConnection.LOGGER.error("Couldn\'t select trade", exception2); @@ -1585,7 +1580,7 @@ } } else { TileEntity tileentity; -@@ -1133,6 +2214,7 @@ +@@ -1133,6 +2209,7 @@ } } catch (Exception exception3) { PlayerConnection.LOGGER.error("Couldn\'t set command block", exception3); @@ -1593,7 +1588,7 @@ } } else if ("MC|AutoCmd".equals(s)) { if (!this.minecraftServer.getEnableCommandBlock()) { -@@ -1200,6 +2282,7 @@ +@@ -1200,6 +2277,7 @@ } } catch (Exception exception4) { PlayerConnection.LOGGER.error("Couldn\'t set command block", exception4); @@ -1601,7 +1596,7 @@ } } else { int k; -@@ -1223,6 +2306,7 @@ +@@ -1223,6 +2301,7 @@ } } catch (Exception exception5) { PlayerConnection.LOGGER.error("Couldn\'t set beacon", exception5); @@ -1609,7 +1604,7 @@ } } } else if ("MC|ItemName".equals(s)) { -@@ -1309,6 +2393,7 @@ +@@ -1309,6 +2388,7 @@ } } catch (Exception exception6) { PlayerConnection.LOGGER.error("Couldn\'t set structure block", exception6); @@ -1617,7 +1612,7 @@ } } else if ("MC|PickItem".equals(s)) { packetdataserializer = packetplayincustompayload.b(); -@@ -1323,9 +2408,31 @@ +@@ -1323,9 +2403,31 @@ PlayerConnection.LOGGER.error("Couldn\'t pick item", exception7); } } -- cgit v1.2.3