Skip to content

Commit 7d2434d

Browse files
committed
feat: update NPC stuff
1 parent 5115114 commit 7d2434d

7 files changed

Lines changed: 26 additions & 15 deletions

File tree

type.generic/src/main/java/net/swofty/type/generic/entity/npc/HypixelNPC.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import net.kyori.adventure.sound.Sound;
77
import net.minestom.server.coordinate.Pos;
88
import net.minestom.server.entity.Entity;
9+
import net.minestom.server.entity.GameMode;
910
import net.swofty.type.generic.entity.npc.configuration.AnimalConfiguration;
1011
import net.swofty.type.generic.entity.npc.configuration.HumanConfiguration;
1112
import net.swofty.type.generic.entity.npc.configuration.NPCConfiguration;
@@ -153,7 +154,7 @@ public static void updateForPlayer(HypixelPlayer player) {
153154

154155
Pos playerPosition = player.getPosition();
155156
double entityDistance = playerPosition.distance(npcPosition);
156-
boolean isLookingNPC = config.looking(player);
157+
boolean isLookingNPC = config.looking(player) && player.getGameMode() != GameMode.SPECTATOR;
157158

158159
// Get inRangeOf list based on entity type
159160
List<HypixelPlayer> inRange = npcViewable.getInRangeOf();

type.generic/src/main/java/net/swofty/type/generic/entity/npc/configuration/NPCConfiguration.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,8 @@ default Instance instance() {
3333
default EntityPose pose(HypixelPlayer player) {
3434
return EntityPose.STANDING;
3535
}
36+
37+
default boolean shouldDisplayHolograms(HypixelPlayer player) {
38+
return true;
39+
}
3640
}

type.generic/src/main/java/net/swofty/type/generic/entity/npc/impl/NPCEntityImpl.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ public NPCEntityImpl(@NotNull HypixelPlayer viewer, @NotNull Pos pos, @NotNull S
6565
.build();
6666

6767
this.holo = holo;
68-
PlayerHolograms.addExternalPlayerHologram(holo);
68+
if (config.shouldDisplayHolograms(viewer)) {
69+
PlayerHolograms.addExternalPlayerHologram(holo);
70+
}
6971

7072
setInstance(config.instance(), pos);
7173
addViewer(viewer);
@@ -122,7 +124,7 @@ public void tick(long time) {
122124
@Override
123125
public void updateNPC() {
124126
Pos npcPosition = config.position(viewer);
125-
if (!getPosition().asVec().equals(npcPosition.asVec())) {
127+
if (!getPosition().asVec().equals(npcPosition.asVec()) && config.shouldDisplayHolograms(viewer)) {
126128
PlayerHolograms.relocateExternalPlayerHologram(holo, npcPosition.add(0, getEyeHeight() + 0.1f, 0));
127129
}
128130

@@ -137,10 +139,14 @@ public void updateNPC() {
137139
));
138140
}
139141

140-
String[] newHolograms = config.holograms(viewer);
141-
if (!Arrays.equals(newHolograms, holograms)) {
142-
PlayerHolograms.updateExternalPlayerHologramText(holo, newHolograms);
143-
this.holograms = newHolograms;
142+
if (config.shouldDisplayHolograms(viewer)) {
143+
String[] newHolograms = config.holograms(viewer);
144+
if (!Arrays.equals(newHolograms, holograms)) {
145+
PlayerHolograms.updateExternalPlayerHologramText(holo, newHolograms);
146+
this.holograms = newHolograms;
147+
}
148+
} else {
149+
PlayerHolograms.removeExternalPlayerHologram(holo);
144150
}
145151

146152
String actualSkinTexture = config.texture(viewer);

type.hub/src/main/java/net/swofty/type/hub/npcs/NPCDanteMemorial.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public Pos position(HypixelPlayer player) {
3131
}
3232

3333
@Override
34-
public boolean looking(HypixelPlayer player) {
35-
return true;
34+
public boolean shouldDisplayHolograms(HypixelPlayer player) {
35+
return false;
3636
}
3737
});
3838
}

type.hub/src/main/java/net/swofty/type/hub/npcs/NPCMuseumDisplay.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.swofty.type.hub.npcs;
22

3+
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
34
import net.minestom.server.coordinate.Pos;
45
import net.swofty.type.generic.data.HypixelDataHandler;
56
import net.swofty.type.generic.data.datapoints.DatapointString;
@@ -36,7 +37,7 @@ public String[] holograms(HypixelPlayer p) {
3637
if (dataHandler == null) {
3738
dataHandler = HypixelDataHandler.getOfOfflinePlayer(currentlyViewing);
3839
}
39-
String username = HypixelDataHandler.getPotentialIGNFromUUID(profileUUID);
40+
String username = LegacyComponentSerializer.legacySection().serialize(p.getColouredName());
4041
String profileName = skyblockHandler.get(SkyBlockDataHandler.Data.PROFILE_NAME, DatapointString.class).getValue();
4142

4243
return new String[]{

type.hub/src/main/java/net/swofty/type/hub/npcs/NPCTiaTheFairy.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.swofty.type.hub.npcs;
22

3+
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
34
import net.minestom.server.coordinate.Pos;
45
import net.swofty.type.generic.data.datapoints.DatapointToggles;
56
import net.swofty.type.generic.entity.npc.HypixelNPC;
@@ -60,7 +61,7 @@ public DialogueSet[] dialogues(HypixelPlayer player) {
6061
return Stream.of(
6162
DialogueSet.builder()
6263
.key("hello").lines(new String[]{
63-
"Welcome to the Fairy Pond! I am Tia.",
64+
"Welcome to the §dFairy Pond§f, " + LegacyComponentSerializer.legacySection().serialize(player.getColouredName()) + "! I am Tia.",
6465
"You may have noticed some strange orbs laying around the island.",
6566
"They are the souls of my fallen sisters.",
6667
"If you find any more during your travels, please bring them back to me!"

type.hub/src/main/java/net/swofty/type/hub/npcs/villagers/VillagerLibrarian.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@
44
import net.minestom.server.entity.VillagerProfession;
55
import net.swofty.type.generic.entity.npc.HypixelNPC;
66
import net.swofty.type.generic.entity.npc.configuration.VillagerConfiguration;
7+
import net.swofty.type.generic.event.custom.NPCInteractEvent;
78
import net.swofty.type.generic.user.HypixelPlayer;
89
import net.swofty.type.hub.gui.GUIShopLibrarian;
9-
import net.swofty.type.hub.gui.rosetta.GUIStarlightArmor;
1010
import net.swofty.type.skyblockgeneric.mission.MissionData;
1111
import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer;
1212

1313
import java.util.stream.Stream;
1414

15-
import net.swofty.type.generic.event.custom.NPCInteractEvent;
16-
1715
public class VillagerLibrarian extends HypixelNPC {
1816
public VillagerLibrarian() {
1917
super(new VillagerConfiguration(){
@@ -24,7 +22,7 @@ public String[] holograms(HypixelPlayer player) {
2422

2523
@Override
2624
public Pos position(HypixelPlayer player) {
27-
return new Pos(-35, 69, -112, -45, 0);
25+
return new Pos(-68.5, 70, -79.5, -45, 0);
2826
}
2927

3028
@Override

0 commit comments

Comments
 (0)