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.
This commit is contained in:
Redned 2023-06-19 15:45:53 -05:00
parent 6702fe7546
commit 4bb84c46ac

View file

@ -60,11 +60,13 @@
ServerEntity.removedPassengers(list, this.lastPassengers).forEach((entity) -> {
if (entity instanceof ServerPlayer entityplayer) {
entityplayer.connection.teleport(entityplayer.getX(), entityplayer.getY(), entityplayer.getZ(), entityplayer.getYRot(), entityplayer.getXRot());
@@ -107,18 +117,18 @@
@@ -106,19 +116,19 @@
Entity entity = this.entity;
if (entity instanceof ItemFrame entityitemframe) {
- if (entity instanceof ItemFrame entityitemframe) {
- if (this.tickCount % 10 == 0) {
+ 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
ItemStack itemstack = entityitemframe.getItem();