Skip to content

Commit

Permalink
"this"
Browse files Browse the repository at this point in the history
  • Loading branch information
MrPowerGamerBR committed Nov 26, 2023
1 parent 3c9992b commit 6e182d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions patches/server/0016-Fix-MC-117075-TE-Unload-Lag-Spike.patch
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ We replaced the `blockEntityTickers` list with a custom list based on fastutil's
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/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index ddb618fce875b1a337b139c9c47433453654017b..36c1cc48e6c2541d1218db0560ed7b315ce8067d 100644
index ddb618fce875b1a337b139c9c47433453654017b..f50a66841fd8c798cd881612be302c292afcfa65 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -117,7 +117,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
Expand All @@ -25,7 +25,7 @@ index ddb618fce875b1a337b139c9c47433453654017b..36c1cc48e6c2541d1218db0560ed7b31
this.getCraftServer().getLogger().severe("Spigot has detected a null entity and has removed it, preventing a crash");
tilesThisCycle--;
- this.blockEntityTickers.remove(this.tileTickPosition--);
+ blockEntityTickers.markAsRemoved(this.tileTickPosition); // this.blockEntityTickers.remove(this.tileTickPosition--); // SparklyPaper - optimize block entity removals
+ this.blockEntityTickers.markAsRemoved(this.tileTickPosition); // this.blockEntityTickers.remove(this.tileTickPosition--); // SparklyPaper - optimize block entity removals
continue;
}
// Spigot end
Expand All @@ -34,7 +34,7 @@ index ddb618fce875b1a337b139c9c47433453654017b..36c1cc48e6c2541d1218db0560ed7b31
// Spigot start
tilesThisCycle--;
- this.blockEntityTickers.remove(this.tileTickPosition--);
+ blockEntityTickers.markAsRemoved(this.tileTickPosition); // this.blockEntityTickers.remove(this.tileTickPosition--); // SparklyPaper - optimize block entity removals
+ this.blockEntityTickers.markAsRemoved(this.tileTickPosition); // this.blockEntityTickers.remove(this.tileTickPosition--); // SparklyPaper - optimize block entity removals
// Spigot end
} else if (this.shouldTickBlocksAt(tickingblockentity.getPos())) {
tickingblockentity.tick();
Expand All @@ -43,7 +43,7 @@ index ddb618fce875b1a337b139c9c47433453654017b..36c1cc48e6c2541d1218db0560ed7b31
}
}
-
+ blockEntityTickers.removeMarkedEntries(); // SparklyPaper - optimize block entity removals
+ this.blockEntityTickers.removeMarkedEntries(); // SparklyPaper - optimize block entity removals
this.timings.tileEntityTick.stopTiming(); // Spigot
this.tickingBlockEntities = false;
co.aikar.timings.TimingHistory.tileEntityTicks += this.blockEntityTickers.size(); // Paper
Expand Down
6 changes: 3 additions & 3 deletions patches/server/0017-Optimize-tickBlockEntities.patch
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ But here's the thing: We don't care if we have a small performance penalty if th
And finally, we also cache the chunk's coordinate key when creating the block entity, which is actually "free" because we just reuse the already cached chunk coordinate key from the chunk!

diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 36c1cc48e6c2541d1218db0560ed7b315ce8067d..9c2ce199d486ac143843c5a1492da14f8bdcdfce 100644
index f50a66841fd8c798cd881612be302c292afcfa65..6048e9ed03b633eb545a82a506e5033c61d8176f 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -1270,6 +1270,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
Expand All @@ -28,7 +28,7 @@ index 36c1cc48e6c2541d1218db0560ed7b315ce8067d..9c2ce199d486ac143843c5a1492da14f
TickingBlockEntity tickingblockentity = (TickingBlockEntity) this.blockEntityTickers.get(this.tileTickPosition);
@@ -1287,13 +1291,25 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
tilesThisCycle--;
blockEntityTickers.markAsRemoved(this.tileTickPosition); // this.blockEntityTickers.remove(this.tileTickPosition--); // SparklyPaper - optimize block entity removals
this.blockEntityTickers.markAsRemoved(this.tileTickPosition); // this.blockEntityTickers.remove(this.tileTickPosition--); // SparklyPaper - optimize block entity removals
// Spigot end
- } else if (this.shouldTickBlocksAt(tickingblockentity.getPos())) {
+ // } else if (this.shouldTickBlocksAt(tickingblockentity.getPos())) { // SparklyPaper start - optimize tickBlockEntities
Expand All @@ -52,7 +52,7 @@ index 36c1cc48e6c2541d1218db0560ed7b315ce8067d..9c2ce199d486ac143843c5a1492da14f
+ } // SparklyPaper end
}
}
blockEntityTickers.removeMarkedEntries(); // SparklyPaper - optimize block entity removals
this.blockEntityTickers.removeMarkedEntries(); // SparklyPaper - optimize block entity removals
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TickingBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/TickingBlockEntity.java
index 28e3b73507b988f7234cbf29c4024c88180d0aef..427cf73383155c52bca8fb4b32f43029ff619833 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/TickingBlockEntity.java
Expand Down

0 comments on commit 6e182d7

Please sign in to comment.