13
0
geforkt von Mirrors/Paper

Iterate over entity array copy for entity scheduler

Dieser Commit ist enthalten in:
Nassim Jahnke 2023-06-26 18:41:08 +02:00
Ursprung 9696b46122
Commit 279c17fcdf
2 geänderte Dateien mit 15 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -1130,15 +1130,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
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");

Datei anzeigen

@ -3776,6 +3776,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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..00000000000000000000000000000000
+ 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()) {