Properly merge/split tracker entities

Fixes https://github.com/PaperMC/Folia/issues/256 https://github.com/PaperMC/Folia/issues/255
This commit is contained in:
Spottedleaf 2024-07-31 19:15:49 -07:00
parent 61dcc07256
commit dafae4f54a

View File

@ -2832,10 +2832,10 @@ index 0000000000000000000000000000000000000000..a1e1782d87403ca8934d37361be7ba66
+}
diff --git a/src/main/java/io/papermc/paper/threadedregions/RegionizedWorldData.java b/src/main/java/io/papermc/paper/threadedregions/RegionizedWorldData.java
new file mode 100644
index 0000000000000000000000000000000000000000..6277d69efb9945fcfe7a5e1ad6597e92527f9112
index 0000000000000000000000000000000000000000..5dc4c8a5b896f519be5414d4a53a71144c225324
--- /dev/null
+++ b/src/main/java/io/papermc/paper/threadedregions/RegionizedWorldData.java
@@ -0,0 +1,760 @@
@@ -0,0 +1,772 @@
+package io.papermc.paper.threadedregions;
+
+import ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet;
@ -2934,6 +2934,12 @@ index 0000000000000000000000000000000000000000..6277d69efb9945fcfe7a5e1ad6597e92
+ for (final Iterator<Mob> iterator = from.navigatingMobs.unsafeIterator(); iterator.hasNext();) {
+ into.navigatingMobs.add(iterator.next());
+ }
+ for (final Iterator<Entity> iterator = from.trackerEntities.iterator(); iterator.hasNext();) {
+ into.trackerEntities.add(iterator.next());
+ }
+ for (final Iterator<Entity> iterator = from.trackerUnloadedEntities.iterator(); iterator.hasNext();) {
+ into.trackerUnloadedEntities.add(iterator.next());
+ }
+ // block ticking
+ into.blockEvents.addAll(from.blockEvents);
+ // ticklists use game time
@ -3032,6 +3038,12 @@ index 0000000000000000000000000000000000000000..6277d69efb9945fcfe7a5e1ad6597e92
+ if (entity instanceof Mob mob && from.navigatingMobs.contains(mob)) {
+ into.navigatingMobs.add(mob);
+ }
+ if (from.trackerEntities.contains(entity)) {
+ into.trackerEntities.add(entity);
+ }
+ if (from.trackerUnloadedEntities.contains(entity)) {
+ into.trackerUnloadedEntities.add(entity);
+ }
+ }
+ // block ticking
+ for (final BlockEventData blockEventData : from.blockEvents) {