mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2026-01-06 15:51:31 +00:00
ClassInstanceMultiMap belongs to Minecraft vanilla entity storage. And is unused, since replaced by spottedleaf's entity storage (rewrite chunk system). However these patches might be useful for vanilla entity storage if is used.
51 lines
3.8 KiB
Diff
51 lines
3.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: MrPowerGamerBR <git@mrpowergamerbr.com>
|
|
Date: Sun, 26 Nov 2023 13:02:16 -0300
|
|
Subject: [PATCH] PaperPR: Fix MC-117075: Block Entities Unload Lag Spike
|
|
|
|
Original license: GPLv3
|
|
Original project: https://github.com/SparklyPower/SparklyPaper
|
|
Paper pull request: https://github.com/PaperMC/Paper/pull/9970
|
|
|
|
We replaced the `blockEntityTickers` list with a custom list based on fastutil's `ObjectArrayList` with a small yet huge change for us: A method that allows us to remove a list of indexes from the list.
|
|
|
|
This is WAY FASTER than using `removeAll` with a list of entries to be removed, because we don't need to calculate the identity of each block entity to be removed, and we can jump directly to where the search should begin, giving a performance boost for small removals (because we don't need to loop thru the entire list to find what element should be removed) and a performance boost for big removals (no need to calculate the identity of each block entity).
|
|
|
|
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
|
|
index 8ebfb2f5cf439190ea9bd4ad81d737fbcd4514c2..ca39e3bd93f896d5c7b1fc3b9264f64555be5d50 100644
|
|
--- a/net/minecraft/world/level/Level.java
|
|
+++ b/net/minecraft/world/level/Level.java
|
|
@@ -104,7 +104,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
|
|
public static final int TICKS_PER_DAY = 24000;
|
|
public static final int MAX_ENTITY_SPAWN_Y = 20000000;
|
|
public static final int MIN_ENTITY_SPAWN_Y = -20000000;
|
|
- public final List<TickingBlockEntity> blockEntityTickers = Lists.newArrayList();
|
|
+ public final List<TickingBlockEntity> blockEntityTickers = new org.dreeam.leaf.util.list.BlockEntityTickersList(); // Paper - public // SparklyPaper - optimize block entity removals
|
|
protected final NeighborUpdater neighborUpdater;
|
|
private final List<TickingBlockEntity> pendingBlockEntityTickers = Lists.newArrayList();
|
|
private boolean tickingBlockEntities;
|
|
@@ -1507,13 +1507,11 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
|
|
boolean runsNormally = this.tickRateManager().runsNormally();
|
|
|
|
int tickedEntities = 0; // Paper - rewrite chunk system
|
|
- var toRemove = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<TickingBlockEntity>(); // Paper - Fix MC-117075; use removeAll
|
|
- toRemove.add(null); // Paper - Fix MC-117075
|
|
for (this.tileTickPosition = 0; this.tileTickPosition < this.blockEntityTickers.size(); this.tileTickPosition++) { // Paper - Disable tick limiters
|
|
TickingBlockEntity tickingBlockEntity = this.blockEntityTickers.get(this.tileTickPosition);
|
|
// Spigot end
|
|
if (tickingBlockEntity.isRemoved()) {
|
|
- toRemove.add(tickingBlockEntity); // Paper - Fix MC-117075; use removeAll
|
|
+ ((org.dreeam.leaf.util.list.BlockEntityTickersList) this.blockEntityTickers).markAsRemoved(this.tileTickPosition); // toRemove.add(tickingBlockEntity); // SparklyPaper - optimize block entity removals // Paper - Fix MC-117075; use removeAll
|
|
} else if (runsNormally && this.shouldTickBlocksAt(tickingBlockEntity.getPos())) {
|
|
tickingBlockEntity.tick();
|
|
// Paper start - rewrite chunk system
|
|
@@ -1523,7 +1521,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
|
|
// Paper end - rewrite chunk system
|
|
}
|
|
}
|
|
- this.blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075
|
|
+ ((org.dreeam.leaf.util.list.BlockEntityTickersList) this.blockEntityTickers).removeMarkedEntries(); // SparklyPaper - optimize block entity removals
|
|
|
|
this.tickingBlockEntities = false;
|
|
this.spigotConfig.currentPrimedTnt = 0; // Spigot
|