2020-10-12 00:48:05 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
|
|
|
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/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
2021-02-06 01:00:18 +01:00
|
|
|
index 5af38d36f64020d1df492ad57fafd2baf867536a..9fd9d81b1d875c4f465f8fb509b35da49695d4c8 100644
|
2020-10-12 00:48:05 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
2020-12-08 08:51:55 +01:00
|
|
|
@@ -367,19 +367,24 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
2020-10-12 00:48:05 +02:00
|
|
|
|
|
|
|
if (entity != this.player && entity.getRidingPassenger() == this.player && entity == this.r) {
|
|
|
|
WorldServer worldserver = this.player.getWorldServer();
|
|
|
|
- double d0 = entity.locX();
|
|
|
|
- double d1 = entity.locY();
|
|
|
|
- double d2 = entity.locZ();
|
|
|
|
- double d3 = packetplayinvehiclemove.getX();
|
|
|
|
- double d4 = packetplayinvehiclemove.getY();
|
|
|
|
- double d5 = packetplayinvehiclemove.getZ();
|
|
|
|
+ double d0 = entity.locX();double fromX = d0; // Paper - OBFHELPER
|
|
|
|
+ double d1 = entity.locY();double fromY = d1; // Paper - OBFHELPER
|
|
|
|
+ double d2 = entity.locZ();double fromZ = d2; // Paper - OBFHELPER
|
|
|
|
+ double d3 = packetplayinvehiclemove.getX();double toX = d3; // Paper - OBFHELPER
|
|
|
|
+ double d4 = packetplayinvehiclemove.getY();double toY = d4; // Paper - OBFHELPER
|
|
|
|
+ double d5 = packetplayinvehiclemove.getZ();double toZ = d5; // Paper - OBFHELPER
|
|
|
|
float f = packetplayinvehiclemove.getYaw();
|
|
|
|
float f1 = packetplayinvehiclemove.getPitch();
|
|
|
|
double d6 = d3 - this.s;
|
|
|
|
double d7 = d4 - this.t;
|
|
|
|
double d8 = d5 - this.u;
|
|
|
|
double d9 = entity.getMot().g();
|
|
|
|
- double d10 = d6 * d6 + d7 * d7 + d8 * d8;
|
|
|
|
+ // 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
|
|
|
|
|
|
|
|
|
|
|
|
// CraftBukkit start - handle custom speeds and skipped ticks
|
2020-12-22 23:45:10 +01:00
|
|
|
@@ -1081,7 +1086,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
2020-10-12 00:48:05 +02:00
|
|
|
double d2 = this.player.locZ();
|
|
|
|
double d3 = this.player.locY();
|
|
|
|
double d4 = packetplayinflying.a(this.player.locX());double toX = d4; // Paper - OBFHELPER
|
|
|
|
- double d5 = packetplayinflying.b(this.player.locY());
|
|
|
|
+ double d5 = packetplayinflying.b(this.player.locY());double toY = d5; // Paper - OBFHELPER
|
|
|
|
double d6 = packetplayinflying.c(this.player.locZ());double toZ = d6; // Paper - OBFHELPER
|
|
|
|
float f = packetplayinflying.a(this.player.yaw);
|
|
|
|
float f1 = packetplayinflying.b(this.player.pitch);
|
2020-12-22 23:45:10 +01:00
|
|
|
@@ -1089,7 +1094,12 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
2020-10-12 00:48:05 +02:00
|
|
|
double d8 = d5 - this.m;
|
|
|
|
double d9 = d6 - this.n;
|
|
|
|
double d10 = this.player.getMot().g();
|
|
|
|
- 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);
|
|
|
|
+ // Paper end - fix large move vectors killing the server
|
|
|
|
|
|
|
|
if (this.player.isSleeping()) {
|
|
|
|
if (d11 > 1.0D) {
|