mirror of
https://github.com/Dreeam-qwq/Gale.git
synced 2026-01-04 15:31:45 +00:00
200 lines
9.3 KiB
Diff
200 lines
9.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
|
Date: Tue, 31 Jan 2023 22:39:10 +0100
|
|
Subject: [PATCH] Define server children tick steps
|
|
|
|
License: AGPL-3.0 (https://www.gnu.org/licenses/agpl-3.0.html)
|
|
Gale - https://galemc.org
|
|
|
|
diff --git a/src/main/java/org/galemc/gale/tick/step/ServerChildrenTickSteps.java b/src/main/java/org/galemc/gale/tick/step/ServerChildrenTickSteps.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..0e438fd13ef36bb7fd572286768ca231a2ef5039
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/galemc/gale/tick/step/ServerChildrenTickSteps.java
|
|
@@ -0,0 +1,107 @@
|
|
+// Gale - multithreaded ticking
|
|
+
|
|
+package org.galemc.gale.tick.step;
|
|
+
|
|
+import net.minecraft.server.MinecraftServer;
|
|
+
|
|
+/**
|
|
+ * A utility class defining the tick steps in {@link MinecraftServer#tickChildren} in a way
|
|
+ * that they can be executed both in the default order, or submitted as tasks that may run in parallel.
|
|
+ *
|
|
+ * @author Martijn Muijsers under AGPL-3.0
|
|
+ */
|
|
+public final class ServerChildrenTickSteps {
|
|
+
|
|
+ private ServerChildrenTickSteps() {}
|
|
+
|
|
+ public static final ServerTickStep doSchedulerHeartbeat = new ServerTickStep(() -> MinecraftServer.SERVER.tickStep_doSchedulerHeartbeat());
|
|
+ public static final ServerTickStep tickFunctions = new ServerTickStep(() -> MinecraftServer.SERVER.tickStep_tickFunctions());
|
|
+ public static final ServerTickStep runProcessQueueTasks = new ServerTickStep(() -> MinecraftServer.SERVER.tickStep_runProcessQueueTasks());
|
|
+ public static final WorldTickStep sendTimeUpdates = new WorldTickStep(world -> MinecraftServer.SERVER.tickStep_sendTimeUpdates(world));
|
|
+ public static final ServerTickStep startIteratingOverLevels = new ServerTickStep(() -> MinecraftServer.SERVER.tickStep_startIteratingOverLevels());
|
|
+ public static final WorldTickStep updateEvents = new WorldTickStep(world -> MinecraftServer.SERVER.tickStep_updateEvents(world));
|
|
+
|
|
+ public static final WorldTickStep updatePlayersAffectingSpawning = new WorldTickStep(world -> world.tickStep_updatePlayersAffectingSpawning.run());
|
|
+ public static final WorldTickStep startHandlingTick = new WorldTickStep(world -> world.tickStep_startHandlingTick.run());
|
|
+ public static final WorldTickStep tickWorldBorder = new WorldTickStep(world -> world.tickStep_tickWorldBorder.run());
|
|
+ public static final WorldTickStep advanceWeatherCycle = new WorldTickStep(world -> world.tickStep_advanceWeatherCycle.run());
|
|
+ public static final WorldTickStep applySleep = new WorldTickStep(world -> world.tickStep_applySleep.run());
|
|
+ public static final WorldTickStep updateSkyBrightness = new WorldTickStep(world -> world.tickStep_updateSkyBrightness.run());
|
|
+ public static final WorldTickStep tickTime = new WorldTickStep(world -> world.tickStep_tickTime.run());
|
|
+ public static final WorldTickStep setScheduledBlocksGameTime = new WorldTickStep(world -> world.tickStep_setScheduledBlocksGameTime.run());
|
|
+ public static final WorldTickStep setIsDebug = new WorldTickStep(world -> world.tickStep_setIsDebug.run());
|
|
+ public static final WorldTickStep tickBlocks = new WorldTickStep(world -> world.tickStep_tickBlocks.run());
|
|
+ public static final WorldTickStep tickFluids = new WorldTickStep(world -> world.tickStep_tickFluids.run());
|
|
+ public static final WorldTickStep tickRaids = new WorldTickStep(world -> world.tickStep_tickRaids.run());
|
|
+
|
|
+ public static final WorldTickStep purgeStaleTickets = new WorldTickStep(world -> world.getChunkSource().tickStep_purgeStaleTickets.run());
|
|
+ public static final WorldTickStep runDistanceManagerUpdates = new WorldTickStep(world -> world.getChunkSource().tickStep_runDistanceManagerUpdates.run());
|
|
+ public static final WorldTickStep tickChunks = new WorldTickStep(world -> world.getChunkSource().tickStep_tickChunks.run());
|
|
+ public static final WorldTickStep tickChunkMap = new WorldTickStep(world -> world.getChunkSource().tickStep_tickChunkMap.run());
|
|
+ public static final WorldTickStep clearCache = new WorldTickStep(world -> world.getChunkSource().tickStep_clearCache.run());
|
|
+
|
|
+ public static final WorldTickStep doRunBlockEvents = new WorldTickStep(world -> world.tickStep_doRunBlockEvents.run());
|
|
+ public static final WorldTickStep stopHandlingTick = new WorldTickStep(world -> world.tickStep_stopHandlingTick.run());
|
|
+ public static final WorldTickStep setDoEntityAndBlockEntityTick = new WorldTickStep(world -> world.tickStep_setDoEntityAndBlockEntityTick.run());
|
|
+ public static final WorldTickStep tickDragonFight = new WorldTickStep(world -> world.tickStep_tickDragonFight.run());
|
|
+ public static final WorldTickStep activateEntities = new WorldTickStep(world -> world.tickStep_activateEntities.run());
|
|
+ public static final WorldTickStep tickEntityList = new WorldTickStep(world -> world.tickStep_tickEntityList.run());
|
|
+ public static final WorldTickStep tickBlockEntities = new WorldTickStep(world -> world.tickStep_tickBlockEntities.run());
|
|
+
|
|
+ public static final WorldTickStep recalculateRegions = new WorldTickStep(world -> MinecraftServer.SERVER.tickStep_recalculateRegions(world));
|
|
+ public static final WorldTickStep clearExplosionDensity = new WorldTickStep(world -> MinecraftServer.SERVER.tickStep_clearExplosionDensity(world));
|
|
+ public static final ServerTickStep stopIteratingOverLevels = new ServerTickStep(() -> MinecraftServer.SERVER.tickStep_stopIteratingOverLevels());
|
|
+ public static final ServerTickStep tickConnection = new ServerTickStep(() -> MinecraftServer.SERVER.tickStep_tickConnection());
|
|
+ public static final ServerTickStep tickPlayerList = new ServerTickStep(() -> MinecraftServer.SERVER.tickStep_tickPlayerList());
|
|
+ public static final ServerTickStep tickGameTestTicker = new ServerTickStep(() -> MinecraftServer.SERVER.tickStep_tickGameTestTicker());
|
|
+ public static final ServerTickStep runTickables = new ServerTickStep(() -> MinecraftServer.SERVER.tickStep_runTickables());
|
|
+
|
|
+ /**
|
|
+ * The {@linkplain TickStep tick steps} that occur in {@link MinecraftServer#tickChildren},
|
|
+ * in the same order.
|
|
+ */
|
|
+ public static final TickStep[] values = {
|
|
+ doSchedulerHeartbeat,
|
|
+ tickFunctions,
|
|
+ runProcessQueueTasks,
|
|
+ sendTimeUpdates,
|
|
+ startIteratingOverLevels,
|
|
+ updateEvents,
|
|
+
|
|
+ updatePlayersAffectingSpawning,
|
|
+ startHandlingTick,
|
|
+ tickWorldBorder,
|
|
+ advanceWeatherCycle,
|
|
+ applySleep,
|
|
+ updateSkyBrightness,
|
|
+ tickTime,
|
|
+ setScheduledBlocksGameTime,
|
|
+ setIsDebug,
|
|
+ tickBlocks,
|
|
+ tickFluids,
|
|
+ tickRaids,
|
|
+
|
|
+ purgeStaleTickets,
|
|
+ runDistanceManagerUpdates,
|
|
+ tickChunks,
|
|
+ tickChunkMap,
|
|
+ clearCache,
|
|
+
|
|
+ doRunBlockEvents,
|
|
+ stopHandlingTick,
|
|
+ setDoEntityAndBlockEntityTick,
|
|
+ tickDragonFight,
|
|
+ activateEntities,
|
|
+ tickEntityList,
|
|
+ tickBlockEntities,
|
|
+
|
|
+ recalculateRegions,
|
|
+ clearExplosionDensity,
|
|
+ stopIteratingOverLevels,
|
|
+ tickConnection,
|
|
+ tickPlayerList,
|
|
+ tickGameTestTicker,
|
|
+ runTickables
|
|
+ };
|
|
+
|
|
+}
|
|
diff --git a/src/main/java/org/galemc/gale/tick/step/ServerTickStep.java b/src/main/java/org/galemc/gale/tick/step/ServerTickStep.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..8530b7c5cf64572440c05a5539532e245333746f
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/galemc/gale/tick/step/ServerTickStep.java
|
|
@@ -0,0 +1,23 @@
|
|
+// Gale - multithreaded ticking
|
|
+
|
|
+package org.galemc.gale.tick.step;
|
|
+
|
|
+import net.minecraft.server.level.ServerLevel;
|
|
+
|
|
+import java.util.function.Consumer;
|
|
+
|
|
+/**
|
|
+ * A {@link TickStep} that applies to the whole server (i.e. is run once per tick).
|
|
+ *
|
|
+ * @author Martijn Muijsers under AGPL-3.0
|
|
+ */
|
|
+public class ServerTickStep extends TickStep {
|
|
+
|
|
+ public final Runnable action;
|
|
+
|
|
+ ServerTickStep(Runnable action) {
|
|
+ super();
|
|
+ this.action = action;
|
|
+ }
|
|
+
|
|
+}
|
|
diff --git a/src/main/java/org/galemc/gale/tick/step/TickStep.java b/src/main/java/org/galemc/gale/tick/step/TickStep.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..e07883e4121e3241657f1e60ba46540ab0dd6f08
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/galemc/gale/tick/step/TickStep.java
|
|
@@ -0,0 +1,14 @@
|
|
+// Gale - multithreaded ticking
|
|
+
|
|
+package org.galemc.gale.tick.step;
|
|
+
|
|
+/**
|
|
+ * An abstract step of ticking, as used in {@link ServerChildrenTickSteps}.
|
|
+ *
|
|
+ * @author Martijn Muijsers under AGPL-3.0
|
|
+ */
|
|
+public abstract class TickStep {
|
|
+
|
|
+ protected TickStep() {}
|
|
+
|
|
+}
|
|
diff --git a/src/main/java/org/galemc/gale/tick/step/WorldTickStep.java b/src/main/java/org/galemc/gale/tick/step/WorldTickStep.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..9c2dddae5f26c4e8db4c7490c23afaf3acb06f2b
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/galemc/gale/tick/step/WorldTickStep.java
|
|
@@ -0,0 +1,23 @@
|
|
+// Gale - multithreaded ticking
|
|
+
|
|
+package org.galemc.gale.tick.step;
|
|
+
|
|
+import net.minecraft.server.level.ServerLevel;
|
|
+
|
|
+import java.util.function.Consumer;
|
|
+
|
|
+/**
|
|
+ * A {@link TickStep} that applies to each individual world separately.
|
|
+ *
|
|
+ * @author Martijn Muijsers under AGPL-3.0
|
|
+ */
|
|
+public class WorldTickStep extends TickStep {
|
|
+
|
|
+ public final Consumer<ServerLevel> action;
|
|
+
|
|
+ WorldTickStep(Consumer<ServerLevel> action) {
|
|
+ super();
|
|
+ this.action = action;
|
|
+ }
|
|
+
|
|
+}
|