2021-06-16 06:53:50 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: mezz <tehgeek@gmail.com>
|
|
|
|
Date: Wed, 9 Aug 2017 17:51:22 -0500
|
2024-01-22 18:04:55 +01:00
|
|
|
Subject: [PATCH] Fix MC-117075: Block entity unload lag spike
|
2021-06-16 06:53:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
2024-01-23 15:43:48 +01:00
|
|
|
index 4e1b8ce73f07b8ea12f9f2b7883cd994aed73648..0e837193b5b858d0be30974c7454cf76920d58e9 100644
|
2021-06-16 06:53:50 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
2024-01-23 15:43:48 +01:00
|
|
|
@@ -732,6 +732,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
2023-12-05 23:12:48 +01:00
|
|
|
boolean flag = this.tickRateManager().runsNormally();
|
|
|
|
|
2021-06-16 06:53:50 +02:00
|
|
|
int tilesThisCycle = 0;
|
2024-01-22 18:04:55 +01:00
|
|
|
+ var toRemove = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<TickingBlockEntity>(); // Paper - Fix MC-117075; use removeAll
|
|
|
|
+ toRemove.add(null); // Paper - Fix MC-117075
|
2021-06-16 06:53:50 +02:00
|
|
|
for (tileTickPosition = 0; tileTickPosition < this.blockEntityTickers.size(); tileTickPosition++) { // Paper - Disable tick limiters
|
|
|
|
this.tileTickPosition = (this.tileTickPosition < this.blockEntityTickers.size()) ? this.tileTickPosition : 0;
|
2023-10-27 01:34:58 +02:00
|
|
|
TickingBlockEntity tickingblockentity = (TickingBlockEntity) this.blockEntityTickers.get(this.tileTickPosition);
|
2024-01-23 15:43:48 +01:00
|
|
|
@@ -740,12 +742,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
2021-06-16 06:53:50 +02:00
|
|
|
if (tickingblockentity.isRemoved()) {
|
|
|
|
// Spigot start
|
|
|
|
tilesThisCycle--;
|
|
|
|
- this.blockEntityTickers.remove(this.tileTickPosition--);
|
2024-01-22 18:04:55 +01:00
|
|
|
+ toRemove.add(tickingblockentity); // Paper - Fix MC-117075; use removeAll
|
2021-06-16 06:53:50 +02:00
|
|
|
// Spigot end
|
2023-12-05 23:12:48 +01:00
|
|
|
} else if (flag && this.shouldTickBlocksAt(tickingblockentity.getPos())) {
|
2021-06-16 06:53:50 +02:00
|
|
|
tickingblockentity.tick();
|
|
|
|
}
|
|
|
|
}
|
2024-01-22 18:04:55 +01:00
|
|
|
+ this.blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075
|
2021-06-16 06:53:50 +02:00
|
|
|
|
2023-10-27 01:34:58 +02:00
|
|
|
this.timings.tileEntityTick.stopTiming(); // Spigot
|
2021-06-16 06:53:50 +02:00
|
|
|
this.tickingBlockEntities = false;
|