Paper/patches/server/0536-Fix-for-large-move-vectors-crashing-server.patch
Jason bc127ea819
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#6222)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
eec4aab0 SPIGOT-6657: Add getPlayer to SheepDyeWoolEvent
205213c6 SPIGOT-6656: CauldronLevelChangeEvent is not fired correctly when dripstone fills the cauldron

CraftBukkit Changes:
b8c522d5 SPIGOT-6657: Add getPlayer to SheepDyeWoolEvent
f04a77dc SPIGOT-6656: CauldronLevelChangeEvent is not fired correctly when dripstone fills the cauldron
d1dbcebc SPIGOT-6653: Canceling snow bucket placement removes snow from bucket
4f34a67b #891: Fix scheduler task ID overflow and duplication issues

Spigot Changes:
d03d7f12 BUILDTOOLS-604: Rebuild patches
2021-07-18 09:41:53 +02:00

66 lines
4.5 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 55e824f0b0258b8bde6d9f453256edf32b2e4a32..650793ec3d9f2d30845aff1ddf1067da36ee8004 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -506,19 +506,24 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
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 = ServerGamePacketListenerImpl.clampHorizontal(packet.getX());
- double d4 = ServerGamePacketListenerImpl.clampVertical(packet.getY());
- double d5 = ServerGamePacketListenerImpl.clampHorizontal(packet.getZ());
+ 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
+ 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
float f = Mth.wrapDegrees(packet.getYRot());
float f1 = Mth.wrapDegrees(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
@@ -1232,14 +1237,19 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
float prevPitch = this.player.getXRot();
// CraftBukkit end
double d3 = this.player.getX(); final double toX = d3; // Paper - OBFHELPER
- double d4 = this.player.getY();
+ double d4 = this.player.getY(); final double toY = d4; // Paper - OBFHELPER
double d5 = this.player.getZ(); final double toZ = d5; // Paper - OBFHELPER
double d6 = this.player.getY();
double d7 = d0 - this.firstGoodX;
double d8 = d1 - this.firstGoodY;
double d9 = d2 - 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) {