Make target Travel Anchor selection snap angle configurable and don't override empty selection server-side (#230)

Co-authored-by: Wilhelm Schuster <[email protected]>
Co-authored-by: Martin Robertz <[email protected]>
This commit is contained in:
authored and GitHub committed 2026-11-11 22:52:22 +01:00
1 parent f4dfa9e6cf
commit 749ea96c62
2 files changed
+19 -4

No files matched your search

@@ -145,6 +145,7 @@ public final class Config {
public static int travelAnchorCooldown = 0;
public static boolean travelAnchorSneak = true;
public static boolean travelAnchorSkipWarning = true;
public static double travelAnchorSnapAngle = 0.175;
public static int travelStaffMaxDistance = 128;
public static float travelStaffPowerPerBlockRF = 250;
@@ -1167,6 +1168,14 @@ public final class Config {
"Travel Anchors send a chat warning when skipping inaccessible anchors")
.getBoolean(travelAnchorSkipWarning);
travelAnchorSnapAngle = Math.toRadians(
config.get(
sectionAnchor.name,
"travelAnchorSnapAngle",
Math.round(Math.toDegrees(travelAnchorSnapAngle)),
"The maximum angle to snap to an anchor when selecting target")
.getDouble(Math.toDegrees(travelAnchorSnapAngle)));
travelStaffMaxDistance = config
.get(
sectionStaff.name,
@@ -741,7 +741,10 @@ public class TravelController {
for (Table.Cell<Double, Double, BlockCoord> cell : possibleDestinations.cellSet()) {
if (cell.getColumnKey() <= maxDistance) {
return Optional.of(cell.getValue());
// If the client hasn't selected a target, the server shouldn't try to force one,
// but checking if there is one just outside of range (below message) might still
// be useful.
return Optional.empty();
}
}
@@ -1066,9 +1069,12 @@ public class TravelController {
return;
}
// Find the nearest travel anchor within roughly 10 degrees.
Optional<BlockCoord> selectedBlock = findBlocksWithinAngle(player, candidates.keySet(), 0.175, Double.MAX_VALUE)
.values().stream().findFirst();
// Find the nearest travel anchor within the configured angle (default ~10 degrees).
Optional<BlockCoord> selectedBlock = findBlocksWithinAngle(
player,
candidates.keySet(),
Config.travelAnchorSnapAngle,
Double.MAX_VALUE).values().stream().findFirst();
selectedCoord = selectedBlock.orElse(null);
}