5
5
import com .mojang .serialization .Codec ;
6
6
import com .mojang .serialization .JsonOps ;
7
7
import com .mojang .serialization .codecs .RecordCodecBuilder ;
8
- import de .hysky .skyblocker .config .SkyblockerConfig ;
9
8
import de .hysky .skyblocker .config .SkyblockerConfigManager ;
10
9
import de .hysky .skyblocker .config .configs .DungeonsConfig ;
11
10
import de .hysky .skyblocker .utils .render .RenderHelper ;
11
+ import de .hysky .skyblocker .utils .waypoint .NamedWaypoint ;
12
12
import de .hysky .skyblocker .utils .waypoint .Waypoint ;
13
13
import net .fabricmc .fabric .api .client .rendering .v1 .WorldRenderContext ;
14
14
import net .minecraft .client .MinecraftClient ;
29
29
import java .util .function .Supplier ;
30
30
import java .util .function .ToDoubleFunction ;
31
31
32
- public class SecretWaypoint extends Waypoint {
32
+ public class SecretWaypoint extends NamedWaypoint {
33
33
private static final Logger LOGGER = LoggerFactory .getLogger (SecretWaypoint .class );
34
34
public static final Codec <SecretWaypoint > CODEC = RecordCodecBuilder .create (instance -> instance .group (
35
35
Codec .INT .fieldOf ("secretIndex" ).forGetter (secretWaypoint -> secretWaypoint .secretIndex ),
@@ -43,8 +43,6 @@ public class SecretWaypoint extends Waypoint {
43
43
static final Supplier <Type > TYPE_SUPPLIER = () -> CONFIG .get ().waypointType ;
44
44
final int secretIndex ;
45
45
final Category category ;
46
- final Text name ;
47
- private final Vec3d centerPos ;
48
46
49
47
SecretWaypoint (int secretIndex , JsonObject waypoint , String name , BlockPos pos ) {
50
48
this (secretIndex , Category .get (waypoint ), name , pos );
@@ -55,11 +53,9 @@ public class SecretWaypoint extends Waypoint {
55
53
}
56
54
57
55
SecretWaypoint (int secretIndex , Category category , Text name , BlockPos pos ) {
58
- super (pos , TYPE_SUPPLIER , category .colorComponents );
56
+ super (pos , name , TYPE_SUPPLIER , category .colorComponents );
59
57
this .secretIndex = secretIndex ;
60
58
this .category = category ;
61
- this .name = name ;
62
- this .centerPos = pos .toCenterPos ();
63
59
}
64
60
65
61
static ToDoubleFunction <SecretWaypoint > getSquaredDistanceToFunction (Entity entity ) {
@@ -96,6 +92,11 @@ public boolean equals(Object obj) {
96
92
return super .equals (obj ) || obj instanceof SecretWaypoint other && secretIndex == other .secretIndex && category == other .category && name .equals (other .name ) && pos .equals (other .pos );
97
93
}
98
94
95
+ @ Override
96
+ protected boolean shouldRenderName () {
97
+ return CONFIG .get ().showSecretText ;
98
+ }
99
+
99
100
/**
100
101
* Renders the secret waypoint, including a waypoint through {@link Waypoint#render(WorldRenderContext)}, the name, and the distance from the player.
101
102
*/
@@ -106,7 +107,6 @@ public void render(WorldRenderContext context) {
106
107
107
108
if (CONFIG .get ().showSecretText ) {
108
109
Vec3d posUp = centerPos .add (0 , 1 , 0 );
109
- RenderHelper .renderText (context , name , posUp , true );
110
110
double distance = context .camera ().getPos ().distanceTo (centerPos );
111
111
RenderHelper .renderText (context , Text .literal (Math .round (distance ) + "m" ).formatted (Formatting .YELLOW ), posUp , 1 , MinecraftClient .getInstance ().textRenderer .fontHeight + 1 , true );
112
112
}
0 commit comments