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
|
|
|
|
Subject: [PATCH] Fix MC-117075: TE 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
|
2023-12-06 20:40:37 +01:00
|
|
|
index c6e56303ec8ee466a6de7e6bd76c4f6814e8db30..2dad35f00a98be534db1da1a38a6865e41a1a94d 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
|
2023-12-05 23:12:48 +01:00
|
|
|
@@ -816,6 +816,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
|
|
|
boolean flag = this.tickRateManager().runsNormally();
|
|
|
|
|
2021-06-16 06:53:50 +02:00
|
|
|
int tilesThisCycle = 0;
|
2023-12-06 20:40:37 +01:00
|
|
|
+ var toRemove = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<TickingBlockEntity>(); // Paper - use removeAll
|
2021-06-16 06:53:50 +02:00
|
|
|
+ toRemove.add(null);
|
|
|
|
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);
|
2023-12-05 23:12:48 +01:00
|
|
|
@@ -823,7 +825,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
2021-06-16 06:53:50 +02:00
|
|
|
if (tickingblockentity == null) {
|
|
|
|
this.getCraftServer().getLogger().severe("Spigot has detected a null entity and has removed it, preventing a crash");
|
|
|
|
tilesThisCycle--;
|
|
|
|
- this.blockEntityTickers.remove(this.tileTickPosition--);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Spigot end
|
2023-12-05 23:12:48 +01:00
|
|
|
@@ -831,12 +832,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--);
|
|
|
|
+ toRemove.add(tickingblockentity); // Paper - use removeAll
|
|
|
|
// 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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+ this.blockEntityTickers.removeAll(toRemove);
|
|
|
|
|
2023-10-27 01:34:58 +02:00
|
|
|
this.timings.tileEntityTick.stopTiming(); // Spigot
|
2021-06-16 06:53:50 +02:00
|
|
|
this.tickingBlockEntities = false;
|