testserver/patches/server/0162-Fix-MC-117075-TE-Unloa...

43 lines
2.4 KiB
Diff
Raw Normal View History

2021-06-16 04:53:50 +00: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
2022-06-07 20:45:38 +00:00
index 4aea5e937e2e0e272e5aeb4e6b9ed750064f3828..fc7d5f89b0ad56ab30d32b8ff2a301a55ad768dc 100644
2021-06-16 04:53:50 +00:00
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
2022-06-07 20:45:38 +00:00
@@ -687,6 +687,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
2021-06-16 04:53:50 +00:00
// Spigot start
// Iterator iterator = this.blockEntityTickers.iterator();
int tilesThisCycle = 0;
2021-06-17 01:43:30 +00:00
+ var toRemove = new it.unimi.dsi.fastutil.objects.ObjectOpenCustomHashSet<TickingBlockEntity>(net.minecraft.Util.identityStrategy()); // Paper - use removeAll
2021-06-16 04:53:50 +00: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;
TickingBlockEntity tickingblockentity = (TickingBlockEntity) this.blockEntityTickers.get(tileTickPosition);
2022-06-07 20:45:38 +00:00
@@ -694,7 +696,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
2021-06-16 04:53:50 +00: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
2022-06-07 20:45:38 +00:00
@@ -702,12 +703,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
2021-06-16 04:53:50 +00:00
if (tickingblockentity.isRemoved()) {
// Spigot start
tilesThisCycle--;
- this.blockEntityTickers.remove(this.tileTickPosition--);
+ toRemove.add(tickingblockentity); // Paper - use removeAll
// Spigot end
2022-06-07 20:45:38 +00:00
} else if (this.shouldTickBlocksAt(tickingblockentity.getPos())) {
2021-06-16 04:53:50 +00:00
tickingblockentity.tick();
}
}
+ this.blockEntityTickers.removeAll(toRemove);
timings.tileEntityTick.stopTiming(); // Spigot
this.tickingBlockEntities = false;