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 | |
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
-rw-r--r-- | nms-patches/EntityPlayer.patch | 69 | ||||
-rw-r--r-- | nms-patches/PlayerConnection.patch | 91 |
2 files changed, 92 insertions, 68 deletions
diff --git a/nms-patches/EntityPlayer.patch b/nms-patches/EntityPlayer.patch index fa7e23bc..bca64e24 100644 --- a/nms-patches/EntityPlayer.patch +++ b/nms-patches/EntityPlayer.patch @@ -1,5 +1,5 @@ ---- ../work/decompile-8eb82bde/net/minecraft/server/EntityPlayer.java 2015-01-09 16:51:30.962362579 +1100 -+++ src/main/java/net/minecraft/server/EntityPlayer.java 2015-01-09 16:51:30.962362579 +1100 +--- ../work/decompile-8eb82bde//net/minecraft/server/EntityPlayer.java 2015-01-22 22:25:21.173416238 +0000 ++++ src/main/java/net/minecraft/server/EntityPlayer.java 2015-01-22 22:25:21.177416238 +0000 @@ -13,6 +13,17 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -92,10 +92,25 @@ public void levelDown(int i) { super.levelDown(i); this.lastSentExp = -1; -@@ -114,6 +167,11 @@ +@@ -113,7 +166,26 @@ + this.playerConnection.sendPacket(new PacketPlayOutCombatEvent(this.br(), EnumCombatEventType.END_COMBAT)); } ++ // CraftBukkit start ++ public double movementLimit = 0; ++ public boolean hasLoggedSpeed = false; ++ public void s_() { ++ // Limit based on the server motion for the player ++ double limit = this.motX * this.motX ++ + this.motY * this.motY ++ + this.motZ * this.motZ; ++ limit *= 1.5; // Give a little extra room ++ limit = Math.max(4, limit); ++ hasLoggedSpeed = false; ++ movementLimit = Math.min(movementLimit + limit, 2000); ++ // CraftBukkit end ++ + // CraftBukkit start + if (this.joining) { + this.joining = false; @@ -104,7 +119,7 @@ this.playerInteractManager.a(); --this.invulnerableTicks; if (this.noDamageTicks > 0) { -@@ -155,7 +213,7 @@ +@@ -155,7 +227,7 @@ chunk = this.world.getChunkAt(chunkcoordintpair.x, chunkcoordintpair.z); if (chunk.isReady()) { arraylist.add(chunk); @@ -113,7 +128,7 @@ iterator1.remove(); } } -@@ -220,8 +278,9 @@ +@@ -220,8 +292,9 @@ } } @@ -124,7 +139,7 @@ this.bK = this.getHealth(); this.bL = this.foodData.getFoodLevel(); this.bM = this.foodData.getSaturationLevel() == 0.0F; -@@ -229,15 +288,14 @@ +@@ -229,15 +302,14 @@ if (this.getHealth() + this.getAbsorptionHearts() != this.bJ) { this.bJ = this.getHealth() + this.getAbsorptionHearts(); @@ -138,16 +153,16 @@ - } + // CraftBukkit - Update ALL the scores! + this.world.getServer().getScoreboardManager().updateAllScoresForList(IScoreboardCriteria.g, this.getName(), com.google.common.collect.ImmutableList.of(this)); -+ } + } + // CraftBukkit start - Force max health updates + if (this.maxHealthCache != this.getMaxHealth()) { + this.getBukkitEntity().updateScaledHealth(); - } ++ } + // CraftBukkit end if (this.expTotal != this.lastSentExp) { this.lastSentExp = this.expTotal; -@@ -247,7 +305,17 @@ +@@ -247,7 +319,17 @@ if (this.ticksLived % 20 * 5 == 0 && !this.getStatisticManager().hasAchievement(AchievementList.L)) { this.h_(); } @@ -165,7 +180,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Ticking player"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Player being ticked"); -@@ -296,30 +364,64 @@ +@@ -296,30 +378,64 @@ } public void die(DamageSource damagesource) { @@ -243,7 +258,7 @@ scoreboardscore.incrementScore(); } -@@ -376,7 +478,8 @@ +@@ -376,7 +492,8 @@ } private boolean cq() { @@ -253,7 +268,7 @@ } public void c(int i) { -@@ -388,6 +491,8 @@ +@@ -388,6 +505,8 @@ } else { if (this.dimension == 0 && i == 1) { this.b((Statistic) AchievementList.C); @@ -262,7 +277,7 @@ BlockPosition blockposition = this.server.getWorldServer(i).getDimensionSpawn(); if (blockposition != null) { -@@ -395,11 +500,16 @@ +@@ -395,11 +514,16 @@ } i = 1; @@ -280,7 +295,7 @@ this.lastSentExp = -1; this.bK = -1.0F; this.bL = -1; -@@ -442,6 +552,8 @@ +@@ -442,6 +566,8 @@ } public void a(boolean flag, boolean flag1, boolean flag2) { @@ -289,7 +304,7 @@ if (this.isSleeping()) { this.u().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(this, 2)); } -@@ -490,19 +602,46 @@ +@@ -490,19 +616,46 @@ this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition())); } @@ -338,7 +353,7 @@ if (this.activeContainer != this.defaultContainer) { this.closeInventory(); } -@@ -510,9 +649,11 @@ +@@ -510,9 +663,11 @@ if (iinventory instanceof ITileInventory) { ITileInventory itileinventory = (ITileInventory) iinventory; @@ -351,7 +366,7 @@ return; } } -@@ -520,10 +661,10 @@ +@@ -520,10 +675,10 @@ this.nextContainerCounter(); if (iinventory instanceof ITileEntityContainer) { this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, ((ITileEntityContainer) iinventory).getContainerName(), iinventory.getScoreboardDisplayName(), iinventory.getSize())); @@ -364,7 +379,7 @@ } this.activeContainer.windowId = this.containerCounter; -@@ -531,8 +672,14 @@ +@@ -531,8 +686,14 @@ } public void openTrade(IMerchant imerchant) { @@ -380,7 +395,7 @@ this.activeContainer.windowId = this.containerCounter; this.activeContainer.addSlotListener(this); InventoryMerchant inventorymerchant = ((ContainerMerchant) this.activeContainer).e(); -@@ -552,13 +699,20 @@ +@@ -552,13 +713,20 @@ } public void openHorseInventory(EntityHorse entityhorse, IInventory iinventory) { @@ -402,7 +417,7 @@ this.activeContainer.windowId = this.containerCounter; this.activeContainer.addSlotListener(this); } -@@ -587,6 +741,11 @@ +@@ -587,6 +755,11 @@ public void a(Container container, List list) { this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, list)); this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried())); @@ -414,7 +429,7 @@ } public void setContainerData(Container container, int i, int j) { -@@ -601,6 +760,7 @@ +@@ -601,6 +774,7 @@ } public void closeInventory() { @@ -422,7 +437,7 @@ this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId)); this.p(); } -@@ -681,7 +841,16 @@ +@@ -681,7 +855,16 @@ public void triggerHealthUpdate() { this.bK = -1.0E8F; @@ -439,7 +454,7 @@ public void b(IChatBaseComponent ichatbasecomponent) { this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent)); -@@ -747,6 +916,8 @@ +@@ -747,6 +930,8 @@ } public void a(EnumGamemode enumgamemode) { @@ -448,7 +463,7 @@ this.playerInteractManager.setGameMode(enumgamemode); this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, (float) enumgamemode.getId())); if (enumgamemode == EnumGamemode.SPECTATOR) { -@@ -757,6 +928,7 @@ +@@ -757,6 +942,7 @@ this.updateAbilities(); this.bO(); @@ -456,7 +471,7 @@ } public boolean v() { -@@ -768,6 +940,7 @@ +@@ -768,6 +954,7 @@ } public boolean a(int i, String s) { @@ -464,7 +479,7 @@ if ("seed".equals(s) && !this.server.ad()) { return true; } else if (!"tell".equals(s) && !"help".equals(s) && !"me".equals(s) && !"trigger".equals(s)) { -@@ -781,6 +954,9 @@ +@@ -781,6 +968,9 @@ } else { return true; } @@ -474,7 +489,7 @@ } public String w() { -@@ -867,6 +1043,129 @@ +@@ -867,6 +1057,129 @@ } public IChatBaseComponent getPlayerListName() { 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(""); } } |