mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-19 14:59:25 +00:00
74 lines
6.1 KiB
Diff
74 lines
6.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
|
Date: Sat, 1 Feb 2025 18:03:13 +0300
|
|
Subject: [PATCH] Option to allow weird movement and disable teleporting
|
|
players when they move too quickly
|
|
|
|
|
|
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index b44afe316fc8d886b9a21102cddf20d977169c51..b58fc16f9054f36d5ddb2dffabd9274969e56897 100644
|
|
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -609,7 +609,7 @@ public class ServerGamePacketListenerImpl
|
|
return;
|
|
}
|
|
// Paper end - Prevent moving into unloaded chunks
|
|
- if (d7 - d6 > Math.max(100.0, Mth.square(org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed)) && !this.isSingleplayerOwner()) {
|
|
+ if (!org.bxteam.divinemc.config.DivineConfig.FixesCategory.alwaysAllowWeirdMovement && (d7 - d6 > Math.max(100.0, Mth.square(org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed)) && !this.isSingleplayerOwner())) { // DivineMC - stop weird movement
|
|
// CraftBukkit end
|
|
LOGGER.warn(
|
|
"{} (vehicle of {}) moved too quickly! {},{},{}", rootVehicle.getName().getString(), this.player.getName().getString(), d3, d4, d5
|
|
@@ -639,7 +639,7 @@ public class ServerGamePacketListenerImpl
|
|
d5 = d2 - rootVehicle.getZ();
|
|
d7 = d3 * d3 + d4 * d4 + d5 * d5;
|
|
boolean flag1 = false;
|
|
- if (d7 > org.spigotmc.SpigotConfig.movedWronglyThreshold) { // Spigot
|
|
+ if (!org.bxteam.divinemc.config.DivineConfig.FixesCategory.alwaysAllowWeirdMovement && (d7 > org.spigotmc.SpigotConfig.movedWronglyThreshold)) { // Spigot // DivineMC - stop weird movement
|
|
flag1 = true; // Paper - diff on change, this should be moved wrongly
|
|
LOGGER.warn("{} (vehicle of {}) moved wrongly! {}", rootVehicle.getName().getString(), this.player.getName().getString(), Math.sqrt(d7));
|
|
}
|
|
@@ -1557,20 +1557,24 @@ public class ServerGamePacketListenerImpl
|
|
if (this.shouldCheckPlayerMovement(isFallFlying)) {
|
|
float f2 = isFallFlying ? 300.0F : 100.0F;
|
|
if (d7 - d6 > Math.max(f2, Mth.square(org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed))) {
|
|
- // CraftBukkit end
|
|
- // Paper start - Add fail move event
|
|
- io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.MOVED_TOO_QUICKLY,
|
|
+ // DivineMC start - Stop teleporting players when they move too quickly
|
|
+ if (!org.bxteam.divinemc.config.DivineConfig.FixesCategory.alwaysAllowWeirdMovement && !(org.bxteam.divinemc.config.DivineConfig.FixesCategory.ignoreMovedTooQuicklyWhenLagging && player.level().getServer().lagging)) {
|
|
+ // CraftBukkit end
|
|
+ // Paper start - Add fail move event
|
|
+ io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.MOVED_TOO_QUICKLY,
|
|
toX, toY, toZ, toYaw, toPitch, true);
|
|
- if (!event.isAllowed()) {
|
|
- if (event.getLogWarning()) {
|
|
- LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getName().getString(), d3, d4, d5);
|
|
- }
|
|
- this.teleport(
|
|
+ if (!event.isAllowed()) {
|
|
+ if (event.getLogWarning()) {
|
|
+ LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getName().getString(), d3, d4, d5);
|
|
+ }
|
|
+ this.teleport(
|
|
this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot()
|
|
- );
|
|
- return;
|
|
+ );
|
|
+ return;
|
|
+ }
|
|
+ // Paper end - Add fail move event
|
|
}
|
|
- // Paper end - Add fail move event
|
|
+ // DivineMC end - Stop teleporting players when they move too quickly
|
|
}
|
|
}
|
|
}
|
|
@@ -1631,6 +1635,7 @@ public class ServerGamePacketListenerImpl
|
|
d7 = d3 * d3 + d4 * d4 + d5 * d5;
|
|
boolean movedWrongly = false; // Paper - Add fail move event; rename
|
|
if (!this.player.isChangingDimension()
|
|
+ && !org.bxteam.divinemc.config.DivineConfig.FixesCategory.alwaysAllowWeirdMovement // DivineMC - Stop teleporting players when they move too quickly
|
|
&& d7 > org.spigotmc.SpigotConfig.movedWronglyThreshold // Spigot
|
|
&& !this.player.isSleeping()
|
|
&& !this.player.isCreative()
|