diff options
author | Nassim Jahnke <[email protected]> | 2023-06-26 18:41:08 +0200 |
---|---|---|
committer | Nassim Jahnke <[email protected]> | 2023-06-26 18:41:08 +0200 |
commit | 990be1691b8b89295de56ed7ebda5d77aa43aac2 (patch) | |
tree | c18ed9e3392b9147d93ea8faec58f3265dc4f17a | |
parent | e8bec64217064476784a5c65a5060cfc0145fa98 (diff) | |
download | Paper-990be1691b8b89295de56ed7ebda5d77aa43aac2.tar.gz Paper-990be1691b8b89295de56ed7ebda5d77aa43aac2.zip |
Iterate over entity array copy for entity scheduler
-rw-r--r-- | patches/server/0019-Rewrite-chunk-system.patch | 9 | ||||
-rw-r--r-- | patches/server/0977-Folia-scheduler-and-owned-region-API.patch | 22 |
2 files changed, 19 insertions, 12 deletions
diff --git a/patches/server/0019-Rewrite-chunk-system.patch b/patches/server/0019-Rewrite-chunk-system.patch index 2382b951d9..e91f31b090 100644 --- a/patches/server/0019-Rewrite-chunk-system.patch +++ b/patches/server/0019-Rewrite-chunk-system.patch @@ -3742,10 +3742,10 @@ index 0000000000000000000000000000000000000000..924539d4ac50c70178ba220424ffacd6 +} diff --git a/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java b/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java new file mode 100644 -index 0000000000000000000000000000000000000000..82ccaf612548a7dbab7e5aeffb6eb8db84367477 +index 0000000000000000000000000000000000000000..41791c7331c80d496cde4e3d1846a178bef0bbe3 --- /dev/null +++ b/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java -@@ -0,0 +1,840 @@ +@@ -0,0 +1,845 @@ +package io.papermc.paper.chunk.system.entity; + +import com.destroystokyo.paper.util.maplist.EntityList; @@ -3776,6 +3776,7 @@ index 0000000000000000000000000000000000000000..82ccaf612548a7dbab7e5aeffb6eb8db +import org.jetbrains.annotations.Nullable; +import org.slf4j.Logger; +import java.util.ArrayList; ++import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.NoSuchElementException; @@ -3939,6 +3940,10 @@ index 0000000000000000000000000000000000000000..82ccaf612548a7dbab7e5aeffb6eb8db + return new ArrayIterable<>(this.accessibleEntities.getRawData(), 0, this.accessibleEntities.size()); + } + ++ public Entity[] getAllCopy() { ++ return Arrays.copyOf(this.accessibleEntities.getRawData(), this.accessibleEntities.size(), Entity[].class); ++ } ++ + @Override + public <U extends Entity> void get(final EntityTypeTest<Entity, U> filter, final AbortableIterationConsumer<U> action) { + for (final Entity entity : this.entityById.values()) { diff --git a/patches/server/0977-Folia-scheduler-and-owned-region-API.patch b/patches/server/0977-Folia-scheduler-and-owned-region-API.patch index dd099b06ef..dd7e0f3eeb 100644 --- a/patches/server/0977-Folia-scheduler-and-owned-region-API.patch +++ b/patches/server/0977-Folia-scheduler-and-owned-region-API.patch @@ -1121,24 +1121,26 @@ index 0000000000000000000000000000000000000000..d306f911757a4d556c82c0070d4837db + } +} diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 80cf4852e4010eeeadaf920ab927a40df0179b40..912affb0ab1c4c40f7a655194e95ec6f0ebf1fcd 100644 +index 80cf4852e4010eeeadaf920ab927a40df0179b40..3238cbcba567b1242c77e41f6b6f19a8d157fb4e 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1479,6 +1479,18 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa +@@ -1479,6 +1479,20 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa MinecraftTimings.bukkitSchedulerTimer.startTiming(); // Spigot // Paper this.server.getScheduler().mainThreadHeartbeat(this.tickCount); // CraftBukkit MinecraftTimings.bukkitSchedulerTimer.stopTiming(); // Spigot // Paper + // Paper start - Folia scheduler API + ((io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler) Bukkit.getGlobalRegionScheduler()).tick(); -+ getAllLevels().forEach(level -> level.getAllEntities().forEach(entity -> { -+ if (entity.isRemoved()) { -+ return; -+ } -+ org.bukkit.craftbukkit.entity.CraftEntity bukkit = entity.getBukkitEntityRaw(); -+ if (bukkit != null) { -+ bukkit.taskScheduler.executeTick(); ++ getAllLevels().forEach(level -> { ++ for (final Entity entity : level.getEntityLookup().getAllCopy()) { ++ if (entity.isRemoved()) { ++ continue; ++ } ++ final org.bukkit.craftbukkit.entity.CraftEntity bukkit = entity.getBukkitEntityRaw(); ++ if (bukkit != null) { ++ bukkit.taskScheduler.executeTick(); ++ } + } -+ })); ++ }); + // Paper end - Folia scheduler API io.papermc.paper.adventure.providers.ClickCallbackProviderImpl.CALLBACK_MANAGER.handleQueue(this.tickCount); // Paper this.profiler.push("commandFunctions"); |