Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-15 02:50:09 +01:00
a207d14a0e
Signed-off-by: Mariell Hoversholm <proximyst@proximyst.com>
67 Zeilen
4.3 KiB
Diff
67 Zeilen
4.3 KiB
Diff
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/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index ab45497e8f7720c9d60626b32e9c95779af676b0..3a114bec14fcc6c1e1045e2b99178a6adb25f387 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -516,19 +516,24 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
|
|
|
|
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();
|
|
- double d3 = packet.getX();
|
|
- double d4 = packet.getY();
|
|
- double d5 = packet.getZ();
|
|
+ double d0 = entity.getX();double fromX = d0; // Paper - OBFHELPER
|
|
+ double d1 = entity.getY();double fromY = d1; // Paper - OBFHELPER
|
|
+ double d2 = entity.getZ();double fromZ = d2; // Paper - OBFHELPER
|
|
+ double d3 = packet.getX();double toX = d3; // Paper - OBFHELPER
|
|
+ double d4 = packet.getY();double toY = d4; // Paper - OBFHELPER
|
|
+ double d5 = packet.getZ();double toZ = d5; // Paper - OBFHELPER
|
|
float f = packet.getYRot();
|
|
float f1 = packet.getXRot();
|
|
double d6 = d3 - this.vehicleFirstGoodX;
|
|
double d7 = d4 - this.vehicleFirstGoodY;
|
|
double d8 = d5 - this.vehicleFirstGoodZ;
|
|
double d9 = entity.getDeltaMovement().lengthSqr();
|
|
- 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
|
|
@@ -1230,7 +1235,7 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
|
|
double d2 = this.player.getZ();
|
|
double d3 = this.player.getY();
|
|
double d4 = packet.getX(this.player.getX());double toX = d4; // Paper - OBFHELPER
|
|
- double d5 = packet.getY(this.player.getY());
|
|
+ double d5 = packet.getY(this.player.getY());double toY = d5; // Paper - OBFHELPER
|
|
double d6 = packet.getZ(this.player.getZ());double toZ = d6; // Paper - OBFHELPER
|
|
float f = packet.getYRot(this.player.yRot);
|
|
float f1 = packet.getXRot(this.player.xRot);
|
|
@@ -1238,7 +1243,12 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
|
|
double d8 = d5 - this.firstGoodY;
|
|
double d9 = d6 - this.firstGoodZ;
|
|
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);
|
|
+ // Paper end - fix large move vectors killing the server
|
|
|
|
if (this.player.isSleeping()) {
|
|
if (d11 > 1.0D) {
|