Fix blank names for a few seconds after spawning a npc. (#2477)

This commit is contained in:
mariaum 2021-02-22 08:27:06 -03:00 committed by GitHub
parent 6c26f98080
commit 0b41b24425
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -327,6 +327,7 @@ public class CitizensNPC extends AbstractNPC {
}
updateFlyableState();
updateCustomNameVisibility();
updateCustomName();
Messaging.debug("Spawned", getId(), "SpawnReason." + reason);
@ -381,11 +382,7 @@ public class CitizensNPC extends AbstractNPC {
updateCounter = 0;
}
String nameplateVisible = data().<Object> get(NPC.NAMEPLATE_VISIBLE_METADATA, true).toString();
if (requiresNameHologram()) {
nameplateVisible = "false";
}
getEntity().setCustomNameVisible(Boolean.parseBoolean(nameplateVisible));
updateCustomNameVisibility();
if (isLiving) {
NMS.setKnockbackResistance((LivingEntity) getEntity(),
@ -406,6 +403,14 @@ public class CitizensNPC extends AbstractNPC {
}
}
private void updateCustomNameVisibility() {
String nameplateVisible = data().<Object> get(NPC.NAMEPLATE_VISIBLE_METADATA, true).toString();
if (requiresNameHologram()) {
nameplateVisible = "false";
}
getEntity().setCustomNameVisible(Boolean.parseBoolean(nameplateVisible));
}
private void updateCustomName() {
boolean nameVisibility = false;
if (!getEntity().isCustomNameVisible()