mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-06 10:49:40 +01:00
4104545b11
"It was from a different time before books were as jank as they are now. As time has gone on they've only proven to be worse and worse."
65 lines
4.4 KiB
Diff
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 c17c504acdc12b6ef37d6643eb98a57fa5ca40c9..13e730b18c346934c061fb570048623ad66e7344 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
@@ -390,4 +390,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/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index 05d5d976c18149491124263b056224a384eee06d..5999417f4a357a895757e13f9b69fc970595be2e 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -532,6 +532,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
|
}
|
|
speed *= 2f; // TODO: Get the speed of the vehicle instead of the player
|
|
|
|
+ // Paper start - Prevent moving into unloaded chunks
|
|
+ if (player.level.paperConfig.preventMovingIntoUnloadedChunks && worldserver.getChunkIfLoadedImmediately((int) Math.floor(packet.getX()) >> 4, (int) Math.floor(packet.getZ()) >> 4) == null) {
|
|
+ this.connection.send(new ClientboundMoveVehiclePacket(entity));
|
|
+ return;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
if (d10 - d9 > Math.max(100.0D, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isSingleplayerOwner()) {
|
|
// CraftBukkit end
|
|
ServerGamePacketListenerImpl.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getName().getString(), this.player.getName().getString(), d6, d7, d8);
|
|
@@ -1168,9 +1175,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
|
float prevYaw = this.player.getYRot();
|
|
float prevPitch = this.player.getXRot();
|
|
// CraftBukkit end
|
|
- double d3 = this.player.getX();
|
|
+ double d3 = this.player.getX(); final double toX = d3; // Paper - OBFHELPER
|
|
double d4 = this.player.getY();
|
|
- double d5 = this.player.getZ();
|
|
+ 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;
|
|
@@ -1208,6 +1215,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
|
} else {
|
|
speed = this.player.getAbilities().walkingSpeed * 10f;
|
|
}
|
|
+ // Paper start - Prevent moving into unloaded chunks
|
|
+ if (player.level.paperConfig.preventMovingIntoUnloadedChunks && (this.player.getX() != toX || this.player.getZ() != toZ) && !worldserver.hasChunk((int) Math.floor(toX) >> 4, (int) Math.floor(toZ) >> 4)) {
|
|
+ this.internalTeleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot(), Collections.emptySet(), true);
|
|
+ return;
|
|
+ }
|
|
+ // Paper end
|
|
|
|
if (!this.player.isChangingDimension() && (!this.player.getLevel().getGameRules().getBoolean(GameRules.RULE_DISABLE_ELYTRA_MOVEMENT_CHECK) || !this.player.isFallFlying())) {
|
|
float f2 = this.player.isFallFlying() ? 300.0F : 100.0F;
|