Paper/patches/server/0835-Only-tick-item-frames-if-players-can-see-it.patch

21 lines
1.3 KiB
Diff
Raw Normal View History

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
2024-06-14 10:17:11 +02:00
index f3f93710846ce0f6d53845e0b49331646a4e8332..f010be9605d7458add7e5693ff473fabf679c938 100644
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
2024-06-14 10:17:11 +02:00
@@ -112,7 +112,7 @@ public class ServerEntity {
Entity entity = this.entity;
2024-04-25 00:36:49 +02:00
- if (entity instanceof ItemFrame entityitemframe) {
2024-04-25 07:16:04 +02:00
+ if (!this.trackedPlayers.isEmpty() && entity instanceof ItemFrame entityitemframe) { // Paper - Perf: Only tick item frames if players can see it
if (true || this.tickCount % 10 == 0) { // CraftBukkit - Moved below, should always enter this block
2024-04-25 00:36:49 +02:00
ItemStack itemstack = entityitemframe.getItem();