mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-26 04:25:26 +01:00
Iterate over entity array copy for entity scheduler
This commit is contained in:
parent
e8bec64217
commit
990be1691b
@ -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()) {
|
||||
|
@ -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;
|
||||
+ 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();
|
||||
+ }
|
||||
+ }
|
||||
+ 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");
|
||||
|
Loading…
Reference in New Issue
Block a user