From 47210bb1ce850776f48490461e6188ce01ab9d74 Mon Sep 17 00:00:00 2001 From: Jitse Boonstra Date: Tue, 21 Jul 2020 16:59:45 +0200 Subject: [PATCH] Update NPCBase.java --- .../main/java/net/jitse/npclib/internal/NPCBase.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/api/src/main/java/net/jitse/npclib/internal/NPCBase.java b/api/src/main/java/net/jitse/npclib/internal/NPCBase.java index b2f5159..6d5cbec 100644 --- a/api/src/main/java/net/jitse/npclib/internal/NPCBase.java +++ b/api/src/main/java/net/jitse/npclib/internal/NPCBase.java @@ -66,7 +66,7 @@ public abstract class NPCBase implements NPC, NPCPacketHandler { } @Override - public Hologram getPlayerHologram(Player player){ + public Hologram getPlayerHologram(Player player) { Hologram playerHologram = textDisplayHolograms.getOrDefault(player.getUniqueId(), null); return playerHologram; } @@ -81,13 +81,13 @@ public abstract class NPCBase implements NPC, NPCPacketHandler { public NPC setPlayerLines(List uniqueLines, Player targetPlayer, boolean update) { List originalLines = getPlayerLines(targetPlayer); setPlayerLines(uniqueLines, targetPlayer); - if (update){ - if (originalLines.size() != uniqueLines.size()){ // recreate the entire hologram + if (update) { + if (originalLines.size() != uniqueLines.size()) { // recreate the entire hologram Hologram originalhologram = getPlayerHologram(targetPlayer); originalhologram.hide(targetPlayer); // essentially destroy the hologram textDisplayHolograms.remove(targetPlayer.getUniqueId()); // remove the old obj } - + if (isShown(targetPlayer)) { //only show hologram if the player is in range Hologram hologram = getPlayerHologram(targetPlayer); List updatePackets = hologram.getUpdatePackets(getPlayerLines(targetPlayer)); @@ -208,7 +208,7 @@ public abstract class NPCBase implements NPC, NPCPacketHandler { public boolean inViewOf(Player player) { Vector dir = location.toVector().subtract(player.getEyeLocation().toVector()).normalize(); - return dir.dot(player.getLocation().getDirection()) >= cosFOV; + return dir.dot(player.getEyeLocation().getDirection()) >= cosFOV; } @Override