aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0878-Only-tick-item-frames-if-players-can-see-it.patch
blob: 2ae56c0857d2d6e258f25aaae4251c7a8aec8f8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Redned <redned235@gmail.com>
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 40949825392281c2f7c756007781c672ec24665d..888cbfaf49aa6d1d1b8cc87cf411a1dd53fbe89d 100644
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
@@ -111,7 +111,7 @@ public class ServerEntity {
 
         Entity entity = this.entity;
 
-        if (entity instanceof ItemFrame) {
+        if (!this.trackedPlayers.isEmpty() && entity instanceof ItemFrame) { // Paper - Perf: 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