From f74c7b9578132e74fa45be53f0b69ac510258f75 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 20 Apr 2019 12:57:02 +1000 Subject: [PATCH] SPIGOT-4706: Can't interact with active item --- nms-patches/PlayerConnection.patch | 41 +++++++++++++++--------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/nms-patches/PlayerConnection.patch b/nms-patches/PlayerConnection.patch index 53c2f761ba..91ed78b8d1 100644 --- a/nms-patches/PlayerConnection.patch +++ b/nms-patches/PlayerConnection.patch @@ -657,7 +657,7 @@ WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); EnumHand enumhand = packetplayinuseitem.d(); ItemStack itemstack = this.player.b(enumhand); -@@ -772,6 +1175,13 @@ +@@ -772,6 +1175,14 @@ this.player.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent, ChatMessageType.GAME_INFO)); } else if (this.teleportPos == null && this.player.d((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && !this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) { @@ -667,11 +667,12 @@ + if (reachDistance > (this.getPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? CREATIVE_PLACE_DISTANCE_SQUARED : SURVIVAL_PLACE_DISTANCE_SQUARED)) { + return; + } ++ this.player.clearActiveItem(); // SPIGOT-4706 + // CraftBukkit end this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, blockposition, enumdirection, packetplayinuseitem.e(), packetplayinuseitem.f(), packetplayinuseitem.g()); } -@@ -781,13 +1191,52 @@ +@@ -781,13 +1192,52 @@ public void a(PacketPlayInBlockPlace packetplayinblockplace) { PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.getWorldServer()); @@ -725,7 +726,7 @@ } } -@@ -807,13 +1256,18 @@ +@@ -807,13 +1257,18 @@ } if (entity != null) { @@ -746,7 +747,7 @@ public void a(PacketPlayInBoatMove packetplayinboatmove) { PlayerConnectionUtils.ensureMainThread(packetplayinboatmove, this, this.player.getWorldServer()); -@@ -826,11 +1280,26 @@ +@@ -826,11 +1281,26 @@ } public void a(IChatBaseComponent ichatbasecomponent) { @@ -774,7 +775,7 @@ if (this.minecraftServer.H() && this.player.getDisplayName().getString().equals(this.minecraftServer.G())) { PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out"); this.minecraftServer.safeShutdown(); -@@ -856,6 +1325,15 @@ +@@ -856,6 +1326,15 @@ } } @@ -790,7 +791,7 @@ try { this.networkManager.sendPacket(packet, genericfuturelistener); } catch (Throwable throwable) { -@@ -871,17 +1349,37 @@ +@@ -871,17 +1350,37 @@ public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) { PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.getWorldServer()); @@ -830,7 +831,7 @@ this.sendPacket(new PacketPlayOutChat((new ChatMessage("chat.cannotSend", new Object[0])).a(EnumChatFormat.RED))); } else { this.player.resetIdleTimer(); -@@ -891,39 +1389,255 @@ +@@ -891,39 +1390,255 @@ for (int i = 0; i < s.length(); ++i) { if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) { @@ -1093,7 +1094,7 @@ this.player.resetIdleTimer(); IJumpable ijumpable; -@@ -986,6 +1700,7 @@ +@@ -986,6 +1701,7 @@ public void a(PacketPlayInUseEntity packetplayinuseentity) { PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.getWorldServer()); @@ -1101,7 +1102,7 @@ WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); Entity entity = packetplayinuseentity.a((World) worldserver); -@@ -1001,20 +1716,74 @@ +@@ -1001,20 +1717,74 @@ if (this.player.h(entity) < d0) { EnumHand enumhand; @@ -1177,7 +1178,7 @@ } } } -@@ -1030,7 +1799,8 @@ +@@ -1030,7 +1800,8 @@ case PERFORM_RESPAWN: if (this.player.viewingCredits) { this.player.viewingCredits = false; @@ -1187,7 +1188,7 @@ CriterionTriggers.v.a(this.player, DimensionManager.THE_END, DimensionManager.OVERWORLD); } else { if (this.player.getHealth() > 0.0F) { -@@ -1052,14 +1822,20 @@ +@@ -1052,14 +1823,20 @@ public void a(PacketPlayInCloseWindow packetplayinclosewindow) { PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.getWorldServer()); @@ -1210,7 +1211,7 @@ NonNullList nonnulllist = NonNullList.a(); for (int i = 0; i < this.player.activeContainer.slots.size(); ++i) { -@@ -1068,8 +1844,274 @@ +@@ -1068,8 +1845,274 @@ this.player.a(this.player.activeContainer, nonnulllist); } else { @@ -1486,7 +1487,7 @@ if (ItemStack.matches(packetplayinwindowclick.f(), itemstack)) { this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.b(), packetplayinwindowclick.e(), true)); this.player.f = true; -@@ -1112,6 +2154,7 @@ +@@ -1112,6 +2155,7 @@ public void a(PacketPlayInEnchantItem packetplayinenchantitem) { PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.getWorldServer()); @@ -1494,7 +1495,7 @@ this.player.resetIdleTimer(); if (this.player.activeContainer.windowId == packetplayinenchantitem.b() && this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { this.player.activeContainer.a(this.player, packetplayinenchantitem.c()); -@@ -1143,6 +2186,43 @@ +@@ -1143,6 +2187,43 @@ boolean flag1 = packetplayinsetcreativeslot.b() >= 1 && packetplayinsetcreativeslot.b() <= 45; boolean flag2 = itemstack.isEmpty() || itemstack.getDamage() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty(); @@ -1538,7 +1539,7 @@ if (flag1 && flag2) { if (itemstack.isEmpty()) { -@@ -1166,6 +2246,7 @@ +@@ -1166,6 +2247,7 @@ public void a(PacketPlayInTransaction packetplayintransaction) { PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.getWorldServer()); @@ -1546,7 +1547,7 @@ Short oshort = (Short) this.k.get(this.player.activeContainer.windowId); if (oshort != null && packetplayintransaction.c() == oshort && this.player.activeContainer.windowId == packetplayintransaction.b() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { -@@ -1176,6 +2257,7 @@ +@@ -1176,6 +2258,7 @@ public void a(PacketPlayInUpdateSign packetplayinupdatesign) { PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.getWorldServer()); @@ -1554,7 +1555,7 @@ this.player.resetIdleTimer(); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); BlockPosition blockposition = packetplayinupdatesign.b(); -@@ -1192,14 +2274,30 @@ +@@ -1192,14 +2275,30 @@ if (!tileentitysign.d() || tileentitysign.e() != this.player) { this.minecraftServer.warning("Player " + this.player.getDisplayName().getString() + " just tried to change non-editable sign"); @@ -1586,7 +1587,7 @@ tileentitysign.update(); worldserver.notify(blockposition, iblockdata, iblockdata, 3); -@@ -1208,6 +2306,7 @@ +@@ -1208,6 +2307,7 @@ } public void a(PacketPlayInKeepAlive packetplayinkeepalive) { @@ -1594,7 +1595,7 @@ if (this.awaitingKeepAlive && packetplayinkeepalive.b() == this.h) { int i = (int) (SystemUtils.getMonotonicMillis() - this.lastKeepAlive); -@@ -1221,7 +2320,17 @@ +@@ -1221,7 +2321,17 @@ public void a(PacketPlayInAbilities packetplayinabilities) { PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.getWorldServer()); @@ -1613,7 +1614,7 @@ } public void a(PacketPlayInSettings packetplayinsettings) { -@@ -1229,5 +2338,47 @@ +@@ -1229,5 +2339,47 @@ this.player.a(packetplayinsettings); }