Configurable Keep Spawn Loaded range per world
This lets you disable it for some worlds and lower it for others.
This commit is contained in:
parent
47221671ba
commit
e11a8f0bd5
1 changed files with 83 additions and 0 deletions
|
@ -0,0 +1,83 @@
|
|||
From b8ee28113566b07b8db3ff7a12f4cd23f5436fb6 Mon Sep 17 00:00:00 2001
|
||||
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
|
||||
index be21c0f..0b57f1d 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
@@ -312,4 +312,10 @@ public class PaperWorldConfig {
|
||||
grassUpdateRate = Math.max(0, getInt("grass-spread-tick-rate", grassUpdateRate));
|
||||
log("Grass Spread Tick Rate: " + grassUpdateRate);
|
||||
}
|
||||
+
|
||||
+ public short keepLoadedRange;
|
||||
+ private void keepLoadedRange() {
|
||||
+ keepLoadedRange = (short) getInt("keep-spawn-loaded-range", Math.min(spigotConfig.viewDistance, 8));
|
||||
+ 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
|
||||
index 06dec17..b1e6e5d 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -354,8 +354,9 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
|
||||
long j = av();
|
||||
i = 0;
|
||||
|
||||
- for (int k = -192; k <= 192 && this.isRunning(); k += 16) {
|
||||
- for (int l = -192; l <= 192 && this.isRunning(); l += 16) {
|
||||
+ short radius = worldserver.paperConfig.keepLoadedRange; // Paper
|
||||
+ for (int k = -radius; k <= radius && this.isRunning(); k += 16) { // Paper
|
||||
+ for (int l = -radius; l <= radius && this.isRunning(); l += 16) { // Paper
|
||||
long i1 = av();
|
||||
|
||||
if (i1 - j > 1000L) {
|
||||
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||
index ea187f9..492831d 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -3245,7 +3245,7 @@ public abstract class World implements IBlockAccess {
|
||||
BlockPosition blockposition = this.getSpawn();
|
||||
int k = i * 16 + 8 - blockposition.getX();
|
||||
int l = j * 16 + 8 - blockposition.getZ();
|
||||
- short short0 = 128;
|
||||
+ short short0 = paperConfig.keepLoadedRange; // Paper
|
||||
|
||||
return k >= -short0 && k <= short0 && l >= -short0 && l <= short0 && this.keepSpawnInMemory; // CraftBukkit - Added 'this.keepSpawnInMemory'
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 5b70d7a..831ef84 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -945,7 +945,7 @@ public final class CraftServer implements Server {
|
||||
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
|
||||
index c81dfee..dff2aa4 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -1249,8 +1249,9 @@ public class CraftWorld implements World {
|
||||
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 {
|
||||
--
|
||||
2.8.0
|
||||
|
Loading…
Reference in a new issue