From 749ea96c62f01883108f755b05fb4843e06e35c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Lindstr=C3=B6m?= Date: Wed, 11 Nov 2026 22:52:22 +0100 Subject: [PATCH] Make target Travel Anchor selection snap angle configurable and don't override empty selection server-side (#230) Co-authored-by: Wilhelm Schuster Co-authored-by: Martin Robertz --- .../java/crazypants/enderio/config/Config.java | 9 +++++++++ .../enderio/teleport/TravelController.java | 14 ++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/main/java/crazypants/enderio/config/Config.java b/src/main/java/crazypants/enderio/config/Config.java index fd0bbdf2..3f3d9213 100644 --- a/src/main/java/crazypants/enderio/config/Config.java +++ b/src/main/java/crazypants/enderio/config/Config.java @@ -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, diff --git a/src/main/java/crazypants/enderio/teleport/TravelController.java b/src/main/java/crazypants/enderio/teleport/TravelController.java index 45801334..40699793 100644 --- a/src/main/java/crazypants/enderio/teleport/TravelController.java +++ b/src/main/java/crazypants/enderio/teleport/TravelController.java @@ -741,7 +741,10 @@ public class TravelController { for (Table.Cell 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 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 selectedBlock = findBlocksWithinAngle( + player, + candidates.keySet(), + Config.travelAnchorSnapAngle, + Double.MAX_VALUE).values().stream().findFirst(); selectedCoord = selectedBlock.orElse(null); }