Skip to content

Commit af7555e

Browse files
Fix block entity ticking list (#13724)
Co-authored-by: Bjarne Koll <git@lynxplay.dev>
1 parent 3ed8098 commit af7555e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

paper-server/patches/sources/net/minecraft/world/level/Level.java.patch

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -443,26 +443,26 @@
443443
}
444444

445445
- Iterator<TickingBlockEntity> iterator = this.blockEntityTickers.iterator();
446+
+ // Paper - Fix MC-117075 use removeAll - remove iterator in favour of indexed for loop, ensuring compile error if something uses iter incorrectly
446447
boolean tickBlockEntities = this.tickRateManager().runsNormally();
447448

448449
- while (iterator.hasNext()) {
449450
- TickingBlockEntity ticker = iterator.next();
450-
+ // Paper start - Fix MC-117075; use removeAll
451-
+ final java.util.Set<@Nullable TickingBlockEntity> toRemove = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<>();
451+
+ // Paper start - Fix MC-117075 use removeAll
452+
+ final it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<@Nullable TickingBlockEntity> toRemove = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<>();
452453
+ toRemove.add(null);
453-
+
454-
+ for (final TickingBlockEntity ticker : this.pendingBlockEntityTickers) {
454+
+ for (int tickerIndex = 0; tickerIndex < this.blockEntityTickers.size(); tickerIndex++) {
455+
+ final TickingBlockEntity ticker = this.blockEntityTickers.get(tickerIndex);
456+
+ // Paper end - Fix MC-117075 use removeAll
455457
if (ticker.isRemoved()) {
456458
- iterator.remove();
457-
+ toRemove.add(ticker);
459+
+ toRemove.add(ticker); // Paper - Fix MC-117075 use removeAll
458460
} else if (tickBlockEntities && this.shouldTickBlocksAt(ticker.getPos())) {
459461
ticker.tick();
460462
}
461463
}
462464

463-
+ this.blockEntityTickers.removeAll(toRemove);
464-
+ // Paper end - Fix MC-117075; use removeAll
465-
+
465+
+ this.blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075 use removeAll
466466
this.tickingBlockEntities = false;
467467
+ this.spigotConfig.currentPrimedTnt = 0; // Spigot
468468
}

0 commit comments

Comments
 (0)