2017-07-27 01:12:40 +00:00
From 19b25abf11a53f5f7cf115cfdc267a7132fde3fd Mon Sep 17 00:00:00 2001
2016-04-03 21:34:15 +00:00
From: Aikar <aikar@aikar.co>
Date: Sat, 13 Sep 2014 23:14:43 -0400
Subject: [PATCH] Configurable Keep Spawn Loaded range per world
This lets you disable it for some worlds and lower it for others.
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
2017-07-27 01:12:40 +00:00
index 74a49a5fb..3a942c763 100644
2016-04-03 21:34:15 +00:00
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
2017-03-25 03:18:58 +00:00
@@ -284,4 +284,10 @@ public class PaperWorldConfig {
2016-04-03 21:34:15 +00:00
grassUpdateRate = Math.max(0, getInt("grass-spread-tick-rate", grassUpdateRate));
log("Grass Spread Tick Rate: " + grassUpdateRate);
}
+
+ public short keepLoadedRange;
+ private void keepLoadedRange() {
2016-04-04 03:08:13 +00:00
+ keepLoadedRange = (short) (getInt("keep-spawn-loaded-range", Math.min(spigotConfig.viewDistance, 8)) * 16);
2016-04-03 21:34:15 +00:00
+ log( "Keep Spawn Loaded Range: " + (keepLoadedRange/16));
+ }
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
2017-07-27 01:12:40 +00:00
index 6e11ba5b6..71b66bbdf 100644
2016-04-03 21:34:15 +00:00
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
2017-05-14 18:05:01 +00:00
@@ -356,8 +356,11 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
2016-11-17 02:23:38 +00:00
long j = aw();
2016-04-03 21:34:15 +00:00
i = 0;
- for (int k = -192; k <= 192 && this.isRunning(); k += 16) {
- for (int l = -192; l <= 192 && this.isRunning(); l += 16) {
2016-11-17 02:23:38 +00:00
+ // Paper start
+ short radius = worldserver.paperConfig.keepLoadedRange;
+ for (int k = -radius; k <= radius && this.isRunning(); k += 16) {
+ for (int l = -radius; l <= radius && this.isRunning(); l += 16) {
+ // Paper end
long i1 = aw();
2016-04-03 21:34:15 +00:00
if (i1 - j > 1000L) {
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
2017-07-27 01:12:40 +00:00
index 553d9724b..e9446b9ce 100644
2016-04-03 21:34:15 +00:00
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
2017-06-19 01:36:55 +00:00
@@ -3208,8 +3208,9 @@ public abstract class World implements IBlockAccess {
2016-04-03 21:34:15 +00:00
int k = i * 16 + 8 - blockposition.getX();
int l = j * 16 + 8 - blockposition.getZ();
2016-06-09 03:57:14 +00:00
boolean flag = true;
+ short keepLoadedRange = paperConfig.keepLoadedRange; // Paper
2016-04-03 21:34:15 +00:00
2016-06-09 03:57:14 +00:00
- return k >= -128 && k <= 128 && l >= -128 && l <= 128 && this.keepSpawnInMemory; // CraftBukkit - Added 'this.keepSpawnInMemory'
+ return k >= -keepLoadedRange && k <= keepLoadedRange && l >= -keepLoadedRange && l <= keepLoadedRange && this.keepSpawnInMemory; // CraftBukkit - Added 'this.keepSpawnInMemory' // Paper - Re-add range var
2016-04-03 21:34:15 +00:00
}
2016-06-09 03:57:14 +00:00
public void a(Packet<?> packet) {
2016-04-03 21:34:15 +00:00
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
2017-07-27 01:12:40 +00:00
index 0f7c67256..c2a29cde5 100644
2016-04-03 21:34:15 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
2017-07-27 01:12:40 +00:00
@@ -953,7 +953,7 @@ public final class CraftServer implements Server {
2016-04-03 21:34:15 +00:00
System.out.print("Preparing start region for level " + (console.worlds.size() - 1) + " (Seed: " + internal.getSeed() + ")");
if (internal.getWorld().getKeepSpawnInMemory()) {
- short short1 = 196;
+ short short1 = internal.paperConfig.keepLoadedRange; // Paper
long i = System.currentTimeMillis();
for (int j = -short1; j <= short1; j += 16) {
for (int k = -short1; k <= short1; k += 16) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
2017-07-27 01:12:40 +00:00
index 843a3415f..24b4a7ea7 100644
2016-04-03 21:34:15 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
2017-06-09 12:29:44 +00:00
@@ -1275,8 +1275,9 @@ public class CraftWorld implements World {
2016-04-03 21:34:15 +00:00
int chunkCoordX = chunkcoordinates.getX() >> 4;
int chunkCoordZ = chunkcoordinates.getZ() >> 4;
// Cycle through the 25x25 Chunks around it to load/unload the chunks.
- for (int x = -12; x <= 12; x++) {
- for (int z = -12; z <= 12; z++) {
+ int radius = world.paperConfig.keepLoadedRange / 16; // Paper
+ for (int x = -radius; x <= radius; x++) { // Paper
+ for (int z = -radius; z <= radius; z++) { // Paper
if (keepLoaded) {
loadChunk(chunkCoordX + x, chunkCoordZ + z);
} else {
--
2017-07-27 01:12:40 +00:00
2.13.0
2016-04-03 21:34:15 +00:00