9
0
mirror of https://github.com/SparklyPower/SparklyPaper.git synced 2025-12-22 08:29:24 +00:00
Files
SparklyPaperMC/patches/server/0020-Cache-entityhuman-display-name.patch
2021-04-18 16:49:49 -03:00

35 lines
1.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Paul Sauve <paul@technove.co>
Date: Sat, 13 Mar 2021 14:02:04 -0600
Subject: [PATCH] Cache entityhuman display name
diff --git a/src/main/java/net/minecraft/world/entity/player/EntityHuman.java b/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
index 44038dd278b988508047023107683e5370af54ad..ad85dda5c50b797904824a08513fbcec042128ea 100644
--- a/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
+++ b/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
@@ -162,7 +162,8 @@ public abstract class EntityHuman extends EntityLiving {
protected int bG;
protected final float bH = 0.02F;
private int g;
- private GameProfile bJ; public final void setProfile(final GameProfile profile) { this.bJ = profile; } // Paper - OBFHELPER
+ private IChatBaseComponent displayName; // Airplane - cache displayName
+ private GameProfile bJ; public final void setProfile(final GameProfile profile) { this.bJ = profile; this.displayName = null; } // Paper - OBFHELPER // Airplane - use to reset displayName
private ItemStack bL;
private final ItemCooldown bM;
@Nullable
@@ -1828,7 +1829,12 @@ public abstract class EntityHuman extends EntityLiving {
@Override
public IChatBaseComponent getDisplayName() {
- return new ChatComponentText(this.bJ.getName());
+ // Airplane start - cache display name
+ if (this.displayName == null) {
+ this.displayName = new ChatComponentText(this.getProfile().getName());
+ }
+ return this.displayName;
+ // Airplane end
}
public InventoryEnderChest getEnderChest() {