aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0158-Fix-MC-117075-Block-entity-unload-lag-spike.patch
blob: 12f777016d062f1d403f0441d1fd473ec9b450b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: mezz <tehgeek@gmail.com>
Date: Wed, 9 Aug 2017 17:51:22 -0500
Subject: [PATCH] Fix MC-117075: Block entity unload lag spike


diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index e5eac1977f77b7ce1112bfe7ac1b77d9ef4d90f4..b8a3116ab104405c26d97f4103eb426f5367071a 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -723,6 +723,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
         boolean flag = this.tickRateManager().runsNormally();
 
         int tilesThisCycle = 0;
+        var toRemove = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<TickingBlockEntity>(); // Paper - Fix MC-117075; use removeAll
+        toRemove.add(null); // Paper - Fix MC-117075
         for (tileTickPosition = 0; tileTickPosition < this.blockEntityTickers.size(); tileTickPosition++) { // Paper - Disable tick limiters
             this.tileTickPosition = (this.tileTickPosition < this.blockEntityTickers.size()) ? this.tileTickPosition : 0;
             TickingBlockEntity tickingblockentity = (TickingBlockEntity) this.blockEntityTickers.get(this.tileTickPosition);
@@ -731,12 +733,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
             if (tickingblockentity.isRemoved()) {
                 // Spigot start
                 tilesThisCycle--;
-                this.blockEntityTickers.remove(this.tileTickPosition--);
+                toRemove.add(tickingblockentity); // Paper - Fix MC-117075; use removeAll
                 // Spigot end
             } else if (flag && this.shouldTickBlocksAt(tickingblockentity.getPos())) {
                 tickingblockentity.tick();
             }
         }
+        this.blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075
 
         this.tickingBlockEntities = false;
         gameprofilerfiller.pop();