Files
Shiroha/shiroha-server/minecraft-patches/features/0043-Add-config-to-enable-tick-command.patch
T

105 lines
6.6 KiB
Diff
Raw Normal View History

2026-07-09 00:03:09 +08:00
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
2026-07-14 15:09:17 +08:00
index aa575f3b76ef70ffb9f0410e7e5cfe7af384bfbd..5f6d6533067863d609484d1463fe4e64ff5f683c 100644
2026-07-09 00:03:09 +08:00
--- 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;
2026-07-14 11:32:51 +08:00
+ // Shiroha start - Add a config to enable tick command
2026-07-14 12:22:17 +08:00
+ if (io.nanachiyo0721.shiroha.config.modules.experiment.CommandConfig.tick) {
2026-07-09 00:03:09 +08:00
+ MinecraftServer.getServer().tickRateManager().tick();
+ }
2026-07-14 11:32:51 +08:00
+ // Shiroha end - Add a config to enable tick command
2026-07-09 00:03:09 +08:00
// 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) {
2026-07-14 12:22:17 +08:00
+ if ((!io.nanachiyo0721.shiroha.config.modules.experiment.CommandConfig.tick || world.tickRateManager().runsNormally()) && world.tickTime) { // Shiroha - Add a config to enable tick command
2026-07-09 00:03:09 +08:00
world.serverLevelData.setGameTime(world.serverLevelData.getGameTime() + tickCount);
}
}
diff --git a/io/papermc/paper/threadedregions/TickRegionScheduler.java b/io/papermc/paper/threadedregions/TickRegionScheduler.java
2026-07-14 15:09:17 +08:00
index e9d22c4b5f30284ca8e026533c24dca2bdb3001d..724332d074bd7d3dfdcb60e83cf1fd6ce706000e 100644
2026-07-09 00:03:09 +08:00
--- 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);
2026-07-14 11:32:51 +08:00
+ // Shiroha start - Add a config to enable tick command
2026-07-14 12:22:17 +08:00
+ if (io.nanachiyo0721.shiroha.config.modules.experiment.CommandConfig.tick) {
2026-07-09 00:03:09 +08:00
+ MinecraftServer.getServer().tickRateManager().endTickWork();
+ }
2026-07-14 11:32:51 +08:00
+ // Shiroha end - Add a config to enable tick command
2026-07-09 00:03:09 +08:00
} 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
2026-07-14 15:09:17 +08:00
index 6f0e1eae0cdc488d7afad18017205f3cd20e994a..570c3523821155d4272161608db7f11a525a783b 100644
2026-07-09 00:03:09 +08:00
--- 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
2026-07-14 11:32:51 +08:00
+ // Shiroha start - Add a config to enable tick command
2026-07-14 12:22:17 +08:00
+ if (io.nanachiyo0721.shiroha.config.modules.experiment.CommandConfig.tick) {
2026-07-09 00:03:09 +08:00
+ TickCommand.register(this.dispatcher); // Folia - region threading - TODO later
+ }
2026-07-14 11:32:51 +08:00
+ // Shiroha end - Add a config to enable tick command
2026-07-09 00:03:09 +08:00
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
2026-07-14 15:09:17 +08:00
index e8d6a67143f3f0b4813e51bb273498bc404899b9..e435142ff4ff14f52f5f9895d3c7d4422dffc8f7 100644
2026-07-09 00:03:09 +08:00
--- 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(
2026-07-14 11:32:51 +08:00
+/* .then( // Shiroha - Add config to enable tick command - limit unsupported functions
2026-07-09 00:03:09 +08:00
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")))
)
- )
2026-07-14 11:32:51 +08:00
+ )*/ // Shiroha - Add config to enable tick command - limit unsupported functions
2026-07-09 00:03:09 +08:00
.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(
2026-07-14 11:32:51 +08:00
+/* .then( // Shiroha - Add config to enable tick command - limit unsupported functions
2026-07-09 00:03:09 +08:00
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")))
)
- )
2026-07-14 11:32:51 +08:00
+ )*/ // Shiroha - Add config to enable tick command - limit unsupported functions
2026-07-09 00:03:09 +08:00
.then(Commands.literal("unfreeze").executes(c -> setFreeze(c.getSource(), false)))
.then(Commands.literal("freeze").executes(c -> setFreeze(c.getSource(), true)))
);