SPIGOT-6806: Add setting to disable new chunks generation under existing chunks

This commit is contained in:
DerFrZocker authored and md_5 committed 2021-11-28 12:16:58 +11:00
1 parent b7a4222eac
commit 7514aa374a
1 file changed
+69
@@ -0,0 +1,69 @@
From e6a9c381fe63a60d8d7913cd420b0596b4217704 Mon Sep 17 00:00:00 2001
From: DerFrZocker <derrieple@gmail.com>
Date: Sun, 28 Nov 2021 12:09:29 +1100
Subject: [PATCH] Configurable Below Zero Generation
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/IChunkLoader.java b/src/main/java/net/minecraft/world/level/chunk/storage/IChunkLoader.java
index b5eb33275..1e3c7fc4b 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/IChunkLoader.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/IChunkLoader.java
@@ -92,12 +92,27 @@ public class IChunkLoader implements AutoCloseable {
}
}
+ // Spigot start - SPIGOT-6806: Quick and dirty way to prevent below zero generation in old chunks, by setting the status to heightmap instead of empty
+ boolean stopBelowZero = false;
+ boolean belowZeroGenerationInExistingChunks = (generatoraccess != null) ? ((WorldServer) generatoraccess).spigotConfig.belowZeroGenerationInExistingChunks : org.spigotmc.SpigotConfig.belowZeroGenerationInExistingChunks;
+
+ if (i <= 2730 && !belowZeroGenerationInExistingChunks) {
+ stopBelowZero = ChunkStatus.FULL.getName().equals(nbttagcompound.getCompound("Level").getString("Status"));
+ }
+ // Spigot end
+
injectDatafixingContext(nbttagcompound, resourcekey, optional);
nbttagcompound = GameProfileSerializer.update(this.fixerUpper, DataFixTypes.CHUNK, nbttagcompound, Math.max(1493, i));
if (i < SharedConstants.getCurrentVersion().getWorldVersion()) {
nbttagcompound.putInt("DataVersion", SharedConstants.getCurrentVersion().getWorldVersion());
}
+ // Spigot start
+ if (stopBelowZero) {
+ nbttagcompound.putString("Status", ChunkStatus.HEIGHTMAPS.getName());
+ }
+ // Spigot end
+
nbttagcompound.remove("__context");
return nbttagcompound;
}
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index f3d75d19c..59c6ed862 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -398,4 +398,9 @@ public class SpigotConfig
private static void disablePlayerDataSaving() {
disablePlayerDataSaving = getBoolean("players.disable-saving", false);
}
+
+ public static boolean belowZeroGenerationInExistingChunks;
+ private static void belowZeroGenerationInExistingChunks() {
+ belowZeroGenerationInExistingChunks = getBoolean("world-settings.default.below-zero-generation-in-existing-chunks", true);
+ }
}
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 1706a7c3f..40aff34e5 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -378,4 +378,9 @@ public class SpigotWorldConfig
{
thunderChance = getInt("thunder-chance", 100000);
}
+
+ public boolean belowZeroGenerationInExistingChunks;
+ private void belowZeroGenerationInExistingChunks() {
+ belowZeroGenerationInExistingChunks = getBoolean("below-zero-generation-in-existing-chunks", true);
+ }
}
--
2.25.1