Skip to content

Commit b3f9524

Browse files
Address some reviews
1 parent 8612cfe commit b3f9524

4 files changed

Lines changed: 15 additions & 12 deletions

File tree

api/src/main/java/org/geysermc/geyser/api/waypoint/CustomWaypointStyle.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939

4040
public interface CustomWaypointStyle {
4141

42-
String getTexturePath(GeyserConnection connection, Identifier style, float distance);
42+
String texturePath(GeyserConnection connection, Identifier style, float distance);
4343

44-
Vector2f getTextureSize(GeyserConnection connection, Identifier style, float distance);
44+
Vector2f textureSize(GeyserConnection connection, Identifier style, float distance);
4545

4646
@ApiStatus.NonExtendable
4747
interface VanillaBuilder extends GenericBuilder<CustomWaypointStyle> {

core/src/main/java/org/geysermc/geyser/registry/mappings/MappingsType.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,12 @@
4141

4242
public record MappingsType<K, V>(String name, Int2ObjectMap<MappingsReader<K, V>> readers) {
4343
public static final MappingsType<String, CustomBlockMapping> BLOCKS = create("blocks", builder -> builder
44-
.with(1, new BlockMappingsReader_v1())
45-
.with(2, new BlockMappingsReader_v1()));
44+
.with(1, new BlockMappingsReader_v1()));
4645
public static final MappingsType<Identifier, CustomItemDefinition> ITEMS = create("items", builder -> builder
4746
.with(1, new ItemMappingsReader_v1())
4847
.with(2, new ItemMappingsReader_v2()));
4948
public static final MappingsType<Identifier, CustomWaypointStyle> WAYPOINT_STYLES = create("waypoint_styles", builder -> builder
50-
.with(1, new WaypointStyleMappingsReader_v1())
51-
.with(2, new WaypointStyleMappingsReader_v1()));
49+
.with(1, new WaypointStyleMappingsReader_v1()));
5250

5351
private static <K, V> MappingsType<K, V> create(String name, UnaryOperator<Builder<K, V>> builder) {
5452
return new MappingsType<>(name, Int2ObjectMaps.unmodifiable(builder.apply(new Builder<>()).readers));

core/src/main/java/org/geysermc/geyser/session/cache/waypoint/GeyserWaypoint.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,13 @@ protected void setPosition(Vector3f position) {
166166
if (uses26_10WaypointPacket) {
167167
if (uses26_20WaypointPacket) {
168168
float distance = session.playerEntity().position().distance(position);
169-
String texture = style.getTexturePath(session, styleIdentifier, distance);
170-
Vector2f iconSize = style.getTextureSize(session, styleIdentifier, distance);
169+
String texture = style.texturePath(session, styleIdentifier, distance);
170+
Vector2f iconSize = style.textureSize(session, styleIdentifier, distance);
171+
172+
if (texture == null) {
173+
GeyserImpl.getInstance().getLogger().warning("custom waypoint style for " + styleIdentifier + " returned null texture!");
174+
texture = "ui/locator_bar_dot_0";
175+
}
171176
if (iconSize.lengthSquared() < 0.0F) {
172177
iconSize = Vector2f.ZERO;
173178
}

core/src/main/java/org/geysermc/geyser/session/cache/waypoint/VanillaWaypoint.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
public record VanillaWaypoint(int nearDistance, int farDistance, List<String> textures) implements CustomWaypointStyle {
3939
// Default near and far distance: https://mcsrc.dev/1/26.1.2/net/minecraft/client/resources/WaypointStyle#L15-16
4040
// Default textures from bedrock's resourcepack (26.20)
41-
public static CustomWaypointStyle VANILLA_DEFAULT = new Builder(128, 332)
41+
public static final CustomWaypointStyle VANILLA_DEFAULT = new Builder(128, 332)
4242
.withTexture("ui/locator_bar_dot_0")
4343
.withTexture("ui/locator_bar_dot_1")
4444
.withTexture("ui/locator_bar_dot_2")
@@ -51,7 +51,7 @@ public record VanillaWaypoint(int nearDistance, int farDistance, List<String> te
5151

5252
// inspired by: https://mcsrc.dev/1/26.1.2/net/minecraft/client/resources/WaypointStyle#L45-59
5353
@Override
54-
public String getTexturePath(GeyserConnection connection, Identifier style, float distance) {
54+
public String texturePath(GeyserConnection connection, Identifier style, float distance) {
5555
if (distance < nearDistance) {
5656
return textures.getFirst();
5757
} else if (distance >= farDistance) {
@@ -67,7 +67,7 @@ public String getTexturePath(GeyserConnection connection, Identifier style, floa
6767
}
6868

6969
@Override
70-
public Vector2f getTextureSize(GeyserConnection connection, Identifier style, float distance) {
70+
public Vector2f textureSize(GeyserConnection connection, Identifier style, float distance) {
7171
if (distance < nearDistance) {
7272
return Vector2f.ONE;
7373
} else if (distance >= farDistance) {
@@ -79,7 +79,7 @@ public Vector2f getTextureSize(GeyserConnection connection, Identifier style, fl
7979
}
8080

8181
// inspired by: https://mcsrc.dev/1/26.1.2/net/minecraft/util/Mth#L523-525
82-
private static int lerpInt(final float alpha1, final int p0, final int p1) {
82+
private static int lerpInt(float alpha1, int p0, int p1) {
8383
return p0 + (int) Math.floor(alpha1 * (p1 - p0));
8484
}
8585

0 commit comments

Comments
 (0)