Paper/Spigot-Server-Patches/0306-Add-option-to-prevent-players-from-moving-into-unloa.patch
Daniel Ennis c97ce029e9
1.16.2 Release (#4123)
PaperMC believes that 1.16.2 is now ready for general release as we fixed the main issue plagueing the 1.16.x release, the MapLike data conversion issues.

Until now, it was not safe for a server to convert a world to 1.16.2 without data conversion issues around villages and potentially other things. If you did, those MapLike errors meant something went wrong.

This is now resolved.

Big thanks to all those that helped, notably @BillyGalbreath and @Proximyst who did large parts of the update process with me.

Please as always, backup your worlds and test before updating to 1.16.2!

If you update to 1.16.2, there is no going back to an older build than this.

---------------------------------

Co-authored-by: William Blake Galbreath <Blake.Galbreath@GMail.com>
Co-authored-by: Mariell Hoversholm <proximyst@proximyst.com>
Co-authored-by: krolik-exe <69214078+krolik-exe@users.noreply.github.com>
Co-authored-by: BillyGalbreath <BillyGalbreath@users.noreply.github.com>
Co-authored-by: stonar96 <minecraft.stonar96@gmail.com>
Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
Co-authored-by: Jason <jasonpenilla2@me.com>
Co-authored-by: kashike <kashike@vq.lc>
Co-authored-by: Aurora <21148213+aurorasmiles@users.noreply.github.com>
Co-authored-by: KennyTV <kennytv@t-online.de>
Co-authored-by: commandblockguy <commandblockguy1@gmail.com>
Co-authored-by: DigitalRegent <misterwener@gmail.com>
Co-authored-by: ishland <ishlandmc@yeah.net>
2020-08-24 22:40:19 -04:00

65 lines
4.4 KiB
Diff

From 0000000000000000000000000000000000000000 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
index 098c99793c68ac916b52776f9a1cc2c6510c0057..15e1f9f65280043853544d3bf796f991df2482de 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -389,4 +389,9 @@ public class PaperWorldConfig {
waterOverLavaFlowSpeed = getInt("water-over-lava-flow-speed", 5);
log("Water over lava flow speed: " + waterOverLavaFlowSpeed);
}
+
+ public boolean preventMovingIntoUnloadedChunks = false;
+ private void preventMovingIntoUnloadedChunks() {
+ 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
index 58f6588f475e000aafede740adf4570d41a71009..ef274f5eac1c3cea0f459955432b925e37866026 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -350,6 +350,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
+ if (player.world.paperConfig.preventMovingIntoUnloadedChunks && worldserver.getChunkIfLoadedImmediately((int) Math.floor(packetplayinvehiclemove.getX()) >> 4, (int) Math.floor(packetplayinvehiclemove.getZ()) >> 4) == null) {
+ this.networkManager.sendPacket(new PacketPlayOutVehicleMove(entity));
+ return;
+ }
+ // Paper end
+
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);
@@ -913,9 +920,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;
@@ -954,6 +961,12 @@ public class PlayerConnection implements PacketListenerPlayIn {
} else {
speed = player.abilities.walkSpeed * 10f;
}
+ // Paper start - Prevent moving into unloaded chunks
+ 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
if (!this.player.H() && (!this.player.getWorldServer().getGameRules().getBoolean(GameRules.DISABLE_ELYTRA_MOVEMENT_CHECK) || !this.player.isGliding())) {
float f2 = this.player.isGliding() ? 300.0F : 100.0F;