diff --git a/nms-patches/PlayerConnection.patch b/nms-patches/PlayerConnection.patch index e45bb73f9c..8a7ef1f0ff 100644 --- a/nms-patches/PlayerConnection.patch +++ b/nms-patches/PlayerConnection.patch @@ -70,7 +70,7 @@ public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) { this.minecraftServer = minecraftserver; -@@ -58,11 +105,38 @@ +@@ -58,7 +105,32 @@ networkmanager.setPacketListener(this); this.player = entityplayer; entityplayer.playerConnection = this; @@ -102,15 +102,8 @@ + // CraftBukkit end public void E_() { -- this.d(); -+ // CraftBukkit start - SPIGOT-1903: reverse order of location update - this.player.k_(); -+ this.d(); -+ // CraftBukkit end - this.player.setLocation(this.l, this.m, this.n, this.player.yaw, this.player.pitch); - ++this.e; - this.G = this.F; -@@ -110,15 +184,21 @@ + this.d(); +@@ -110,15 +182,21 @@ } this.minecraftServer.methodProfiler.b(); @@ -132,7 +125,7 @@ this.disconnect("You have been idle for too long!"); } -@@ -138,19 +218,40 @@ +@@ -138,19 +216,40 @@ } public void disconnect(String s) { @@ -176,7 +169,7 @@ } public void a(PacketPlayInSteerVehicle packetplayinsteervehicle) { -@@ -189,7 +290,34 @@ +@@ -189,7 +288,34 @@ double d9 = entity.motX * entity.motX + entity.motY * entity.motY + entity.motZ * entity.motZ; double d10 = d6 * d6 + d7 * d7 + d8 * d8; @@ -212,7 +205,7 @@ PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[] { entity.getName(), this.player.getName(), Double.valueOf(d6), Double.valueOf(d7), Double.valueOf(d8)}); this.networkManager.sendPacket(new PacketPlayOutVehicleMove(entity)); return; -@@ -227,6 +355,62 @@ +@@ -227,6 +353,62 @@ return; } @@ -275,7 +268,7 @@ this.minecraftServer.getPlayerList().d(this.player); this.player.checkMovement(this.player.locX - d0, this.player.locY - d1, this.player.locZ - d2); this.D = d11 >= -0.03125D && !this.minecraftServer.getAllowFlight() && !worldserver.d(entity.getBoundingBox().g(0.0625D).a(0.0D, -0.55D, 0.0D)); -@@ -261,7 +445,7 @@ +@@ -261,7 +443,7 @@ } else { WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); @@ -284,7 +277,7 @@ if (this.e == 0) { this.d(); } -@@ -271,13 +455,21 @@ +@@ -271,13 +453,21 @@ this.A = this.e; this.a(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch); } @@ -307,7 +300,7 @@ double d0 = this.player.locX; double d1 = this.player.locY; double d2 = this.player.locZ; -@@ -296,15 +488,33 @@ +@@ -296,15 +486,33 @@ ++this.F; int i = this.F - this.G; @@ -344,7 +337,7 @@ PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[] { this.player.getName(), Double.valueOf(d7), Double.valueOf(d8), Double.valueOf(d9)}); this.a(this.player.locX, this.player.locY, this.player.locZ, this.player.yaw, this.player.pitch); return; -@@ -350,6 +560,69 @@ +@@ -350,6 +558,69 @@ } } @@ -414,7 +407,7 @@ this.B = d12 >= -0.03125D; this.B &= !this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly; this.B &= !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.cG() && !worldserver.d(this.player.getBoundingBox().g(0.0625D).a(0.0D, -0.55D, 0.0D)); -@@ -366,15 +639,79 @@ +@@ -366,15 +637,79 @@ } public void a(double d0, double d1, double d2, float f, float f1) { @@ -499,7 +492,7 @@ float f2 = f; float f3 = f1; -@@ -386,6 +723,14 @@ +@@ -386,6 +721,14 @@ f3 = f1 + this.player.pitch; } @@ -514,7 +507,7 @@ if (++this.teleportAwait == Integer.MAX_VALUE) { this.teleportAwait = 0; } -@@ -397,37 +742,61 @@ +@@ -397,37 +740,61 @@ public void a(PacketPlayInBlockDig packetplayinblockdig) { PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.x()); @@ -582,7 +575,7 @@ this.player.clearActiveItem(); itemstack = this.player.getItemInMainHand(); if (itemstack != null && itemstack.count == 0) { -@@ -436,9 +805,9 @@ +@@ -436,9 +803,9 @@ return; @@ -595,7 +588,7 @@ double d0 = this.player.locX - ((double) blockposition.getX() + 0.5D); double d1 = this.player.locY - ((double) blockposition.getY() + 0.5D) + 1.5D; double d2 = this.player.locZ - ((double) blockposition.getZ() + 0.5D); -@@ -453,7 +822,15 @@ +@@ -453,7 +820,15 @@ if (!this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) { this.player.playerInteractManager.a(blockposition, packetplayinblockdig.b()); } else { @@ -611,7 +604,7 @@ } } else { if (packetplayinblockdig.c() == PacketPlayInBlockDig.EnumPlayerDigType.STOP_DESTROY_BLOCK) { -@@ -473,10 +850,12 @@ +@@ -473,10 +848,12 @@ default: throw new IllegalArgumentException("Invalid player action"); } @@ -624,7 +617,7 @@ WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); EnumHand enumhand = packetplayinuseitem.c(); ItemStack itemstack = this.player.b(enumhand); -@@ -490,6 +869,13 @@ +@@ -490,6 +867,13 @@ chatmessage.getChatModifier().setColor(EnumChatFormat.RED); this.player.playerConnection.sendPacket(new PacketPlayOutChat(chatmessage)); } else if (this.teleportPos == null && this.player.e((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)) { @@ -638,7 +631,7 @@ this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, blockposition, enumdirection, packetplayinuseitem.d(), packetplayinuseitem.e(), packetplayinuseitem.f()); } -@@ -504,19 +890,55 @@ +@@ -504,19 +888,55 @@ public void a(PacketPlayInBlockPlace packetplayinblockplace) { PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.x()); @@ -699,7 +692,7 @@ } } -@@ -527,8 +949,8 @@ +@@ -527,8 +947,8 @@ WorldServer[] aworldserver = this.minecraftServer.worldServer; int i = aworldserver.length; @@ -710,7 +703,7 @@ if (worldserver != null) { entity = packetplayinspectate.a(worldserver); -@@ -541,6 +963,8 @@ +@@ -541,6 +961,8 @@ if (entity != null) { this.player.setSpectatorTarget(this.player); this.player.stopRiding(); @@ -719,7 +712,7 @@ if (entity.world == this.player.world) { this.player.enderTeleportTo(entity.locX, entity.locY, entity.locZ); } else { -@@ -566,12 +990,19 @@ +@@ -566,12 +988,19 @@ this.minecraftServer.getPlayerList().b(this.player, worldserver2); this.minecraftServer.getPlayerList().updateClient(this.player); } @@ -740,7 +733,7 @@ public void a(PacketPlayInBoatMove packetplayinboatmove) { PlayerConnectionUtils.ensureMainThread(packetplayinboatmove, this, this.player.x()); -@@ -584,14 +1015,29 @@ +@@ -584,14 +1013,29 @@ } public void a(IChatBaseComponent ichatbasecomponent) { @@ -772,7 +765,7 @@ if (this.minecraftServer.R() && this.player.getName().equals(this.minecraftServer.Q())) { PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out"); this.minecraftServer.safeShutdown(); -@@ -613,6 +1059,15 @@ +@@ -613,6 +1057,15 @@ } } @@ -788,7 +781,7 @@ try { this.networkManager.sendPacket(packet); } catch (Throwable throwable) { -@@ -634,17 +1089,32 @@ +@@ -634,17 +1087,32 @@ public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) { PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.x()); @@ -823,7 +816,7 @@ ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]); chatmessage.getChatModifier().setColor(EnumChatFormat.RED); -@@ -657,39 +1127,249 @@ +@@ -657,39 +1125,249 @@ for (int i = 0; i < s.length(); ++i) { if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) { @@ -1081,7 +1074,7 @@ this.player.resetIdleTimer(); IJumpable ijumpable; -@@ -759,6 +1439,7 @@ +@@ -759,6 +1437,7 @@ public void a(PacketPlayInUseEntity packetplayinuseentity) { PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.x()); @@ -1089,7 +1082,7 @@ WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); Entity entity = packetplayinuseentity.a((World) worldserver); -@@ -775,22 +1456,72 @@ +@@ -775,22 +1454,72 @@ EnumHand enumhand; ItemStack itemstack; @@ -1163,7 +1156,7 @@ } } } -@@ -806,7 +1537,8 @@ +@@ -806,7 +1535,8 @@ case 1: if (this.player.viewingCredits) { this.player.viewingCredits = false; @@ -1173,7 +1166,7 @@ } else { if (this.player.getHealth() > 0.0F) { return; -@@ -832,14 +1564,20 @@ +@@ -832,14 +1562,20 @@ public void a(PacketPlayInCloseWindow packetplayinclosewindow) { PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.x()); @@ -1195,7 +1188,7 @@ ArrayList arraylist = Lists.newArrayList(); for (int i = 0; i < this.player.activeContainer.c.size(); ++i) { -@@ -848,8 +1586,279 @@ +@@ -848,8 +1584,279 @@ this.player.a(this.player.activeContainer, (List) arraylist); } else { @@ -1207,7 +1200,7 @@ + + InventoryView inventory = this.player.activeContainer.getBukkitView(); + SlotType type = CraftInventoryView.getSlotType(inventory, packetplayinwindowclick.b()); -+ + + InventoryClickEvent event; + ClickType click = ClickType.UNKNOWN; + InventoryAction action = InventoryAction.UNKNOWN; @@ -1383,7 +1376,7 @@ + default: + break; + } - ++ + if (packetplayinwindowclick.f() != InventoryClickType.QUICK_CRAFT) { + if (click == ClickType.NUMBER_KEY) { + event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.b(), click, action, packetplayinwindowclick.c()); @@ -1476,7 +1469,7 @@ if (ItemStack.matches(packetplayinwindowclick.e(), itemstack)) { this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.a(), packetplayinwindowclick.d(), true)); this.player.f = true; -@@ -878,6 +1887,7 @@ +@@ -878,6 +1885,7 @@ public void a(PacketPlayInEnchantItem packetplayinenchantitem) { PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.x()); @@ -1484,7 +1477,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()); -@@ -911,8 +1921,48 @@ +@@ -911,8 +1919,48 @@ } boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() <= 45; @@ -1534,7 +1527,7 @@ if (flag1 && flag2 && flag3) { if (itemstack == null) { -@@ -936,6 +1986,7 @@ +@@ -936,6 +1984,7 @@ public void a(PacketPlayInTransaction packetplayintransaction) { PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.x()); @@ -1542,7 +1535,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()) { -@@ -946,6 +1997,7 @@ +@@ -946,6 +1995,7 @@ public void a(PacketPlayInUpdateSign packetplayinupdatesign) { PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.x()); @@ -1550,7 +1543,7 @@ this.player.resetIdleTimer(); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); BlockPosition blockposition = packetplayinupdatesign.a(); -@@ -962,14 +2014,30 @@ +@@ -962,14 +2012,30 @@ if (!tileentitysign.d() || tileentitysign.e() != this.player) { this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign"); @@ -1582,7 +1575,7 @@ tileentitysign.update(); worldserver.notify(blockposition, iblockdata, iblockdata, 3); -@@ -992,11 +2060,27 @@ +@@ -992,11 +2058,27 @@ public void a(PacketPlayInAbilities packetplayinabilities) { PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.x()); @@ -1611,7 +1604,7 @@ ArrayList arraylist = Lists.newArrayList(); Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b(), packetplayintabcomplete.c()).iterator(); -@@ -1040,10 +2124,13 @@ +@@ -1040,10 +2122,13 @@ } if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) { @@ -1625,7 +1618,7 @@ } } else { String s1; -@@ -1067,6 +2154,7 @@ +@@ -1067,6 +2152,7 @@ } if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack1.getItem() == Items.WRITABLE_BOOK) { @@ -1633,7 +1626,7 @@ itemstack1.a("author", (NBTBase) (new NBTTagString(this.player.getName()))); itemstack1.a("title", (NBTBase) (new NBTTagString(itemstack.getTag().getString("title")))); NBTTagList nbttaglist = itemstack.getTag().getList("pages", 8); -@@ -1081,9 +2169,11 @@ +@@ -1081,9 +2167,11 @@ itemstack1.a("pages", (NBTBase) nbttaglist); itemstack1.setItem(Items.WRITTEN_BOOK); @@ -1645,7 +1638,7 @@ } } else if ("MC|TrSel".equals(s)) { try { -@@ -1095,6 +2185,7 @@ +@@ -1095,6 +2183,7 @@ } } catch (Exception exception2) { PlayerConnection.LOGGER.error("Couldn\'t select trade", exception2); @@ -1653,7 +1646,7 @@ } } else { TileEntity tileentity; -@@ -1144,6 +2235,7 @@ +@@ -1144,6 +2233,7 @@ } } catch (Exception exception3) { PlayerConnection.LOGGER.error("Couldn\'t set command block", exception3); @@ -1661,7 +1654,7 @@ } } else if ("MC|AutoCmd".equals(s)) { if (!this.minecraftServer.getEnableCommandBlock()) { -@@ -1211,6 +2303,7 @@ +@@ -1211,6 +2301,7 @@ } } catch (Exception exception4) { PlayerConnection.LOGGER.error("Couldn\'t set command block", exception4); @@ -1669,7 +1662,7 @@ } } else { int k; -@@ -1234,6 +2327,7 @@ +@@ -1234,6 +2325,7 @@ } } catch (Exception exception5) { PlayerConnection.LOGGER.error("Couldn\'t set beacon", exception5); @@ -1677,7 +1670,7 @@ } } } else if ("MC|ItemName".equals(s)) { -@@ -1320,6 +2414,7 @@ +@@ -1320,6 +2412,7 @@ } } catch (Exception exception6) { PlayerConnection.LOGGER.error("Couldn\'t set structure block", exception6); @@ -1685,7 +1678,7 @@ } } else if ("MC|PickItem".equals(s)) { packetdataserializer = packetplayincustompayload.b(); -@@ -1332,14 +2427,37 @@ +@@ -1332,14 +2425,37 @@ this.player.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex)); } catch (Exception exception7) { PlayerConnection.LOGGER.error("Couldn\'t pick item", exception7);