From 1bb523c4e4b58a43f2050567c73e83beb1bd8217 Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 19 Feb 2018 09:52:00 +1100 Subject: [PATCH] SPIGOT-3829: Apply some speed limits to all entities --- nms-patches/Entity.patch | 45 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/nms-patches/Entity.patch b/nms-patches/Entity.patch index 596d2acebb..39777cd1a3 100644 --- a/nms-patches/Entity.patch +++ b/nms-patches/Entity.patch @@ -372,7 +372,7 @@ this.locX = nbttaglist.f(0); this.locY = nbttaglist.f(1); -@@ -1397,6 +1619,58 @@ +@@ -1397,6 +1619,57 @@ this.setPosition(this.locX, this.locY, this.locZ); } @@ -388,19 +388,18 @@ + } + // CraftBukkit end + -+ // CraftBukkit start - Exempt Vehicles from notch's sanity check -+ if (!(getBukkitEntity() instanceof Vehicle)) { -+ if (Math.abs(this.motX) > 10.0D) { -+ this.motX = 0.0D; -+ } ++ // CraftBukkit start ++ double limit = getBukkitEntity() instanceof Vehicle ? 100.0D : 10.0D; ++ if (Math.abs(this.motX) > limit) { ++ this.motX = 0.0D; ++ } + -+ if (Math.abs(this.motY) > 10.0D) { -+ this.motY = 0.0D; -+ } ++ if (Math.abs(this.motY) > limit) { ++ this.motY = 0.0D; ++ } + -+ if (Math.abs(this.motZ) > 10.0D) { -+ this.motZ = 0.0D; -+ } ++ if (Math.abs(this.motZ) > limit) { ++ this.motZ = 0.0D; + } + // CraftBukkit end + @@ -431,7 +430,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded"); -@@ -1464,6 +1738,12 @@ +@@ -1464,6 +1737,12 @@ if (itemstack.isEmpty()) { return null; } else { @@ -444,7 +443,7 @@ EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack); entityitem.q(); -@@ -1589,6 +1869,24 @@ +@@ -1589,6 +1868,24 @@ if (entity.bJ() != this) { throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)"); } else { @@ -469,7 +468,7 @@ if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.bE() instanceof EntityHuman)) { this.passengers.add(0, entity); } else { -@@ -1602,6 +1900,22 @@ +@@ -1602,6 +1899,22 @@ if (entity.bJ() == this) { throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)"); } else { @@ -492,7 +491,7 @@ this.passengers.remove(entity); entity.j = 60; } -@@ -1741,14 +2055,49 @@ +@@ -1741,14 +2054,49 @@ } public void setAirTicks(int i) { @@ -545,7 +544,7 @@ } } -@@ -1893,19 +2242,76 @@ +@@ -1893,19 +2241,76 @@ if (!this.world.isClientSide && !this.dead) { this.world.methodProfiler.a("changeDimension"); MinecraftServer minecraftserver = this.C_(); @@ -625,7 +624,7 @@ BlockPosition blockposition; if (i == 1) { -@@ -1934,12 +2340,18 @@ +@@ -1934,12 +2339,18 @@ blockposition = new BlockPosition(this); } @@ -645,7 +644,7 @@ if (j == 1 && i == 1) { BlockPosition blockposition1 = worldserver1.q(worldserver1.getSpawn()); -@@ -1947,6 +2359,7 @@ +@@ -1947,6 +2358,7 @@ } else { entity.setPositionRotation(blockposition, entity.yaw, entity.pitch); } @@ -653,7 +652,7 @@ boolean flag = entity.attachedToPlayer; -@@ -1954,13 +2367,21 @@ +@@ -1954,13 +2366,21 @@ worldserver1.addEntity(entity); entity.attachedToPlayer = flag; worldserver1.entityJoinedWorld(entity, false); @@ -676,7 +675,7 @@ return entity; } else { return null; -@@ -2064,6 +2485,11 @@ +@@ -2064,6 +2484,11 @@ } public void setCustomName(String s) { @@ -688,7 +687,7 @@ this.datawatcher.set(Entity.aB, s); } -@@ -2121,7 +2547,26 @@ +@@ -2121,7 +2546,26 @@ } public void a(AxisAlignedBB axisalignedbb) { @@ -716,7 +715,7 @@ } public float getHeadHeight() { -@@ -2295,7 +2740,7 @@ +@@ -2295,7 +2739,7 @@ for (Iterator iterator = this.bF().iterator(); iterator.hasNext(); entity.a(oclass, set)) { entity = (Entity) iterator.next(); if (oclass.isAssignableFrom(entity.getClass())) {