Update NPCBase.java
This commit is contained in:
parent
34b4929bed
commit
47210bb1ce
|
@ -66,7 +66,7 @@ public abstract class NPCBase implements NPC, NPCPacketHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Hologram getPlayerHologram(Player player){
|
public Hologram getPlayerHologram(Player player) {
|
||||||
Hologram playerHologram = textDisplayHolograms.getOrDefault(player.getUniqueId(), null);
|
Hologram playerHologram = textDisplayHolograms.getOrDefault(player.getUniqueId(), null);
|
||||||
return playerHologram;
|
return playerHologram;
|
||||||
}
|
}
|
||||||
|
@ -81,13 +81,13 @@ public abstract class NPCBase implements NPC, NPCPacketHandler {
|
||||||
public NPC setPlayerLines(List<String> uniqueLines, Player targetPlayer, boolean update) {
|
public NPC setPlayerLines(List<String> uniqueLines, Player targetPlayer, boolean update) {
|
||||||
List<String> originalLines = getPlayerLines(targetPlayer);
|
List<String> originalLines = getPlayerLines(targetPlayer);
|
||||||
setPlayerLines(uniqueLines, targetPlayer);
|
setPlayerLines(uniqueLines, targetPlayer);
|
||||||
if (update){
|
if (update) {
|
||||||
if (originalLines.size() != uniqueLines.size()){ // recreate the entire hologram
|
if (originalLines.size() != uniqueLines.size()) { // recreate the entire hologram
|
||||||
Hologram originalhologram = getPlayerHologram(targetPlayer);
|
Hologram originalhologram = getPlayerHologram(targetPlayer);
|
||||||
originalhologram.hide(targetPlayer); // essentially destroy the hologram
|
originalhologram.hide(targetPlayer); // essentially destroy the hologram
|
||||||
textDisplayHolograms.remove(targetPlayer.getUniqueId()); // remove the old obj
|
textDisplayHolograms.remove(targetPlayer.getUniqueId()); // remove the old obj
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isShown(targetPlayer)) { //only show hologram if the player is in range
|
if (isShown(targetPlayer)) { //only show hologram if the player is in range
|
||||||
Hologram hologram = getPlayerHologram(targetPlayer);
|
Hologram hologram = getPlayerHologram(targetPlayer);
|
||||||
List<Object> updatePackets = hologram.getUpdatePackets(getPlayerLines(targetPlayer));
|
List<Object> updatePackets = hologram.getUpdatePackets(getPlayerLines(targetPlayer));
|
||||||
|
@ -208,7 +208,7 @@ public abstract class NPCBase implements NPC, NPCPacketHandler {
|
||||||
|
|
||||||
public boolean inViewOf(Player player) {
|
public boolean inViewOf(Player player) {
|
||||||
Vector dir = location.toVector().subtract(player.getEyeLocation().toVector()).normalize();
|
Vector dir = location.toVector().subtract(player.getEyeLocation().toVector()).normalize();
|
||||||
return dir.dot(player.getLocation().getDirection()) >= cosFOV;
|
return dir.dot(player.getEyeLocation().getDirection()) >= cosFOV;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue