aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRedned <[email protected]>2023-06-26 18:26:29 -0500
committerGitHub <[email protected]>2023-06-27 00:26:29 +0100
commit7103f813bc58d335392fe822080a673e6d26293f (patch)
treea9e63ca4e50a99e67ffab67c76161d71f96b0d3f
parent3f6c4b07ac421fba6d2608667f8e38ff9fc453e1 (diff)
downloadPaper-7103f813bc58d335392fe822080a673e6d26293f.tar.gz
Paper-7103f813bc58d335392fe822080a673e6d26293f.zip
Only tick item frames if players can see it (#9377)
In the event that an item frame cannot be seen by any players, ticking the item frame every tick is unnecessary. This can be a very hot section of the entity tracker when lots of item frames are present on a server, so this reduces the logic which speeds it up.
-rw-r--r--patches/server/0981-Only-tick-item-frames-if-players-can-see-it.patch20
1 files changed, 20 insertions, 0 deletions
diff --git a/patches/server/0981-Only-tick-item-frames-if-players-can-see-it.patch b/patches/server/0981-Only-tick-item-frames-if-players-can-see-it.patch
new file mode 100644
index 0000000000..33c6f01d10
--- /dev/null
+++ b/patches/server/0981-Only-tick-item-frames-if-players-can-see-it.patch
@@ -0,0 +1,20 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Redned <[email protected]>
+Date: Mon, 19 Jun 2023 15:45:53 -0500
+Subject: [PATCH] Only tick item frames if players can see it
+
+In the event that an item frame cannot be seen by any players, ticking the item frame every tick is unnecessary. This can be a very hot section of the entity tracker when lots of item frames are present on a server, so this reduces the logic which speeds it up.
+
+diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
+index 6670e657e08e130f7e0368f418379fd1ece00cdf..acaf9f392660d618472aea7bce967d374eb5d549 100644
+--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
++++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
+@@ -108,7 +108,7 @@ public class ServerEntity {
+
+ Entity entity = this.entity;
+
+- if (entity instanceof ItemFrame) {
++ if (!this.trackedPlayers.isEmpty() && entity instanceof ItemFrame) { // Paper - Only tick item frames if players can see it
+ ItemFrame entityitemframe = (ItemFrame) entity;
+
+ if (true || this.tickCount % 10 == 0) { // CraftBukkit - Moved below, should always enter this block