2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2022-09-26 10:02:51 +02:00
|
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
2021-06-11 14:02:28 +02:00
|
|
|
Date: Sun, 17 May 2020 23:47:33 -0700
|
|
|
|
Subject: [PATCH] Fix for large move vectors crashing server
|
|
|
|
|
|
|
|
Check movement distance also based on current position.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2022-12-19 11:46:55 +01:00
|
|
|
index 15b16d37928eca9f8da026df0c76a1f7cd43ba70..ebce5372a4961b8518b3c5ee1f727705c8b68152 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2022-12-19 11:46:55 +01:00
|
|
|
@@ -563,9 +563,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
if (entity != this.player && entity.getControllingPassenger() == this.player && entity == this.lastVehicle) {
|
|
|
|
ServerLevel worldserver = this.player.getLevel();
|
|
|
|
- double d0 = entity.getX();
|
|
|
|
- double d1 = entity.getY();
|
|
|
|
- double d2 = entity.getZ();
|
2021-06-14 18:58:00 +02:00
|
|
|
+ double d0 = entity.getX();final double fromX = d0; // Paper - OBFHELPER
|
|
|
|
+ double d1 = entity.getY();final double fromY = d1; // Paper - OBFHELPER
|
|
|
|
+ double d2 = entity.getZ();final double fromZ = d2; // Paper - OBFHELPER
|
2022-03-14 20:28:02 +01:00
|
|
|
double d3 = ServerGamePacketListenerImpl.clampHorizontal(packet.getX()); final double toX = d3; // Paper - OBFHELPER
|
|
|
|
double d4 = ServerGamePacketListenerImpl.clampVertical(packet.getY()); final double toY = d4; // Paper - OBFHELPER
|
|
|
|
double d5 = ServerGamePacketListenerImpl.clampHorizontal(packet.getZ()); final double toZ = d5; // Paper - OBFHELPER
|
2022-12-19 11:46:55 +01:00
|
|
|
@@ -575,8 +575,19 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
2021-06-11 14:02:28 +02:00
|
|
|
double d7 = d4 - this.vehicleFirstGoodY;
|
|
|
|
double d8 = d5 - this.vehicleFirstGoodZ;
|
|
|
|
double d9 = entity.getDeltaMovement().lengthSqr();
|
|
|
|
- double d10 = d6 * d6 + d7 * d7 + d8 * d8;
|
2021-08-26 04:16:27 +02:00
|
|
|
-
|
2021-06-11 14:02:28 +02:00
|
|
|
+ // Paper start - fix large move vectors killing the server
|
|
|
|
+ double currDeltaX = toX - fromX;
|
|
|
|
+ double currDeltaY = toY - fromY;
|
|
|
|
+ double currDeltaZ = toZ - fromZ;
|
|
|
|
+ double d10 = Math.max(d6 * d6 + d7 * d7 + d8 * d8, (currDeltaX * currDeltaX + currDeltaY * currDeltaY + currDeltaZ * currDeltaZ) - 1);
|
|
|
|
+ // Paper end - fix large move vectors killing the server
|
2021-08-26 04:16:27 +02:00
|
|
|
+
|
|
|
|
+ // Paper start - fix large move vectors killing the server
|
|
|
|
+ double otherFieldX = d3 - this.vehicleLastGoodX;
|
|
|
|
+ double otherFieldY = d4 - this.vehicleLastGoodY - 1.0E-6D;
|
|
|
|
+ double otherFieldZ = d5 - this.vehicleLastGoodZ;
|
|
|
|
+ d10 = Math.max(d10, (otherFieldX * otherFieldX + otherFieldY * otherFieldY + otherFieldZ * otherFieldZ) - 1);
|
|
|
|
+ // Paper end - fix large move vectors killing the server
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
// CraftBukkit start - handle custom speeds and skipped ticks
|
2021-08-26 04:16:27 +02:00
|
|
|
this.allowedPlayerTicks += (System.currentTimeMillis() / 50) - this.lastTick;
|
2022-12-19 11:46:55 +01:00
|
|
|
@@ -622,9 +633,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
2021-08-26 04:16:27 +02:00
|
|
|
|
|
|
|
boolean flag = worldserver.noCollision(entity, entity.getBoundingBox().deflate(0.0625D));
|
|
|
|
|
|
|
|
- d6 = d3 - this.vehicleLastGoodX;
|
|
|
|
- d7 = d4 - this.vehicleLastGoodY - 1.0E-6D;
|
|
|
|
- d8 = d5 - this.vehicleLastGoodZ;
|
|
|
|
+ d6 = d3 - this.vehicleLastGoodX; // Paper - diff on change, used for checking large move vectors above
|
|
|
|
+ d7 = d4 - this.vehicleLastGoodY - 1.0E-6D; // Paper - diff on change, used for checking large move vectors above
|
|
|
|
+ d8 = d5 - this.vehicleLastGoodZ; // Paper - diff on change, used for checking large move vectors above
|
2022-03-01 06:43:03 +01:00
|
|
|
boolean flag1 = entity.verticalCollisionBelow;
|
2021-08-26 04:16:27 +02:00
|
|
|
|
2022-03-01 06:43:03 +01:00
|
|
|
entity.move(MoverType.PLAYER, new Vec3(d6, d7, d8));
|
2022-12-19 11:46:55 +01:00
|
|
|
@@ -1344,7 +1355,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
2021-06-14 18:58:00 +02:00
|
|
|
double d8 = d1 - this.firstGoodY;
|
|
|
|
double d9 = d2 - this.firstGoodZ;
|
2021-06-11 14:02:28 +02:00
|
|
|
double d10 = this.player.getDeltaMovement().lengthSqr();
|
|
|
|
- double d11 = d7 * d7 + d8 * d8 + d9 * d9;
|
|
|
|
+ // Paper start - fix large move vectors killing the server
|
|
|
|
+ double currDeltaX = toX - prevX;
|
|
|
|
+ double currDeltaY = toY - prevY;
|
|
|
|
+ double currDeltaZ = toZ - prevZ;
|
|
|
|
+ double d11 = Math.max(d7 * d7 + d8 * d8 + d9 * d9, (currDeltaX * currDeltaX + currDeltaY * currDeltaY + currDeltaZ * currDeltaZ) - 1);
|
2021-08-26 04:16:27 +02:00
|
|
|
+ // Paper end - fix large move vectors killing the server
|
|
|
|
+ // Paper start - fix large move vectors killing the server
|
|
|
|
+ double otherFieldX = d0 - this.lastGoodX;
|
|
|
|
+ double otherFieldY = d1 - this.lastGoodY;
|
|
|
|
+ double otherFieldZ = d2 - this.lastGoodZ;
|
|
|
|
+ d11 = Math.max(d11, (otherFieldX * otherFieldX + otherFieldY * otherFieldY + otherFieldZ * otherFieldZ) - 1);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ // Paper end - fix large move vectors killing the server
|
|
|
|
|
|
|
|
if (this.player.isSleeping()) {
|
|
|
|
if (d11 > 1.0D) {
|
2022-12-19 11:46:55 +01:00
|
|
|
@@ -1396,9 +1418,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
2021-08-26 04:16:27 +02:00
|
|
|
|
|
|
|
AABB axisalignedbb = this.player.getBoundingBox();
|
|
|
|
|
|
|
|
- d7 = d0 - this.lastGoodX;
|
|
|
|
- d8 = d1 - this.lastGoodY;
|
|
|
|
- d9 = d2 - this.lastGoodZ;
|
|
|
|
+ d7 = d0 - this.lastGoodX; // Paper - diff on change, used for checking large move vectors above
|
|
|
|
+ d8 = d1 - this.lastGoodY; // Paper - diff on change, used for checking large move vectors above
|
|
|
|
+ d9 = d2 - this.lastGoodZ; // Paper - diff on change, used for checking large move vectors above
|
|
|
|
boolean flag = d8 > 0.0D;
|
|
|
|
|
|
|
|
if (this.player.isOnGround() && !packet.isOnGround() && flag) {
|