Paper/patches/server/0956-Only-tick-item-frames-if-players-can-see-it.patch
Jake Potrebic 0cdce89d59
Fix a bunch of stuff with player spawn locations (#9887)
If a playerdata doesn't contain a valid, loaded world, reset
to the main world spawn point
2023-11-04 14:11:55 -07:00

21 lines
1.2 KiB
Diff

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 9d5d32705f9d8aadb51019f17b4db76a9bc6a04b..625a598eb5f3c9c5ea60ae9ea50974bb08abbf85 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 - 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