From 4b57eed3fbb90cca5402b5159973a65c17ab4af0 Mon Sep 17 00:00:00 2001 From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> Date: Wed, 9 Jul 2025 04:42:13 +0300 Subject: [PATCH] add chunks settings back --- .../features/0083-C2ME-Limit-NBT-cache.patch | 54 +++++++++++++++++++ ...igurable-player-spawn-tracking-range.patch | 19 +++++++ .../0021-Configurable-Max-View-Distance.patch | 19 +++++++ 3 files changed, 92 insertions(+) create mode 100644 divinemc-server/minecraft-patches/features/0083-C2ME-Limit-NBT-cache.patch create mode 100644 divinemc-server/minecraft-patches/features/0084-Configurable-player-spawn-tracking-range.patch create mode 100644 divinemc-server/paper-patches/features/0021-Configurable-Max-View-Distance.patch diff --git a/divinemc-server/minecraft-patches/features/0083-C2ME-Limit-NBT-cache.patch b/divinemc-server/minecraft-patches/features/0083-C2ME-Limit-NBT-cache.patch new file mode 100644 index 0000000..c8de5e9 --- /dev/null +++ b/divinemc-server/minecraft-patches/features/0083-C2ME-Limit-NBT-cache.patch @@ -0,0 +1,54 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> +Date: Wed, 9 Jul 2025 04:37:59 +0300 +Subject: [PATCH] C2ME: Limit NBT cache + +This patch is based on the following mixins: +* "com/ishland/c2me/opts/chunkio/mixin/limit_nbt_cache/MixinStorageIoWorker.java" +By: ishland +As part of: C2ME (https://github.com/RelativityMC/C2ME-fabric) +Licensed under: MIT (https://opensource.org/licenses/MIT) + +diff --git a/net/minecraft/world/level/chunk/storage/IOWorker.java b/net/minecraft/world/level/chunk/storage/IOWorker.java +index 27e1edbd8d8ffd80c1a3df17bc47f4a6936619f7..c3326e753ecf8a0ba1930d8c7573ebd2c594cf45 100644 +--- a/net/minecraft/world/level/chunk/storage/IOWorker.java ++++ b/net/minecraft/world/level/chunk/storage/IOWorker.java +@@ -212,7 +212,38 @@ public class IOWorker implements ChunkScanAccess, AutoCloseable { + }); + } + ++ // DivineMC start - C2ME: Limit NBT cache ++ private void checkHardLimit() { ++ if (this.pendingWrites.size() >= org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.chunkDataCacheLimit) { ++ LOGGER.warn("Chunk data cache size exceeded hard limit ({} >= {}), forcing writes to disk (you can increase chunkDataCacheLimit in divinemc.yml)", this.pendingWrites.size(), org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.chunkDataCacheLimit); ++ while (this.pendingWrites.size() >= org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.chunkDataCacheSoftLimit * 0.75) { ++ writeResult0(); ++ } ++ } ++ } ++ ++ private void writeResult0() { ++ java.util.Iterator> iterator = this.pendingWrites.entrySet().iterator(); ++ if (iterator.hasNext()) { ++ java.util.Map.Entry entry = iterator.next(); ++ iterator.remove(); ++ this.runStore(entry.getKey(), entry.getValue()); ++ } ++ } ++ // DivineMC end - C2ME: Limit NBT cache ++ + private void storePendingChunk() { ++ // DivineMC start - C2ME: Limit NBT cache ++ if (!this.pendingWrites.isEmpty()) { ++ checkHardLimit(); ++ if (this.pendingWrites.size() >= org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.chunkDataCacheSoftLimit) { ++ int writeFrequency = Math.min(1, (this.pendingWrites.size() - (int) org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.chunkDataCacheSoftLimit) / 16); ++ for (int i = 0; i < writeFrequency; i++) { ++ writeResult0(); ++ } ++ } ++ } ++ // DivineMC end - C2ME: Limit NBT cache + Entry entry = this.pendingWrites.pollFirstEntry(); + if (entry != null) { + this.runStore(entry.getKey(), entry.getValue()); diff --git a/divinemc-server/minecraft-patches/features/0084-Configurable-player-spawn-tracking-range.patch b/divinemc-server/minecraft-patches/features/0084-Configurable-player-spawn-tracking-range.patch new file mode 100644 index 0000000..aa79ad8 --- /dev/null +++ b/divinemc-server/minecraft-patches/features/0084-Configurable-player-spawn-tracking-range.patch @@ -0,0 +1,19 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> +Date: Wed, 9 Jul 2025 04:40:45 +0300 +Subject: [PATCH] Configurable player spawn tracking range + + +diff --git a/ca/spottedleaf/moonrise/patches/chunk_tick_iteration/ChunkTickConstants.java b/ca/spottedleaf/moonrise/patches/chunk_tick_iteration/ChunkTickConstants.java +index 6d1fe8028739145b11fce98ad62b2f8044299548..9f086ded18d1fc8850877c6be113d88074427526 100644 +--- a/ca/spottedleaf/moonrise/patches/chunk_tick_iteration/ChunkTickConstants.java ++++ b/ca/spottedleaf/moonrise/patches/chunk_tick_iteration/ChunkTickConstants.java +@@ -2,7 +2,7 @@ package ca.spottedleaf.moonrise.patches.chunk_tick_iteration; + + public final class ChunkTickConstants { + +- public static final int PLAYER_SPAWN_TRACK_RANGE = 8; ++ public static final int PLAYER_SPAWN_TRACK_RANGE = (int) Math.round(org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.playerNearChunkDetectionRange / 16.0); // DivineMC - Configurable player spawn tracking range + // the smallest distance on x/z is at 45 degrees, we need to subtract 0.5 since this is calculated from chunk center and not chunk perimeter + // note: vanilla does not subtract 0.5 but the result is (luckily!) the same + public static final int NARROW_SPAWN_TRACK_RANGE = (int)Math.floor(((double)PLAYER_SPAWN_TRACK_RANGE / Math.sqrt(2.0)) - 0.5); diff --git a/divinemc-server/paper-patches/features/0021-Configurable-Max-View-Distance.patch b/divinemc-server/paper-patches/features/0021-Configurable-Max-View-Distance.patch new file mode 100644 index 0000000..fdc3795 --- /dev/null +++ b/divinemc-server/paper-patches/features/0021-Configurable-Max-View-Distance.patch @@ -0,0 +1,19 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> +Date: Wed, 9 Jul 2025 04:40:05 +0300 +Subject: [PATCH] Configurable Max View Distance + + +diff --git a/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseConstants.java b/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseConstants.java +index 559c959aff3c9deef867b9e425fba3e2e669cac6..00aac7b5b610746f619b07502ceea5dd87e36ff7 100644 +--- a/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseConstants.java ++++ b/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseConstants.java +@@ -4,7 +4,7 @@ import ca.spottedleaf.moonrise.common.PlatformHooks; + + public final class MoonriseConstants { + +- public static final int MAX_VIEW_DISTANCE = Integer.getInteger(PlatformHooks.get().getBrand() + ".MaxViewDistance", 32); ++ public static final int MAX_VIEW_DISTANCE = Integer.getInteger(PlatformHooks.get().getBrand() + ".MaxViewDistance", org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.maxViewDistance); // DivineMC - Configurable Max View Distance + + private MoonriseConstants() {} +