From 42a4d18717331349ff8e8dfc46bdad1bd5fb75c8 Mon Sep 17 00:00:00 2001 From: Helvetica Volubi Date: Mon, 27 Oct 2025 21:28:59 +0800 Subject: [PATCH] refactor: deprecated tickCount --- ...h => 0010-Leaves-Base-Protocol-Core.patch} | 0 .../0010-Rewrite-tickCount-support.patch | 63 ------------------- ... => 0011-Leaves-Item-overstack-util.patch} | 0 ...ves-Old-Explosion-Damage-Calculator.patch} | 0 ...ch => 0013-Leaves-Old-raid-behavior.patch} | 0 ... 0014-Leaves-Redstone-Shears-Wrench.patch} | 0 ...atch => 0015-Leaves-Servux-Protocol.patch} | 0 ...rpur-Barrels-and-enderchests-6-rows.patch} | 0 ...-for-Raid-Revert-and-Cross-Region-D.patch} | 0 ...18-Disable-some-check-for-operators.patch} | 0 ...-support.patch => 0019-I18n-support.patch} | 0 ...ch => 0020-Old-zombie-reinforcement.patch} | 0 ...tch => 0021-Spawn-invulnerable-time.patch} | 0 ...yer.patch => 0022-Leaves-Fakeplayer.patch} | 12 ++-- ... 0023-Modify-merge-ItemEntity-logic.patch} | 0 ... => 0024-Leaves-Syncmatica-Protocol.patch} | 0 ....patch => 0025-Leaves-BBOR-Protocol.patch} | 0 ....patch => 0026-Leaves-Jade-Protocol.patch} | 0 ...h => 0027-Leaves-Xaero-Map-Protocol.patch} | 0 ...=> 0028-Leaves-Support-REI-protocol.patch} | 0 ... => 0029-Leaves-Wool-Hopper-Counter.patch} | 0 .../command/counter/sub/DisplayCommand.java | 1 - .../command/counter/sub/ResetCommand.java | 1 - .../org/leavesmc/leaves/bot/ServerBot.java | 2 +- .../protocol/core/LeavesProtocolManager.java | 8 ++- .../servux/ServuxHudDataProtocol.java | 8 ++- 26 files changed, 19 insertions(+), 76 deletions(-) rename lophine-server/minecraft-patches/features/{0011-Leaves-Base-Protocol-Core.patch => 0010-Leaves-Base-Protocol-Core.patch} (100%) delete mode 100644 lophine-server/minecraft-patches/features/0010-Rewrite-tickCount-support.patch rename lophine-server/minecraft-patches/features/{0012-Leaves-Item-overstack-util.patch => 0011-Leaves-Item-overstack-util.patch} (100%) rename lophine-server/minecraft-patches/features/{0013-Leaves-Old-Explosion-Damage-Calculator.patch => 0012-Leaves-Old-Explosion-Damage-Calculator.patch} (100%) rename lophine-server/minecraft-patches/features/{0014-Leaves-Old-raid-behavior.patch => 0013-Leaves-Old-raid-behavior.patch} (100%) rename lophine-server/minecraft-patches/features/{0015-Leaves-Redstone-Shears-Wrench.patch => 0014-Leaves-Redstone-Shears-Wrench.patch} (100%) rename lophine-server/minecraft-patches/features/{0016-Leaves-Servux-Protocol.patch => 0015-Leaves-Servux-Protocol.patch} (100%) rename lophine-server/minecraft-patches/features/{0017-Purpur-Barrels-and-enderchests-6-rows.patch => 0016-Purpur-Barrels-and-enderchests-6-rows.patch} (100%) rename lophine-server/minecraft-patches/features/{0018-Compatibility-fix-for-Raid-Revert-and-Cross-Region-D.patch => 0017-Compatibility-fix-for-Raid-Revert-and-Cross-Region-D.patch} (100%) rename lophine-server/minecraft-patches/features/{0019-Disable-some-check-for-operators.patch => 0018-Disable-some-check-for-operators.patch} (100%) rename lophine-server/minecraft-patches/features/{0020-I18n-support.patch => 0019-I18n-support.patch} (100%) rename lophine-server/minecraft-patches/features/{0021-Old-zombie-reinforcement.patch => 0020-Old-zombie-reinforcement.patch} (100%) rename lophine-server/minecraft-patches/features/{0022-Spawn-invulnerable-time.patch => 0021-Spawn-invulnerable-time.patch} (100%) rename lophine-server/minecraft-patches/features/{0023-Leaves-Fakeplayer.patch => 0022-Leaves-Fakeplayer.patch} (99%) rename lophine-server/minecraft-patches/features/{0024-Modify-merge-ItemEntity-logic.patch => 0023-Modify-merge-ItemEntity-logic.patch} (100%) rename lophine-server/minecraft-patches/features/{0025-Leaves-Syncmatica-Protocol.patch => 0024-Leaves-Syncmatica-Protocol.patch} (100%) rename lophine-server/minecraft-patches/features/{0026-Leaves-BBOR-Protocol.patch => 0025-Leaves-BBOR-Protocol.patch} (100%) rename lophine-server/minecraft-patches/features/{0027-Leaves-Jade-Protocol.patch => 0026-Leaves-Jade-Protocol.patch} (100%) rename lophine-server/minecraft-patches/features/{0028-Leaves-Xaero-Map-Protocol.patch => 0027-Leaves-Xaero-Map-Protocol.patch} (100%) rename lophine-server/minecraft-patches/features/{0029-Leaves-Support-REI-protocol.patch => 0028-Leaves-Support-REI-protocol.patch} (100%) rename lophine-server/minecraft-patches/features/{0030-Leaves-Wool-Hopper-Counter.patch => 0029-Leaves-Wool-Hopper-Counter.patch} (100%) diff --git a/lophine-server/minecraft-patches/features/0011-Leaves-Base-Protocol-Core.patch b/lophine-server/minecraft-patches/features/0010-Leaves-Base-Protocol-Core.patch similarity index 100% rename from lophine-server/minecraft-patches/features/0011-Leaves-Base-Protocol-Core.patch rename to lophine-server/minecraft-patches/features/0010-Leaves-Base-Protocol-Core.patch diff --git a/lophine-server/minecraft-patches/features/0010-Rewrite-tickCount-support.patch b/lophine-server/minecraft-patches/features/0010-Rewrite-tickCount-support.patch deleted file mode 100644 index 2ec8c3a..0000000 --- a/lophine-server/minecraft-patches/features/0010-Rewrite-tickCount-support.patch +++ /dev/null @@ -1,63 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Helvetica Volubi -Date: Sun, 28 Sep 2025 13:21:30 +0800 -Subject: [PATCH] Rewrite tickCount support - - -diff --git a/io/papermc/paper/threadedregions/TickRegionScheduler.java b/io/papermc/paper/threadedregions/TickRegionScheduler.java -index b957585cf7cf7f845e20f59c7b355722880f3b4e..9b279d003eb9f780ed2723c98b28d9f4d6e3a281 100644 ---- a/io/papermc/paper/threadedregions/TickRegionScheduler.java -+++ b/io/papermc/paper/threadedregions/TickRegionScheduler.java -@@ -412,6 +412,8 @@ public final class TickRegionScheduler { - } - // Luminol end - Add tick command support - -+ MinecraftServer.getServer().handleTickCount(tickCount); // Lophine - reuse tick count -+ - if (!this.tryMarkTicking()) { - if (!this.cancelled.get()) { - throw new IllegalStateException("Scheduled region should be acquirable"); -diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index b156b5c635f931a3d4abc0584591f90476d011a6..0c2b7aafa8ddee36d38fabd3561e6f97fce828f9 100644 ---- a/net/minecraft/server/MinecraftServer.java -+++ b/net/minecraft/server/MinecraftServer.java -@@ -305,6 +305,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop lastTickCount = ThreadLocal.withInitial(() -> 0); // Lophine - reuse tick count - - @Override - public CompletableFuture submit(java.util.function.Supplier task) { -@@ -2227,9 +2229,29 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop S spin(Function threadFunction) { ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.init(); // Paper - rewrite data converter system AtomicReference atomicReference = new AtomicReference<>(); -@@ -1040,6 +1042,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0) { // Folia - region threading - this is complicated to implement, and even if done correctly is messy @@ -66,7 +66,7 @@ index 0c2b7aafa8ddee36d38fabd3561e6f97fce828f9..e5fc1969b8af692d785214731b3f8cc4 this.emptyTicks++; } else { this.emptyTicks = 0; -@@ -1914,6 +1921,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0.0 && getServer().checkTickCount(20)) { + if (FakeplayerConfig.regenAmount > 0.0 && this.tickCount % 20 == 0) { float regenAmount = (float) (FakeplayerConfig.regenAmount * 20); this.setHealth(Math.min(this.getHealth() + regenAmount, this.getMaxHealth())); } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java index 65b0713..334658f 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java @@ -24,7 +24,6 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import org.leavesmc.leaves.protocol.core.invoker.*; import org.slf4j.Logger; @@ -66,6 +65,8 @@ public class LeavesProtocolManager { private static final List> RELOAD_SERVER = new ArrayList<>(); private static final List> RELOAD_DATAPACK = new ArrayList<>(); + private static long lastAcceptTime = 0; + @SuppressWarnings("unchecked") public static void init() { for (Class clazz : getClasses("org.leavesmc.leaves.protocol")) { @@ -253,8 +254,11 @@ public class LeavesProtocolManager { } public static void handleTick() { + long currentTime = System.currentTimeMillis() / 50; + if (currentTime == lastAcceptTime) return; + lastAcceptTime = currentTime; for (var tickerInfo : TICKERS) { - if (MinecraftServer.getServer().checkTickCount(tickerInfo.owner().tickerInterval(tickerInfo.handler().tickerId()))) { + if (currentTime % tickerInfo.owner().tickerInterval(tickerInfo.handler().tickerId()) == 0) { tickerInfo.invoke(); } } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxHudDataProtocol.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxHudDataProtocol.java index d251de2..6f19348 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxHudDataProtocol.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxHudDataProtocol.java @@ -61,6 +61,7 @@ public class ServuxHudDataProtocol implements LeavesProtocol { private static final Table DATA = HashBasedTable.create(); public static boolean refreshSpawnMetadata = false; + private long lastAcceptTime = 0; @ProtocolHandler.Init private static void initializeLoggers() { @@ -238,9 +239,12 @@ public class ServuxHudDataProtocol implements LeavesProtocol { return; } - MinecraftServer server = MinecraftServer.getServer(); + long currentTime = System.currentTimeMillis() / 50; + if (currentTime == lastAcceptTime) return; + lastAcceptTime = currentTime; - if (server.checkTickCount(ServuxProtocolConfig.hudUpdateInterval)) { + if (currentTime % ServuxProtocolConfig.hudUpdateInterval == 0) { + MinecraftServer server = MinecraftServer.getServer(); LOGGERS.forEach((type, logger) -> { if (!isLoggerTypeEnabled(type)) { return;