From ed8cef0edb8058ff9d5f452956e3b63036c64875 Mon Sep 17 00:00:00 2001 From: Thinkofdeath Date: Wed, 2 Mar 2016 23:06:25 +0000 Subject: SPIGOT-1646: Don't move the player until after the PlayerMoveEvent completes --- nms-patches/PlayerConnection.patch | 74 +++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 28 deletions(-) (limited to 'nms-patches/PlayerConnection.patch') diff --git a/nms-patches/PlayerConnection.patch b/nms-patches/PlayerConnection.patch index c00bc0cc..bb668cc2 100644 --- a/nms-patches/PlayerConnection.patch +++ b/nms-patches/PlayerConnection.patch @@ -285,11 +285,28 @@ PlayerConnection.LOGGER.warn(this.player.getName() + " moved too quickly! " + d7 + "," + d8 + "," + d9); this.a(this.player.locX, this.player.locY, this.player.locZ, this.player.yaw, this.player.pitch); return; -@@ -352,6 +519,65 @@ +@@ -341,6 +508,13 @@ + PlayerConnection.LOGGER.warn(this.player.getName() + " moved wrongly!"); + } + ++ // CraftBukkit - Make sure the move is valid but then reset it for plugins to modify ++ double prevX = player.locX; ++ double prevY = player.locY; ++ double prevZ = player.locZ; ++ float prevYaw = player.yaw; ++ float prevPitch = player.pitch; ++ // CraftBukkit end + this.player.setLocation(d4, d5, d6, f, f1); + this.player.checkMovement(this.player.locX - d0, this.player.locY - d1, this.player.locZ - d2); + if (!this.player.noclip && !this.player.isSleeping()) { +@@ -352,6 +526,69 @@ } } + // CraftBukkit start - fire PlayerMoveEvent ++ // Rest to old location first ++ this.player.setLocation(prevX, prevY, prevZ, prevYaw, prevPitch); ++ + Player player = this.getPlayer(); + Location from = new Location(player.getWorld(), lastPosX, lastPosY, lastPosZ, lastYaw, lastPitch); // Get the Players previous Event location. + Location to = player.getLocation().clone(); // Start off the To location as the Players current location. @@ -346,12 +363,13 @@ + } + } + } ++ this.player.setLocation(d4, d5, d6, f, f1); // Copied from above + // CraftBukkit end + this.B = d12 >= -0.03125D; this.B &= !this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly; this.B &= !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.cB() && !worldserver.d(this.player.getBoundingBox().g(0.0625D).a(0.0D, -0.55D, 0.0D)); -@@ -368,15 +594,79 @@ +@@ -368,15 +605,79 @@ } public void a(double d0, double d1, double d2, float f, float f1) { @@ -436,7 +454,7 @@ float f2 = f; float f3 = f1; -@@ -388,6 +678,14 @@ +@@ -388,6 +689,14 @@ f3 = f1 + this.player.pitch; } @@ -451,7 +469,7 @@ if (++this.teleportAwait == Integer.MAX_VALUE) { this.teleportAwait = 0; } -@@ -399,15 +697,32 @@ +@@ -399,15 +708,32 @@ public void a(PacketPlayInBlockDig packetplayinblockdig) { PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.x()); @@ -485,7 +503,7 @@ itemstack = this.player.b(EnumHand.OFF_HAND); this.player.a(EnumHand.OFF_HAND, this.player.b(EnumHand.MAIN_HAND)); this.player.a(EnumHand.MAIN_HAND, itemstack); -@@ -415,21 +730,21 @@ +@@ -415,21 +741,21 @@ return; @@ -510,7 +528,7 @@ this.player.clearActiveItem(); itemstack = this.player.getItemInMainHand(); if (itemstack != null && itemstack.count == 0) { -@@ -438,8 +753,8 @@ +@@ -438,8 +764,8 @@ return; @@ -521,7 +539,7 @@ case 7: double d0 = this.player.locX - ((double) blockposition.getX() + 0.5D); double d1 = this.player.locY - ((double) blockposition.getY() + 0.5D) + 1.5D; -@@ -455,7 +770,15 @@ +@@ -455,7 +781,15 @@ if (!this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) { this.player.playerInteractManager.a(blockposition, packetplayinblockdig.b()); } else { @@ -537,7 +555,7 @@ } } else { if (packetplayinblockdig.c() == PacketPlayInBlockDig.EnumPlayerDigType.STOP_DESTROY_BLOCK) { -@@ -475,10 +798,12 @@ +@@ -475,10 +809,12 @@ default: throw new IllegalArgumentException("Invalid player action"); } @@ -550,7 +568,7 @@ WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); EnumHand enumhand = packetplayinuseitem.c(); ItemStack itemstack = this.player.b(enumhand); -@@ -492,6 +817,13 @@ +@@ -492,6 +828,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)) { @@ -564,7 +582,7 @@ this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, blockposition, enumdirection, packetplayinuseitem.d(), packetplayinuseitem.e(), packetplayinuseitem.f()); } -@@ -507,19 +839,55 @@ +@@ -507,19 +850,55 @@ public void a(PacketPlayInBlockPlace packetplayinblockplace) { PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.x()); @@ -625,7 +643,7 @@ } } -@@ -530,8 +898,8 @@ +@@ -530,8 +909,8 @@ WorldServer[] aworldserver = this.minecraftServer.worldServer; int i = aworldserver.length; @@ -636,7 +654,7 @@ if (worldserver != null) { entity = packetplayinspectate.a(worldserver); -@@ -544,6 +912,8 @@ +@@ -544,6 +923,8 @@ if (entity != null) { this.player.setSpectatorTarget(this.player); this.player.stopRiding(); @@ -645,7 +663,7 @@ if (entity.world != this.player.world) { WorldServer worldserver1 = this.player.x(); WorldServer worldserver2 = (WorldServer) entity.world; -@@ -569,12 +939,19 @@ +@@ -569,12 +950,19 @@ } else { this.player.enderTeleportTo(entity.locX, entity.locY, entity.locZ); } @@ -666,7 +684,7 @@ public void a(PacketPlayInBoatMove packetplayinboatmove) { PlayerConnectionUtils.ensureMainThread(packetplayinboatmove, this, this.player.x()); -@@ -587,14 +964,29 @@ +@@ -587,14 +975,29 @@ } public void a(IChatBaseComponent ichatbasecomponent) { @@ -698,7 +716,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(); -@@ -616,6 +1008,15 @@ +@@ -616,6 +1019,15 @@ } } @@ -714,7 +732,7 @@ try { this.networkManager.sendPacket(packet); } catch (Throwable throwable) { -@@ -637,17 +1038,32 @@ +@@ -637,17 +1049,32 @@ public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) { PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.x()); @@ -749,7 +767,7 @@ ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]); chatmessage.getChatModifier().setColor(EnumChatFormat.RED); -@@ -660,39 +1076,249 @@ +@@ -660,39 +1087,249 @@ for (int i = 0; i < s.length(); ++i) { if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) { @@ -1007,7 +1025,7 @@ this.player.resetIdleTimer(); IJumpable ijumpable; -@@ -762,6 +1388,7 @@ +@@ -762,6 +1399,7 @@ public void a(PacketPlayInUseEntity packetplayinuseentity) { PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.x()); @@ -1015,7 +1033,7 @@ WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); Entity entity = packetplayinuseentity.a((World) worldserver); -@@ -778,22 +1405,72 @@ +@@ -778,22 +1416,72 @@ EnumHand enumhand; ItemStack itemstack; @@ -1089,7 +1107,7 @@ } } } -@@ -809,7 +1486,8 @@ +@@ -809,7 +1497,8 @@ case 1: if (this.player.viewingCredits) { this.player.viewingCredits = false; @@ -1099,7 +1117,7 @@ } else { if (this.player.getHealth() > 0.0F) { return; -@@ -835,14 +1513,20 @@ +@@ -835,14 +1524,20 @@ public void a(PacketPlayInCloseWindow packetplayinclosewindow) { PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.x()); @@ -1121,7 +1139,7 @@ ArrayList arraylist = Lists.newArrayList(); for (int i = 0; i < this.player.activeContainer.c.size(); ++i) { -@@ -851,8 +1535,275 @@ +@@ -851,8 +1546,275 @@ this.player.a(this.player.activeContainer, (List) arraylist); } else { @@ -1398,7 +1416,7 @@ if (ItemStack.matches(packetplayinwindowclick.e(), itemstack)) { this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.a(), packetplayinwindowclick.d(), true)); this.player.f = true; -@@ -915,8 +1866,48 @@ +@@ -915,8 +1877,48 @@ } boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() <= 45; @@ -1448,7 +1466,7 @@ if (flag1 && flag2 && flag3) { if (itemstack == null) { -@@ -940,6 +1931,7 @@ +@@ -940,6 +1942,7 @@ public void a(PacketPlayInTransaction packetplayintransaction) { PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.x()); @@ -1456,7 +1474,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()) { -@@ -950,6 +1942,7 @@ +@@ -950,6 +1953,7 @@ public void a(PacketPlayInUpdateSign packetplayinupdatesign) { PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.x()); @@ -1464,7 +1482,7 @@ this.player.resetIdleTimer(); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); BlockPosition blockposition = packetplayinupdatesign.a(); -@@ -966,14 +1959,30 @@ +@@ -966,14 +1970,30 @@ if (!tileentitysign.b() || tileentitysign.c() != this.player) { this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign"); @@ -1496,7 +1514,7 @@ tileentitysign.update(); worldserver.notify(blockposition, iblockdata, iblockdata, 3); -@@ -996,11 +2005,27 @@ +@@ -996,11 +2016,27 @@ public void a(PacketPlayInAbilities packetplayinabilities) { PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.x()); @@ -1525,7 +1543,7 @@ ArrayList arraylist = Lists.newArrayList(); Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b(), packetplayintabcomplete.c()).iterator(); -@@ -1334,12 +2359,34 @@ +@@ -1334,12 +2370,34 @@ packetdataserializer.release(); } } -- cgit v1.2.3