Files
Shiroha/camellia-server/minecraft-patches/features/0020-Force-clamp-grid-exponent-to-1-6.patch
T

30 lines
2.2 KiB
Diff
Raw Normal View History

2026-07-10 16:10:58 +08:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrHua269 <mrhua269@gmail.com>
Date: Fri, 10 Jul 2026 15:48:51 +0800
Subject: [PATCH] Force clamp grid-exponent to 1~6
diff --git a/io/papermc/paper/threadedregions/TickRegions.java b/io/papermc/paper/threadedregions/TickRegions.java
index a6ab9cb01f4f49f5f44b6ed324fa6d51139aabb6..7bf49d2c235cb3f6c4cd8de4d127f476c7deb069 100644
--- a/io/papermc/paper/threadedregions/TickRegions.java
+++ b/io/papermc/paper/threadedregions/TickRegions.java
@@ -27,7 +27,7 @@ import java.util.function.BooleanSupplier;
public final class TickRegions implements ThreadedRegionizer.RegionCallbacks<TickRegions.TickRegionData, TickRegions.TickRegionSectionData> {
private static final Logger LOGGER = LogUtils.getLogger();
- private static int regionShift = 31;
+ private static int regionShift = ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ThreadedTicketLevelPropagator.SECTION_SHIFT; // Camellia - Force clamp grid-exponent to 1~6
public static int getRegionChunkShift() {
return regionShift;
@@ -68,7 +68,8 @@ public final class TickRegions implements ThreadedRegionizer.RegionCallbacks<Tic
initialised = true;
int gridExponent = config.gridExponent;
gridExponent = Math.max(0, gridExponent);
- gridExponent = Math.min(31, gridExponent);
+ if (gridExponent > ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ThreadedTicketLevelPropagator.SECTION_SHIFT) LOGGER.warn("You are using a grid-exponent ({}) which is larger than the ticket lock shift! This would lead to randomly fatal crash !!!, Clamping back to max allowed {}", gridExponent, ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ThreadedTicketLevelPropagator.SECTION_SHIFT); // Camellia - Force clamp grid-exponent to 1~6
+ gridExponent = Math.min(ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ThreadedTicketLevelPropagator.SECTION_SHIFT, gridExponent); // Camellia - Force clamp grid-exponent to 1~6
regionShift = gridExponent;
scheduler = new TickRegionScheduler(config.scheduler, tickThreads);
LOGGER.info("Initialised " + config.scheduler + " Folia scheduler with initial " + tickThreads + " target thread(s)");