From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Martijn Muijsers Date: Tue, 31 Jan 2023 19:05:12 +0100 Subject: [PATCH] Split 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/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index 7ed820d2483bf6741a355b062f062a04866ba938..575f8ba79cf3547b837abb5957fed0aa29e1d0cf 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -154,7 +154,6 @@ import org.galemc.gale.executor.annotation.thread.OriginalServerThreadOnly; import org.galemc.gale.executor.queue.BaseTaskQueues; import org.galemc.gale.executor.queue.ScheduledServerThreadTaskQueues; import org.galemc.gale.executor.thread.OriginalServerThread; -import org.galemc.gale.executor.thread.SignalReason; import org.galemc.gale.executor.thread.pool.BaseThreadActivation; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; @@ -1576,15 +1575,53 @@ public abstract class MinecraftServer extends MinecraftServerBlockableEventLoop co.aikar.timings.TimingsManager.FULL_SERVER_TICK.stopTimingFullServerTick(); // Paper // Gale - final timings calls } + // Gale start - split tick steps + public static BooleanSupplier tick_shouldKeepTicking; + public static final boolean tick_tickChunks = true; + // Gale end - split tick steps + public void tickChildren(BooleanSupplier shouldKeepTicking) { + // Gale start - split tick steps + tick_shouldKeepTicking = shouldKeepTicking; + this.tickStep_doSchedulerHeartbeat(); + this.tickStep_tickFunctions(); + //Iterator iterator = this.getAllLevels().iterator(); // Paper - moved down + this.tickStep_runProcessQueueTasks(); + for (final ServerLevel world : this.getAllLevelsArray()) { // Gale - base thread pool - optimize server levels + this.tickStep_sendTimeUpdates(world); + } + this.tickStep_startIteratingOverLevels(); + for (ServerLevel worldserver : this.getAllLevelsArray()) { // Paper - move down // Gale - base thread pool - optimize server levels + this.tickStep_updateEvents(worldserver); + this.tickStep_tickWorld(worldserver); + this.tickStep_recalculateRegions(worldserver); + this.tickStep_clearExplosionDensityCache(worldserver); + } + this.tickStep_stopIteratingOverLevels(); + this.tickStep_tickConnection(); + this.tickStep_tickPlayerList(); + this.tickStep_tickGameTestTicker(); + this.tickStep_runTickables(); + } + + public final void tickStep_doSchedulerHeartbeat() { + // Gale end - split tick steps MinecraftTimings.bukkitSchedulerTimer.startTiming(); // Spigot // Paper this.server.getScheduler().mainThreadHeartbeat(this.tickCount); // CraftBukkit MinecraftTimings.bukkitSchedulerTimer.stopTiming(); // Spigot // Paper + // Gale start - split tick steps + } + + public final void tickStep_tickFunctions() { + // Gale end - split tick steps MinecraftTimings.commandFunctionsTimer.startTiming(); // Spigot // Paper this.getFunctions().tick(); MinecraftTimings.commandFunctionsTimer.stopTiming(); // Spigot // Paper - //Iterator iterator = this.getAllLevels().iterator(); // Paper - moved down + // Gale start - split tick steps + } + public final void tickStep_runProcessQueueTasks() { + // Gale end - split tick steps // CraftBukkit start // Run tasks that are waiting on processing MinecraftTimings.processQueueTimer.startTiming(); // Spigot @@ -1592,11 +1629,14 @@ public abstract class MinecraftServer extends MinecraftServerBlockableEventLoop this.processQueue.remove().run(); } MinecraftTimings.processQueueTimer.stopTiming(); // Spigot + // Gale start - split tick steps + } + public final void tickStep_sendTimeUpdates(ServerLevel world) { + // Gale end - split tick steps MinecraftTimings.timeUpdateTimer.startTiming(); // Spigot // Paper // Send time updates to everyone, it will get the right time from the world the player is in. // Paper start - optimize time updates - for (final ServerLevel world : this.getAllLevelsArray()) { // Gale - base thread pool - optimize server levels final boolean doDaylight = world.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT); final long dayTime = world.getDayTime(); long worldTime = world.getGameTime(); @@ -1611,15 +1651,23 @@ public abstract class MinecraftServer extends MinecraftServerBlockableEventLoop new ClientboundSetTimePacket(worldTime, playerTime, doDaylight); entityplayer.connection.send(packet); // Add support for per player time } - } // Paper end MinecraftTimings.timeUpdateTimer.stopTiming(); // Spigot // Paper + // Gale start - split tick steps + } + public final void tickStep_startIteratingOverLevels() { + // Gale end - split tick steps this.isIteratingOverLevels = true; // Paper - for (ServerLevel worldserver : this.getAllLevelsArray()) { // Paper - move down // Gale - base thread pool - optimize server levels + // Gale start - split tick steps + } + + public final void tickStep_updateEvents(ServerLevel worldserver) { + // Gale end - split tick steps worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper worldserver.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = worldserver.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper + } // Gale - split tick steps /* Drop global time updates if (this.tickCount % 20 == 0) { @@ -1629,16 +1677,28 @@ public abstract class MinecraftServer extends MinecraftServerBlockableEventLoop } // CraftBukkit end */ - try { - worldserver.timings.doTick.startTiming(); // Spigot - worldserver.tick(shouldKeepTicking); + public final void tickStep_tickWorld(ServerLevel worldserver) { + worldserver.tick(tick_shouldKeepTicking); + } + + public final void tickStep_recalculateRegions(ServerLevel worldserver) { + try { + worldserver.timings.doTick.startTiming(); // Spigot + // Gale end - split tick steps // Paper start for (final io.papermc.paper.chunk.SingleThreadChunkRegionManager regionManager : worldserver.getChunkSource().chunkMap.regionManagers) { regionManager.recalculateRegions(); } - // Paper end worldserver.timings.doTick.stopTiming(); // Spigot - } catch (Throwable throwable) { + // Paper end + // Gale start - split tick steps + } catch (Throwable throwable) { + SERVER.catchWorldTickException(worldserver, throwable); + } + } + + public final void catchWorldTickException(ServerLevel worldserver, Throwable throwable) { + // Gale end - split tick steps // Spigot Start CrashReport crashreport; try { @@ -1651,22 +1711,47 @@ public abstract class MinecraftServer extends MinecraftServerBlockableEventLoop worldserver.fillReportDetails(crashreport); throw new ReportedException(crashreport); - } + // Gale start - split tick steps + } + public final void tickStep_clearExplosionDensityCache(ServerLevel worldserver) { + // Gale end - split tick steps worldserver.explosionDensityCache.clear(); // Paper - Optimize explosions - } + // Gale start - split tick steps + } + + public final void tickStep_stopIteratingOverLevels() { + // Gale end - split tick steps this.isIteratingOverLevels = false; // Paper + // Gale start - split tick steps + } + public final void tickStep_tickConnection() { + // Gale end - split tick steps MinecraftTimings.connectionTimer.startTiming(); // Spigot this.getConnection().tick(); MinecraftTimings.connectionTimer.stopTiming(); // Spigot + // Gale start - split tick steps + } + + public final void tickStep_tickPlayerList() { + // Gale end - split tick steps MinecraftTimings.playerListTimer.startTiming(); // Spigot // Paper this.playerList.tick(); MinecraftTimings.playerListTimer.stopTiming(); // Spigot // Paper + // Gale start - split tick steps + } + + public final void tickStep_tickGameTestTicker() { + // Gale end - split tick steps if (SharedConstants.IS_RUNNING_IN_IDE) { GameTestTicker.SINGLETON.tick(); } + // Gale start - split tick steps + } + public final void tickStep_runTickables() { + // Gale end - split tick steps MinecraftTimings.tickablesTimer.startTiming(); // Spigot // Paper for (int i = 0; i < this.tickables.size(); ++i) { ((Runnable) this.tickables.get(i)).run(); diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java index 2a0cbe5146eb444a8cb7ab4960904143af4456a7..aa49a3d3827128c7d4c7b424211f80abd7e2ff80 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java @@ -630,23 +630,99 @@ public class ServerChunkCache extends ChunkSource { } // CraftBukkit end + // Gale start - split tick steps + public Runnable tickStep_purgeStaleTickets; + public Runnable tickStep_runDistanceManagerUpdates; + public Runnable tickStep_tickChunks; + public Runnable tickStep_tickChunkMap; + public Runnable tickStep_clearCache; + // Gale end - split tick steps + @Override public void tick(BooleanSupplier shouldKeepTicking, boolean tickChunks) { + // Gale start - split tick steps + this.initializeTickSteps(); + this.tickStep_purgeStaleTickets.run(); + this.tickStep_runDistanceManagerUpdates.run(); + this.tickStep_tickChunks.run(); + this.tickStep_tickChunkMap.run(); + this.tickStep_clearCache.run(); + } + + public void initializeTickSteps() { + //noinspection ConstantValue + if (this.tickStep_purgeStaleTickets != null) { + return; + } + this.tickStep_purgeStaleTickets = this.tickStep_purgeStaleTickets_create(); + this.tickStep_runDistanceManagerUpdates = this.tickStep_runDistanceManagerUpdates_create(); + this.tickStep_tickChunks = this.tickStep_tickChunks_create(); + this.tickStep_tickChunkMap = this.tickStep_tickChunkMap_create(); + this.tickStep_clearCache = this.tickStep_clearCache_create(); + } + + private Runnable wrapTickStep(Runnable runnable) { + return this.level.wrapTickStep(() -> { + this.level.timings.chunkProviderTick.startTiming(); // Paper - timings + runnable.run(); + this.level.timings.chunkProviderTick.stopTiming(); // Paper - timings + }); + } + + private Runnable wrapDoChunkMapTickStep(Runnable runnable) { + return this.wrapTickStep(() -> { + // Gale end - split tick steps this.level.timings.doChunkMap.startTiming(); // Spigot + // Gale start - split tick steps + runnable.run(); + this.level.timings.doChunkMap.stopTiming(); // Spigot + }); + } + + private Runnable tickStep_purgeStaleTickets_create() { + return this.wrapDoChunkMapTickStep(() -> { + // Gale end - split tick steps this.distanceManager.purgeStaleTickets(); + // Gale start - split tick steps + }); + } + + private Runnable tickStep_runDistanceManagerUpdates_create() { + return this.wrapDoChunkMapTickStep(() -> { + // Gale end - split tick steps this.runDistanceManagerUpdates(); - this.level.timings.doChunkMap.stopTiming(); // Spigot - if (tickChunks) { + // Gale start - split tick steps + }); + } + + private Runnable tickStep_tickChunks_create() { + return this.wrapTickStep(() -> { + if (MinecraftServer.tick_tickChunks) { + // Gale end - split tick steps this.level.timings.chunks.startTiming(); // Paper - timings this.chunkMap.playerChunkManager.tick(); // Paper - this is mostly is to account for view distance changes this.tickChunks(); this.level.timings.chunks.stopTiming(); // Paper - timings } + // Gale start - split tick steps + }); + } + private Runnable tickStep_tickChunkMap_create() { + return this.wrapTickStep(() -> { + // Gale end - split tick steps this.level.timings.doChunkUnload.startTiming(); // Spigot - this.chunkMap.tick(shouldKeepTicking); + this.chunkMap.tick(MinecraftServer.tick_shouldKeepTicking); // Gale - split tick steps this.level.timings.doChunkUnload.stopTiming(); // Spigot + // Gale start - split tick steps + }); + } + + private Runnable tickStep_clearCache_create() { + return this.wrapTickStep(() -> { + // Gale end - split tick steps this.clearCache(); + }); // Gale - split tick steps } private void tickChunks() { diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java index e7747b19685fd943d7fbefbfef656f8bb7c359f1..5472fac17f78f59c3e97ecac42f29092ce364e42 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -23,7 +23,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.Comparator; import java.util.Iterator; import java.util.List; @@ -163,16 +162,13 @@ import org.galemc.gale.executor.annotation.Access; import org.galemc.gale.executor.annotation.thread.AnyThreadSafe; import org.slf4j.Logger; import org.bukkit.Bukkit; -import org.bukkit.Location; import org.bukkit.WeatherType; import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.craftbukkit.generator.CustomWorldChunkManager; -import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.craftbukkit.util.WorldUUID; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.server.MapInitializeEvent; import org.bukkit.event.weather.LightningStrikeEvent; -import org.bukkit.event.world.GenericGameEvent; import org.bukkit.event.world.TimeSkipEvent; // CraftBukkit end import it.unimi.dsi.fastutil.ints.IntArrayList; // Paper @@ -633,7 +629,101 @@ public class ServerLevel extends Level implements WorldGenLevel { return this.structureManager; } + // Gale start - split tick steps + public Runnable tickStep_updatePlayersAffectingSpawning; + public Runnable tickStep_startHandlingTick; + public Runnable tickStep_tickWorldBorder; + public Runnable tickStep_advanceWeatherCycle; + public Runnable tickStep_applySleep; + public Runnable tickStep_updateSkyBrightness; + public Runnable tickStep_tickTime; + public Runnable tickStep_setScheduledBlocksGameTime; + public Runnable tickStep_setIsDebug; + public Runnable tickStep_tickBlocks; + public Runnable tickStep_tickFluids; + public Runnable tickStep_tickRaids; + public Runnable tickStep_tickChunkSource; + public Runnable tickStep_doRunBlockEvents; + public Runnable tickStep_stopHandlingTick; + public Runnable tickStep_setDoEntityAndBlockEntityTick; + public Runnable tickStep_tickDragonFight; + public Runnable tickStep_activateEntities; + public Runnable tickStep_tickEntityList; + public Runnable tickStep_tickBlockEntities; + + private long tick_scheduledBlocksGameTime; + private boolean tick_isDebug; + private boolean tick_doEntityAndBlockEntityTick; + // Gale end - split tick steps + public void tick(BooleanSupplier shouldKeepTicking) { + // Gale start - split tick steps + this.initializeTickSteps(); + this.tickStep_updatePlayersAffectingSpawning.run(); + this.tickStep_startHandlingTick.run(); + this.tickStep_tickWorldBorder.run(); + this.tickStep_advanceWeatherCycle.run(); + this.tickStep_applySleep.run(); + this.tickStep_updateSkyBrightness.run(); + this.tickStep_tickTime.run(); + this.tickStep_setScheduledBlocksGameTime.run(); + this.tickStep_setIsDebug.run(); + this.tickStep_tickBlocks.run(); + this.tickStep_tickFluids.run(); + this.tickStep_tickRaids.run(); + this.tickStep_tickChunkSource.run(); + this.tickStep_doRunBlockEvents.run(); + this.tickStep_stopHandlingTick.run(); + this.tickStep_setDoEntityAndBlockEntityTick.run(); + this.tickStep_tickDragonFight.run(); + this.tickStep_activateEntities.run(); + this.tickStep_tickEntityList.run(); + this.tickStep_tickBlockEntities.run(); + //this.entityManager.tick(); // Paper - rewrite chunk system + } + + public void initializeTickSteps() { + //noinspection ConstantValue + if (this.tickStep_updatePlayersAffectingSpawning != null) { + return; + } + this.tickStep_updatePlayersAffectingSpawning = this.tickStep_updatePlayersAffectingSpawning_create(); + this.tickStep_startHandlingTick = this.tickStep_startHandlingTick_create(); + this.tickStep_tickWorldBorder = this.tickStep_tickWorldBorder_create(); + this.tickStep_advanceWeatherCycle = this.tickStep_advanceWeatherCycle_create(); + this.tickStep_applySleep = this.tickStep_applySleep_create(); + this.tickStep_updateSkyBrightness = this.tickStep_updateSkyBrightness_create(); + this.tickStep_tickTime = this.tickStep_tickTime_create(); + this.tickStep_setScheduledBlocksGameTime = this.tickStep_setScheduledBlocksGameTime_create(); + this.tickStep_setIsDebug = this.tickStep_setIsDebug_create(); + this.tickStep_tickBlocks = this.tickStep_tickBlocks_create(); + this.tickStep_tickFluids = this.tickStep_tickFluids_create(); + this.tickStep_tickRaids = this.tickStep_tickRaids_create(); + this.tickStep_tickChunkSource = this.tickStep_tickChunkSource_create(); + this.tickStep_doRunBlockEvents = this.tickStep_doRunBlockEvents_create(); + this.tickStep_stopHandlingTick = this.tickStep_stopHandlingTick_create(); + this.tickStep_setDoEntityAndBlockEntityTick = this.tickStep_setDoEntityAndBlockEntityTick_create(); + this.tickStep_tickDragonFight = this.tickStep_tickDragonFight_create(); + this.tickStep_activateEntities = this.tickStep_activateEntities_create(); + this.tickStep_tickEntityList = this.tickStep_tickEntityList_create(); + this.tickStep_tickBlockEntities = this.tickStep_tickBlockEntities_create(); + } + + public Runnable wrapTickStep(Runnable runnable) { + return () -> { + try { + this.timings.doTick.startTiming(); // Spigot + runnable.run(); + this.timings.doTick.stopTiming(); // Spigot + } catch (Throwable throwable) { + MinecraftServer.SERVER.catchWorldTickException(this, throwable); + } + }; + } + + private Runnable tickStep_updatePlayersAffectingSpawning_create() { + return this.wrapTickStep(() -> { + // Gale end - split tick steps // Paper start - optimise checkDespawn this.playersAffectingSpawning.clear(); for (ServerPlayer player : this.players) { @@ -641,10 +731,35 @@ public class ServerLevel extends Level implements WorldGenLevel { this.playersAffectingSpawning.add(player); } } - // Paper end - optimise checkDespawn - this.handlingTick = true; + // Gale start - split tick steps + }); + } + + private Runnable tickStep_startHandlingTick_create() { + return this.wrapTickStep(() -> { + this.handlingTick = true; + }); + } + + private Runnable tickStep_tickWorldBorder_create() { + return this.wrapTickStep(() -> { + // Gale end - split tick steps this.getWorldBorder().tick(); + // Gale start - split tick steps + }); + } + + private Runnable tickStep_advanceWeatherCycle_create() { + return this.wrapTickStep(() -> { + // Gale end - split tick steps this.advanceWeatherCycle(); + // Gale start - split tick steps + }); + } + + private Runnable tickStep_applySleep_create() { + return this.wrapTickStep(() -> { + // Gale end - split tick steps int i = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE); long j; @@ -667,40 +782,155 @@ public class ServerLevel extends Level implements WorldGenLevel { this.resetWeatherCycle(); } } + // Gale start - split tick steps + }); + } + private Runnable tickStep_updateSkyBrightness_create() { + return this.wrapTickStep(() -> { + // Gale end - split tick steps this.updateSkyBrightness(); + // Gale start - split tick steps + }); + } + + private Runnable tickStep_tickTime_create() { + return this.wrapTickStep(() -> { + // Gale end - split tick steps this.tickTime(); + // Gale start - split tick steps + }); + } + + private Runnable wrapScheduledBlocksTickStep(Runnable runnable) { + return this.wrapTickStep(() -> { + // Gale end - split tick steps timings.scheduledBlocks.startTiming(); // Paper - if (!this.isDebug()) { - j = this.getGameTime(); - this.blockTicks.tick(j, 65536, this::tickBlock); - this.fluidTicks.tick(j, 65536, this::tickFluid); - } + // Gale start - split tick steps + runnable.run(); timings.scheduledBlocks.stopTiming(); // Paper + }); + } + + private Runnable tickStep_setScheduledBlocksGameTime_create() { + return this.wrapScheduledBlocksTickStep(() -> { + this.tick_scheduledBlocksGameTime = this.getGameTime(); + }); + } + + private Runnable tickStep_setIsDebug_create() { + return this.wrapScheduledBlocksTickStep(() -> { + this.tick_isDebug = this.isDebug(); + }); + } + + private Runnable wrapNonDebugScheduledBlocksTickStep(Runnable runnable) { + return this.wrapScheduledBlocksTickStep(() -> { + if (!this.tick_isDebug) { + runnable.run(); + } + }); + } + + private Runnable tickStep_tickBlocks_create() { + return this.wrapScheduledBlocksTickStep(() -> { + this.blockTicks.tick(this.tick_scheduledBlocksGameTime, 65536, this::tickBlock); + }); + } + private Runnable tickStep_tickFluids_create() { + return this.wrapScheduledBlocksTickStep(() -> { + this.fluidTicks.tick(this.tick_scheduledBlocksGameTime, 65536, this::tickFluid); + }); + } + + private Runnable tickStep_tickRaids_create() { + return this.wrapTickStep(() -> { + // Gale end - split tick steps this.timings.raids.startTiming(); // Paper - timings this.raids.tick(); this.timings.raids.stopTiming(); // Paper - timings - this.timings.chunkProviderTick.startTiming(); // Paper - timings - this.getChunkSource().tick(shouldKeepTicking, true); - this.timings.chunkProviderTick.stopTiming(); // Paper - timings + // Gale start - split tick steps + }); + } + + private Runnable tickStep_tickChunkSource_create() { + return () -> { + this.getChunkSource().tick(MinecraftServer.tick_shouldKeepTicking, true); + }; + } + + private Runnable tickStep_doRunBlockEvents_create() { + return this.wrapTickStep(() -> { + // Gale end - split tick steps timings.doSounds.startTiming(); // Spigot this.runBlockEvents(); timings.doSounds.stopTiming(); // Spigot + // Gale start - split tick steps + }); + } + + private Runnable tickStep_stopHandlingTick_create() { + return this.wrapTickStep(() -> { + // Gale end - split tick steps this.handlingTick = false; + // Gale start - split tick steps + }); + } + + private Runnable tickStep_setDoEntityAndBlockEntityTick_create() { + return this.wrapTickStep(() -> { + // Gale end - split tick steps boolean flag = true || !this.players.isEmpty() || !this.getForcedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players if (flag) { this.resetEmptyTime(); } - if (flag || this.emptyTime++ < 300) { + // Gale start - split tick steps + this.tick_doEntityAndBlockEntityTick = flag || this.emptyTime++ < 300; + }); + } + + private Runnable wrapDoEntityAndBlockEntityTickTickStep(Runnable runnable) { + return this.wrapTickStep(() -> { + if (this.tick_doEntityAndBlockEntityTick) { + runnable.run(); + } + }); + } + + private Runnable wrapTickEntitiesTickStep(Runnable runnable) { + return this.wrapDoEntityAndBlockEntityTickTickStep(() -> { + // Gale end - split tick steps timings.tickEntities.startTiming(); // Spigot + // Gale start - split tick steps + runnable.run(); + timings.tickEntities.stopTiming(); // Spigot + }); + } + + private Runnable tickStep_tickDragonFight_create() { + return this.wrapTickEntitiesTickStep(() -> { + // Gale end - split tick steps if (this.dragonFight != null) { this.dragonFight.tick(); } + // Gale start - split tick steps + }); + } + private Runnable tickStep_activateEntities_create() { + return this.wrapTickEntitiesTickStep(() -> { + // Gale end - split tick steps org.spigotmc.ActivationRange.activateEntities(this); // Spigot + // Gale start - split tick steps + }); + } + + private Runnable tickStep_tickEntityList_create() { + return this.wrapTickEntitiesTickStep(() -> { + // Gale end - split tick steps timings.entityTick.startTiming(); // Spigot this.entityTickList.forEach((entity) -> { if (!entity.isRemoved()) { @@ -738,11 +968,15 @@ public class ServerLevel extends Level implements WorldGenLevel { } }); timings.entityTick.stopTiming(); // Spigot - timings.tickEntities.stopTiming(); // Spigot - this.tickBlockEntities(); - } + // Gale start - split tick steps + }); + } - //this.entityManager.tick(); // Paper - rewrite chunk system + private Runnable tickStep_tickBlockEntities_create() { + return this.wrapDoEntityAndBlockEntityTickTickStep(() -> { + // Gale end - split tick steps + this.tickBlockEntities(); + }); // Gale - split tick steps } @Override