From 301ad263ac7c92a458bd841c1c44c571712f415c Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Thu, 9 May 2024 17:25:23 -0400 Subject: [PATCH] Add a way to show all ordered waypoints at once (#688) --- .../skyblock/waypoint/OrderedWaypoints.java | 56 ++++++++++++------- .../assets/skyblocker/lang/en_us.json | 1 + 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/OrderedWaypoints.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/OrderedWaypoints.java index b70bac4795..bbc9a65547 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/OrderedWaypoints.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/OrderedWaypoints.java @@ -72,6 +72,7 @@ public class OrderedWaypoints { private static final float[] LIGHT_GRAY = { 192 / 255f, 192 / 255f, 192 / 255f }; private static CompletableFuture loaded; + private static boolean showAll; public static void init() { ClientLifecycleEvents.CLIENT_STARTED.register(_client -> load()); @@ -114,6 +115,8 @@ private static void registerCommands(CommandDispatcher CommandSource.suggestMatching(WAYPOINTS.keySet(), builder)) .executes(context -> toggleGroup(context.getSource(), getString(context, "groupName"))))) + .then(literal("showAll") + .executes(context -> showAll(context.getSource()))) .then(literal("import") .then(literal("coleWeight") .then(argument("groupName", word()) @@ -215,39 +218,54 @@ private static int toggleGroup(FabricClientCommandSource source, String groupNam return Command.SINGLE_SUCCESS; } + private static int showAll(FabricClientCommandSource source) { + source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.waypoints.ordered.showAll"))); + showAll = !showAll; + + return Command.SINGLE_SUCCESS; + } + private static void render(WorldRenderContext wrc) { if ((Utils.isInCrystalHollows() || Utils.isInDwarvenMines()) && loaded.isDone() && SEMAPHORE.tryAcquire()) { for (OrderedWaypointGroup group : WAYPOINTS.values()) { if (group.enabled()) { List waypoints = group.waypoints(); if (waypoints.isEmpty()) continue; - ClientPlayerEntity player = MinecraftClient.getInstance().player; - int centreIndex = INDEX_STORE.computeIfAbsent(group.name(), name -> 0); - for (int i = 0; i < waypoints.size(); i++) { - OrderedWaypoint waypoint = waypoints.get(i); + if (!showAll) { + ClientPlayerEntity player = MinecraftClient.getInstance().player; + int centreIndex = INDEX_STORE.computeIfAbsent(group.name(), name -> 0); - if (waypoint.getPos().isWithinDistance(player.getPos(), RADIUS)) { - centreIndex = i; - INDEX_STORE.put(group.name(), i); + for (int i = 0; i < waypoints.size(); i++) { + OrderedWaypoint waypoint = waypoints.get(i); - break; + if (waypoint.getPos().isWithinDistance(player.getPos(), RADIUS)) { + centreIndex = i; + INDEX_STORE.put(group.name(), i); + + break; + } } - } - int previousIndex = (centreIndex - 1 + waypoints.size()) % waypoints.size(); - int currentIndex = (centreIndex + waypoints.size()) % waypoints.size(); - int nextIndex = (centreIndex + 1) % waypoints.size(); + int previousIndex = (centreIndex - 1 + waypoints.size()) % waypoints.size(); + int currentIndex = (centreIndex + waypoints.size()) % waypoints.size(); + int nextIndex = (centreIndex + 1) % waypoints.size(); - OrderedWaypoint previous = waypoints.get(previousIndex); - OrderedWaypoint current = waypoints.get(currentIndex); - OrderedWaypoint next = waypoints.get(nextIndex); + OrderedWaypoint previous = waypoints.get(previousIndex); + OrderedWaypoint current = waypoints.get(currentIndex); + OrderedWaypoint next = waypoints.get(nextIndex); - previous.render(wrc, RelativeIndex.PREVIOUS, previousIndex); - current.render(wrc, RelativeIndex.CURRENT, currentIndex); - next.render(wrc, RelativeIndex.NEXT, nextIndex); + previous.render(wrc, RelativeIndex.PREVIOUS, previousIndex); + current.render(wrc, RelativeIndex.CURRENT, currentIndex); + next.render(wrc, RelativeIndex.NEXT, nextIndex); - RenderHelper.renderLineFromCursor(wrc, Vec3d.ofCenter(next.getPos().up()), LIGHT_GRAY, 1f, 5f); + RenderHelper.renderLineFromCursor(wrc, Vec3d.ofCenter(next.getPos().up()), LIGHT_GRAY, 1f, 5f); + } else { + for (int i = 0; i < waypoints.size(); i++) { + //Render them as white by default + waypoints.get(i).render(wrc, RelativeIndex.CURRENT, i); + } + } } } diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index f56352e794..283175d045 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -773,6 +773,7 @@ "skyblocker.waypoints.ordered.remove.success": "Successfully removed the waypoint at %s from group %s.", "skyblocker.waypoints.ordered.removeAt.success": "Successfully removed the waypoint at index %d from group %s.", "skyblocker.waypoints.ordered.toggle.success": "Toggled the waypoint group %s.", + "skyblocker.waypoints.ordered.showAll": "Toggled showing all waypoints from enabled groups.", "skyblocker.waypoints.ordered.export.success": "Successfully copied your waypoints to your clipboard!", "skyblocker.waypoints.ordered.export.fail": "§cFailed to export your waypoints, check the latest.log for more information.", "skyblocker.waypoints.ordered.import.skyblocker.success": "Successfully imported waypoints from the Skyblocker Ordered Waypoints format!",