Paper/Spigot-Server-Patches/0336-Add-option-to-prevent-players-from-moving-into-unloa.patch

69 Zeilen
4.2 KiB
Diff

2019-05-05 13:32:20 +02:00
From aa5ca3c61f40bcade5ce13c3312c921dc374e0cb Mon Sep 17 00:00:00 2001
From: Gabriele C <sgdc3.mail@gmail.com>
Date: Mon, 22 Oct 2018 17:34:10 +0200
Subject: [PATCH] Add option to prevent players from moving into unloaded
chunks #1551
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
2019-05-05 13:12:32 +02:00
index fb44fccc9..ad793ffa3 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
2019-05-05 13:12:32 +02:00
@@ -434,4 +434,9 @@ public class PaperWorldConfig {
this.armorStandTick = this.getBoolean("armor-stands-tick", this.armorStandTick);
log("ArmorStand ticking is " + (this.armorStandTick ? "enabled" : "disabled") + " by default");
}
+
+ public boolean preventMovingIntoUnloadedChunks = false;
+ private void preventMovingIntoUnloadedChunks() {
2018-10-24 14:38:34 +02:00
+ preventMovingIntoUnloadedChunks = getBoolean("prevent-moving-into-unloaded-chunks", false);
+ }
}
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
2019-05-05 13:12:32 +02:00
index e59037211..16a7aba49 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
2019-05-05 13:12:32 +02:00
@@ -348,6 +348,13 @@ public class PlayerConnection implements PacketListenerPlayIn {
}
speed *= 2f; // TODO: Get the speed of the vehicle instead of the player
+ // Paper start - Prevent moving into unloaded chunks
2019-05-05 13:12:32 +02:00
+ if (player.world.paperConfig.preventMovingIntoUnloadedChunks && !worldserver.isChunkLoaded((int) Math.floor(packetplayinvehiclemove.getX()) >> 4, (int) Math.floor(packetplayinvehiclemove.getZ()) >> 4)) {
+ this.networkManager.sendPacket(new PacketPlayOutVehicleMove(entity));
+ return;
+ }
+ // Paper end
+
2019-05-05 13:12:32 +02:00
if (d10 - d9 > Math.max(100.0D, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isExemptPlayer()) {
// CraftBukkit end
PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getDisplayName().getString(), this.player.getDisplayName().getString(), d6, d7, d8);
2019-05-05 13:12:32 +02:00
@@ -889,9 +896,9 @@ public class PlayerConnection implements PacketListenerPlayIn {
double d1 = this.player.locY;
double d2 = this.player.locZ;
double d3 = this.player.locY;
- double d4 = packetplayinflying.a(this.player.locX);
+ double d4 = packetplayinflying.a(this.player.locX);double toX = d4; // Paper - OBFHELPER
double d5 = packetplayinflying.b(this.player.locY);
- double d6 = packetplayinflying.c(this.player.locZ);
+ 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);
double d7 = d4 - this.l;
2019-05-05 13:12:32 +02:00
@@ -931,6 +938,13 @@ public class PlayerConnection implements PacketListenerPlayIn {
speed = player.abilities.walkSpeed * 10f;
}
+ // Paper start - Prevent moving into unloaded chunks
2019-05-05 13:12:32 +02:00
+ if (player.world.paperConfig.preventMovingIntoUnloadedChunks && (this.player.locX != toX || this.player.locZ != toZ) && !worldserver.isChunkLoaded((int) Math.floor(toX) >> 4, (int) Math.floor(toZ) >> 4)) {
+ this.internalTeleport(this.player.locX, this.player.locY, this.player.locZ, this.player.yaw, this.player.pitch, Collections.emptySet());
+ return;
+ }
+ // Paper end
+
2019-05-05 13:12:32 +02:00
if (!this.player.H() && (!this.player.getWorldServer().getGameRules().getBoolean("disableElytraMovementCheck") || !this.player.isGliding())) {
float f2 = this.player.isGliding() ? 300.0F : 100.0F;
--
2019-05-05 13:32:20 +02:00
2.21.0