Files
Shiroha/shiroha-server/minecraft-patches/features/0050-Add-config-to-enable-tick-command.patch
T
NanaChiyo0721 1bb895c165
Shiroha CI / build (push) Canceled after 0s
Shiroha CI / Event File (push) Canceled after 0s
Fix incorrect ticket lock size computing
Yeah this would fully solve the issue of chunk unloading race condition

The same fix was already initially added at "Force clamp grid-exponent to 1~6"
2026-08-09 14:57:32 +08:00

105 lines
6.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
Date: Thu, 9 Jul 2026 10:11:39 +0800
Subject: [PATCH] Add config to enable tick command
only freeze/unfreeze/step/query can run when enabled
diff --git a/io/papermc/paper/threadedregions/RegionizedServer.java b/io/papermc/paper/threadedregions/RegionizedServer.java
index aa575f3b76ef70ffb9f0410e7e5cfe7af384bfbd..5f6d6533067863d609484d1463fe4e64ff5f683c 100644
--- a/io/papermc/paper/threadedregions/RegionizedServer.java
+++ b/io/papermc/paper/threadedregions/RegionizedServer.java
@@ -233,6 +233,11 @@ public final class RegionizedServer {
private void globalTick(final long tickCount) {
++this.tickCount;
+ // Shiroha start - Add a config to enable tick command
+ if (io.nanachiyo0721.shiroha.config.modules.experiment.CommandConfig.tick) {
+ MinecraftServer.getServer().tickRateManager().tick();
+ }
+ // Shiroha end - Add a config to enable tick command
// expire invalid click command callbacks
io.papermc.paper.adventure.providers.ClickCallbackProviderImpl.ADVENTURE_CLICK_MANAGER.handleQueue((int)this.tickCount); // Paper // Folia - region threading - moved to global tick
io.papermc.paper.adventure.providers.ClickCallbackProviderImpl.DIALOG_CLICK_MANAGER.handleQueue((int)this.tickCount); // Paper // Folia - region threading - moved to global tick
@@ -409,7 +414,7 @@ public final class RegionizedServer {
}
private void tickTime(final ServerLevel world, final long tickCount) {
- if (world.tickTime) {
+ if ((!io.nanachiyo0721.shiroha.config.modules.experiment.CommandConfig.tick || world.tickRateManager().runsNormally()) && world.tickTime) { // Shiroha - Add a config to enable tick command
world.serverLevelData.setGameTime(world.serverLevelData.getGameTime() + tickCount);
}
}
diff --git a/io/papermc/paper/threadedregions/TickRegionScheduler.java b/io/papermc/paper/threadedregions/TickRegionScheduler.java
index e9d22c4b5f30284ca8e026533c24dca2bdb3001d..724332d074bd7d3dfdcb60e83cf1fd6ce706000e 100644
--- a/io/papermc/paper/threadedregions/TickRegionScheduler.java
+++ b/io/papermc/paper/threadedregions/TickRegionScheduler.java
@@ -479,6 +479,11 @@ public final class TickRegionScheduler {
try {
// next start isn't updated until the end of this tick
this.tickRegion(tickCount, tickStart, scheduledEnd);
+ // Shiroha start - Add a config to enable tick command
+ if (io.nanachiyo0721.shiroha.config.modules.experiment.CommandConfig.tick) {
+ MinecraftServer.getServer().tickRateManager().endTickWork();
+ }
+ // Shiroha end - Add a config to enable tick command
} catch (final Throwable thr) {
this.scheduler.regionFailed(this, false, thr);
// regionFailed will schedule a shutdown, so we should avoid letting this region tick further
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
index 22c7cddef55727ad00f909e551f40a544316e5ca..9b411a23545572ff38f624b0a5ac7053935076ea 100644
--- a/net/minecraft/commands/Commands.java
+++ b/net/minecraft/commands/Commands.java
@@ -259,7 +259,11 @@ public class Commands {
TeleportCommand.register(this.dispatcher);
TellRawCommand.register(this.dispatcher, context);
//TestCommand.register(this.dispatcher, context); // Folia - region threading
- //TickCommand.register(this.dispatcher); // Folia - region threading - TODO later
+ // Shiroha start - Add a config to enable tick command
+ if (io.nanachiyo0721.shiroha.config.modules.experiment.CommandConfig.tick) {
+ TickCommand.register(this.dispatcher); // Folia - region threading - TODO later
+ }
+ // Shiroha end - Add a config to enable tick command
TimeCommand.register(this.dispatcher, context);
TitleCommand.register(this.dispatcher, context);
//TriggerCommand.register(this.dispatcher); // Folia - region threading - TODO later
diff --git a/net/minecraft/server/commands/TickCommand.java b/net/minecraft/server/commands/TickCommand.java
index e8d6a67143f3f0b4813e51bb273498bc404899b9..e435142ff4ff14f52f5f9895d3c7d4422dffc8f7 100644
--- a/net/minecraft/server/commands/TickCommand.java
+++ b/net/minecraft/server/commands/TickCommand.java
@@ -23,14 +23,14 @@ public class TickCommand {
Commands.literal("tick")
.requires(Commands.hasPermission(Commands.LEVEL_ADMINS))
.then(Commands.literal("query").executes(c -> tickQuery(c.getSource())))
- .then(
+/* .then( // Shiroha - Add config to enable tick command - limit unsupported functions
Commands.literal("rate")
.then(
Commands.argument("rate", FloatArgumentType.floatArg(1.0F, 10000.0F))
.suggests((c, b) -> SharedSuggestionProvider.suggest(new String[]{DEFAULT_TICKRATE}, b))
.executes(c -> setTickingRate(c.getSource(), FloatArgumentType.getFloat(c, "rate")))
)
- )
+ )*/ // Shiroha - Add config to enable tick command - limit unsupported functions
.then(
Commands.literal("step")
.executes(c -> step(c.getSource(), 1))
@@ -41,7 +41,7 @@ public class TickCommand {
.executes(c -> step(c.getSource(), IntegerArgumentType.getInteger(c, "time")))
)
)
- .then(
+/* .then( // Shiroha - Add config to enable tick command - limit unsupported functions
Commands.literal("sprint")
.then(Commands.literal("stop").executes(c -> stopSprinting(c.getSource())))
.then(
@@ -49,7 +49,7 @@ public class TickCommand {
.suggests((c, b) -> SharedSuggestionProvider.suggest(new String[]{"60s", "1d", "3d"}, b))
.executes(c -> sprint(c.getSource(), IntegerArgumentType.getInteger(c, "time")))
)
- )
+ )*/ // Shiroha - Add config to enable tick command - limit unsupported functions
.then(Commands.literal("unfreeze").executes(c -> setFreeze(c.getSource(), false)))
.then(Commands.literal("freeze").executes(c -> setFreeze(c.getSource(), true)))
);