diff options
author | Thinkofdeath <thinkofdeath@spigotmc.org> | 2015-01-20 18:14:00 +0000 |
---|---|---|
committer | Thinkofdeath <thinkofdeath@spigotmc.org> | 2015-01-22 22:25:36 +0000 |
commit | 9cd081f1ad879b1b79e87352ad87da71d5d226c9 (patch) | |
tree | 80ab1b492f12099458adfb35c44ae08469f66d3a /nms-patches/PlayerConnection.patch | |
parent | 1092acbddf07edfa4100bc6824504ac75088e913 (diff) | |
download | craftbukkit-movement-fix.tar craftbukkit-movement-fix.tar.gz craftbukkit-movement-fix.tar.lz craftbukkit-movement-fix.tar.xz craftbukkit-movement-fix.zip |
Rework speed limiting to better handle server-set high velocitiesmovement-fix
Diffstat (limited to 'nms-patches/PlayerConnection.patch')
-rw-r--r-- | nms-patches/PlayerConnection.patch | 91 |
1 files changed, 50 insertions, 41 deletions
diff --git a/nms-patches/PlayerConnection.patch b/nms-patches/PlayerConnection.patch index 3ef33867..c20ae44a 100644 --- a/nms-patches/PlayerConnection.patch +++ b/nms-patches/PlayerConnection.patch @@ -1,5 +1,5 @@ ---- ../work/decompile-8eb82bde//net/minecraft/server/PlayerConnection.java 2015-01-06 20:20:56.507791620 +0000 -+++ src/main/java/net/minecraft/server/PlayerConnection.java 2015-01-06 20:20:56.507791620 +0000 +--- ../work/decompile-8eb82bde//net/minecraft/server/PlayerConnection.java 2015-01-20 19:42:13.183932767 +0000 ++++ src/main/java/net/minecraft/server/PlayerConnection.java 2015-01-20 19:42:13.187932767 +0000 @@ -16,6 +16,48 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -227,26 +227,35 @@ this.f = this.e; double d7; double d8; -@@ -203,12 +359,14 @@ +@@ -203,16 +359,22 @@ double d11 = d7 - this.player.locX; double d12 = d8 - this.player.locY; double d13 = d9 - this.player.locZ; - double d14 = Math.min(Math.abs(d11), Math.abs(this.player.motX)); - double d15 = Math.min(Math.abs(d12), Math.abs(this.player.motY)); - double d16 = Math.min(Math.abs(d13), Math.abs(this.player.motZ)); -+ // CraftBukkit start - min to max -+ double d14 = Math.max(Math.abs(d11), Math.abs(this.player.motX)); -+ double d15 = Math.max(Math.abs(d12), Math.abs(this.player.motY)); -+ double d16 = Math.max(Math.abs(d13), Math.abs(this.player.motZ)); -+ // CraftBukkit end ++ // CraftBukkit start - just use the player's position ++ double d14 = d11; // Math.min(Math.abs(d11), Math.abs(this.player.motX)); ++ double d15 = d12; // Math.min(Math.abs(d12), Math.abs(this.player.motY)); ++ double d16 = d13; // Math.min(Math.abs(d13), Math.abs(this.player.motZ)); double d17 = d14 * d14 + d15 * d15 + d16 * d16; - if (d17 > 100.0D && (!this.minecraftServer.S() || !this.minecraftServer.R().equals(this.player.getName()))) { -+ if (d17 > 100.0D && this.checkMovement && (!this.minecraftServer.S() || !this.minecraftServer.R().equals(this.player.getName()))) { // CraftBukkit - Added this.checkMovement condition to solve this check being triggered by teleports - PlayerConnection.c.warn(this.player.getName() + " moved too quickly! " + d11 + "," + d12 + "," + d13 + " (" + d14 + ", " + d15 + ", " + d16 + ")"); +- PlayerConnection.c.warn(this.player.getName() + " moved too quickly! " + d11 + "," + d12 + "," + d13 + " (" + d14 + ", " + d15 + ", " + d16 + ")"); ++ if (d17 > this.player.movementLimit && this.checkMovement && (!this.minecraftServer.S() || !this.minecraftServer.R().equals(this.player.getName()))) { // CraftBukkit - Added this.checkMovement condition to solve this check being triggered by teleports ++ if (!this.player.hasLoggedSpeed) { ++ this.player.hasLoggedSpeed = true; ++ PlayerConnection.c.warn(this.player.getName() + " moved too quickly! " + d11 + "," + d12 + "," + d13 + " (" + d14 + ", " + d15 + ", " + d16 + ")"); ++ } ++ // CraftBukkit end this.a(this.o, this.p, this.q, this.player.yaw, this.player.pitch); return; -@@ -281,6 +439,49 @@ + } ++ this.player.movementLimit -= d17; // CraftBukkit + + float f4 = 0.0625F; + boolean flag = worldserver.getCubes(this.player, this.player.getBoundingBox().shrink((double) f4, (double) f4, (double) f4)).isEmpty(); +@@ -281,6 +443,49 @@ } public void a(double d0, double d1, double d2, float f, float f1, Set set) { @@ -296,7 +305,7 @@ this.checkMovement = false; this.o = d0; this.p = d1; -@@ -314,32 +515,49 @@ +@@ -314,32 +519,49 @@ public void a(PacketPlayInBlockDig packetplayinblockdig) { PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.u()); @@ -352,7 +361,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); -@@ -354,7 +572,15 @@ +@@ -354,7 +576,15 @@ if (!this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.af().a(blockposition)) { this.player.playerInteractManager.a(blockposition, packetplayinblockdig.b()); } else { @@ -368,7 +377,7 @@ } } else { if (packetplayinblockdig.c() == EnumPlayerDigType.STOP_DESTROY_BLOCK) { -@@ -374,11 +600,22 @@ +@@ -374,11 +604,22 @@ default: throw new IllegalArgumentException("Invalid player action"); } @@ -391,7 +400,7 @@ ItemStack itemstack = this.player.inventory.getItemInHand(); boolean flag = false; BlockPosition blockposition = packetplayinblockplace.a(); -@@ -390,7 +627,50 @@ +@@ -390,7 +631,50 @@ return; } @@ -443,7 +452,7 @@ } else if (blockposition.getY() >= this.minecraftServer.getMaxBuildHeight() - 1 && (enumdirection == EnumDirection.UP || blockposition.getY() >= this.minecraftServer.getMaxBuildHeight())) { ChatMessage chatmessage = new ChatMessage("build.tooHigh", new Object[] { Integer.valueOf(this.minecraftServer.getMaxBuildHeight())}); -@@ -398,9 +678,21 @@ +@@ -398,9 +682,21 @@ this.player.playerConnection.sendPacket(new PacketPlayOutChat(chatmessage)); flag = true; } else { @@ -466,7 +475,7 @@ flag = true; } -@@ -423,7 +715,8 @@ +@@ -423,7 +719,8 @@ this.player.activeContainer.b(); this.player.g = false; @@ -476,7 +485,7 @@ this.sendPacket(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, slot.rawSlotIndex, this.player.inventory.getItemInHand())); } } -@@ -437,8 +730,8 @@ +@@ -437,8 +734,8 @@ WorldServer[] aworldserver = this.minecraftServer.worldServer; int i = aworldserver.length; @@ -487,7 +496,7 @@ if (worldserver != null) { entity = packetplayinspectate.a(worldserver); -@@ -451,10 +744,11 @@ +@@ -451,10 +748,11 @@ if (entity != null) { this.player.e((Entity) this.player); this.player.mount((Entity) null); @@ -500,7 +509,7 @@ this.player.dimension = entity.dimension; this.sendPacket(new PacketPlayOutRespawn(this.player.dimension, worldserver1.getDifficulty(), worldserver1.getWorldData().getType(), this.player.playerInteractManager.getGameMode())); worldserver1.removeEntity(this.player); -@@ -475,6 +769,9 @@ +@@ -475,6 +773,9 @@ } else { this.player.enderTeleportTo(entity.locX, entity.locY, entity.locZ); } @@ -510,7 +519,7 @@ } } -@@ -483,14 +780,29 @@ +@@ -483,14 +784,29 @@ public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) {} public void a(IChatBaseComponent ichatbasecomponent) { @@ -542,7 +551,7 @@ if (this.minecraftServer.S() && this.player.getName().equals(this.minecraftServer.R())) { PlayerConnection.c.info("Stopping singleplayer server as player logged out"); this.minecraftServer.safeShutdown(); -@@ -511,6 +823,15 @@ +@@ -511,6 +827,15 @@ return; } } @@ -558,7 +567,7 @@ try { this.networkManager.handle(packet); -@@ -524,18 +845,34 @@ +@@ -524,18 +849,34 @@ } public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) { @@ -595,7 +604,7 @@ ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]); chatmessage.getChatModifier().setColor(EnumChatFormat.RED); -@@ -548,39 +885,247 @@ +@@ -548,39 +889,247 @@ for (int i = 0; i < s.length(); ++i) { if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) { @@ -851,7 +860,7 @@ this.player.z(); switch (SwitchHelperCommandActionType.b[packetplayinentityaction.b().ordinal()]) { case 1: -@@ -601,7 +1146,7 @@ +@@ -601,7 +1150,7 @@ case 5: this.player.a(false, true, true); @@ -860,7 +869,7 @@ break; case 6: -@@ -623,6 +1168,7 @@ +@@ -623,6 +1172,7 @@ } public void a(PacketPlayInUseEntity packetplayinuseentity) { @@ -868,7 +877,7 @@ PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.u()); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); Entity entity = packetplayinuseentity.a((World) worldserver); -@@ -637,18 +1183,72 @@ +@@ -637,18 +1187,72 @@ } if (this.player.h(entity) < d0) { @@ -942,7 +951,7 @@ } } } -@@ -663,7 +1263,8 @@ +@@ -663,7 +1267,8 @@ switch (SwitchHelperCommandActionType.c[enumclientcommand.ordinal()]) { case 1: if (this.player.viewingCredits) { @@ -952,7 +961,7 @@ } else if (this.player.u().getWorldData().isHardcore()) { if (this.minecraftServer.S() && this.player.getName().equals(this.minecraftServer.R())) { this.player.playerConnection.disconnect("You have died. Game over, man, it\'s game over!"); -@@ -694,15 +1295,22 @@ +@@ -694,15 +1299,22 @@ } public void a(PacketPlayInCloseWindow packetplayinclosewindow) { @@ -976,7 +985,7 @@ ArrayList arraylist = Lists.newArrayList(); for (int i = 0; i < this.player.activeContainer.c.size(); ++i) { -@@ -711,7 +1319,270 @@ +@@ -711,7 +1323,270 @@ this.player.a(this.player.activeContainer, (List) arraylist); } else { @@ -1248,7 +1257,7 @@ if (ItemStack.matches(packetplayinwindowclick.e(), itemstack)) { this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.a(), packetplayinwindowclick.d(), true)); -@@ -772,8 +1643,50 @@ +@@ -772,8 +1647,50 @@ } boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() < 36 + PlayerInventory.getHotbarSize(); @@ -1300,7 +1309,7 @@ if (flag1 && flag2 && flag3) { if (itemstack == null) { -@@ -796,6 +1709,7 @@ +@@ -796,6 +1713,7 @@ } public void a(PacketPlayInTransaction packetplayintransaction) { @@ -1308,7 +1317,7 @@ PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.u()); Short oshort = (Short) this.n.get(this.player.activeContainer.windowId); -@@ -806,6 +1720,7 @@ +@@ -806,6 +1724,7 @@ } public void a(PacketPlayInUpdateSign packetplayinupdatesign) { @@ -1316,7 +1325,7 @@ PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.u()); this.player.z(); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); -@@ -822,10 +1737,24 @@ +@@ -822,10 +1741,24 @@ if (!tileentitysign.b() || tileentitysign.c() != this.player) { this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign"); @@ -1342,7 +1351,7 @@ tileentitysign.update(); worldserver.notify(blockposition); } -@@ -847,11 +1776,28 @@ +@@ -847,11 +1780,28 @@ public void a(PacketPlayInAbilities packetplayinabilities) { PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.u()); @@ -1372,7 +1381,7 @@ ArrayList arraylist = Lists.newArrayList(); Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b()).iterator(); -@@ -891,13 +1837,15 @@ +@@ -891,13 +1841,15 @@ itemstack1 = this.player.inventory.getItemInHand(); if (itemstack1 != null) { if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) { @@ -1389,7 +1398,7 @@ return; } finally { packetdataserializer.release(); -@@ -909,27 +1857,31 @@ +@@ -909,27 +1861,31 @@ try { itemstack = packetdataserializer.i(); @@ -1433,7 +1442,7 @@ return; } finally { packetdataserializer.release(); -@@ -946,11 +1898,12 @@ +@@ -946,11 +1902,12 @@ } } catch (Exception exception2) { PlayerConnection.c.error("Couldn\'t select trade", exception2); @@ -1447,7 +1456,7 @@ packetdataserializer = packetplayincustompayload.b(); try { -@@ -986,6 +1939,7 @@ +@@ -986,6 +1943,7 @@ } } catch (Exception exception3) { PlayerConnection.c.error("Couldn\'t set command block", exception3); @@ -1455,7 +1464,7 @@ } finally { packetdataserializer.release(); } -@@ -1011,6 +1965,7 @@ +@@ -1011,6 +1969,7 @@ } } catch (Exception exception4) { PlayerConnection.c.error("Couldn\'t set beacon", exception4); @@ -1463,7 +1472,7 @@ } } } else if ("MC|ItemName".equals(packetplayincustompayload.a()) && this.player.activeContainer instanceof ContainerAnvil) { -@@ -1026,6 +1981,27 @@ +@@ -1026,6 +1985,27 @@ containeranvil.a(""); } } |