aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java
diff options
context:
space:
mode:
authorKevin <92656833+kevinthegreat1@users.noreply.github.com>2024-03-21 16:12:32 -0400
committerGitHub <noreply@github.com>2024-03-21 16:12:32 -0400
commit36cf628191947bec44f565a859c9ee9035383b6b (patch)
treec5cd26932b7ab29c55fd303956f9f9966924b18b /src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java
parentc5d059dd5918e801ce2225e75b71a2e33ea57e1c (diff)
downloadSkyblocker-36cf628191947bec44f565a859c9ee9035383b6b.tar.gz
Skyblocker-36cf628191947bec44f565a859c9ee9035383b6b.tar.bz2
Skyblocker-36cf628191947bec44f565a859c9ee9035383b6b.zip
Update Dwarven, Crystals, and Backpack Preview (#601)
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java')
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java
index 0a4e4518..f43574ab 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java
@@ -9,6 +9,7 @@ import de.hysky.skyblocker.SkyblockerMod;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.utils.Constants;
import de.hysky.skyblocker.utils.Utils;
+import de.hysky.skyblocker.utils.scheduler.Scheduler;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents;
@@ -47,12 +48,13 @@ public class CrystalsLocationsManager {
/**
* A look-up table to convert between location names and waypoint in the {@link CrystalsWaypoint.Category} values.
*/
- protected static final Map<String, CrystalsWaypoint.Category> WAYPOINT_LOCATIONS = Arrays.stream(CrystalsWaypoint.Category.values()).collect(Collectors.toMap(CrystalsWaypoint.Category::toString, Function.identity()));
+ private static final Map<String, CrystalsWaypoint.Category> WAYPOINT_LOCATIONS = Arrays.stream(CrystalsWaypoint.Category.values()).collect(Collectors.toMap(CrystalsWaypoint.Category::toString, Function.identity()));
private static final Pattern TEXT_CWORDS_PATTERN = Pattern.compile("([0-9][0-9][0-9]) ([0-9][0-9][0-9]?) ([0-9][0-9][0-9])");
protected static Map<String, CrystalsWaypoint> activeWaypoints = new HashMap<>();
public static void init() {
+ Scheduler.INSTANCE.scheduleCyclic(CrystalsLocationsManager::update, 40);
WorldRenderEvents.AFTER_TRANSLUCENT.register(CrystalsLocationsManager::render);
ClientReceiveMessageEvents.GAME.register(CrystalsLocationsManager::extractLocationFromMessage);
ClientCommandRegistrationCallback.EVENT.register(CrystalsLocationsManager::registerWaypointLocationCommands);
@@ -83,7 +85,7 @@ public class CrystalsLocationsManager {
for (String waypointLocation : WAYPOINT_LOCATIONS.keySet()) {
if (value.toLowerCase().contains(waypointLocation.toLowerCase())) { //todo be more lenient
//all data found to create waypoint
- addCustomWaypoint(Text.of(waypointLocation),blockPos);
+ addCustomWaypoint(waypointLocation, blockPos);
return;
}
}
@@ -144,7 +146,7 @@ public class CrystalsLocationsManager {
BlockPos blockPos = location.toAbsoluteBlockPos(new ServerCommandSource(null, source.getPosition(), source.getRotation(), null, 0, null, null, null, null));
if (WAYPOINT_LOCATIONS.containsKey(place)) {
- addCustomWaypoint(Text.of(place), blockPos);
+ addCustomWaypoint(place, blockPos);
//tell the client it has done this
if (CLIENT.player == null || CLIENT.getNetworkHandler() == null) {
@@ -158,10 +160,10 @@ public class CrystalsLocationsManager {
}
- private static void addCustomWaypoint( Text waypointName, BlockPos pos) {
- CrystalsWaypoint.Category category = WAYPOINT_LOCATIONS.get(waypointName.getString());
- CrystalsWaypoint waypoint = new CrystalsWaypoint(category, waypointName, pos);
- activeWaypoints.put(waypointName.getString(), waypoint);
+ private static void addCustomWaypoint(String waypointName, BlockPos pos) {
+ CrystalsWaypoint.Category category = WAYPOINT_LOCATIONS.get(waypointName);
+ CrystalsWaypoint waypoint = new CrystalsWaypoint(category, Text.literal(waypointName), pos);
+ activeWaypoints.put(waypointName, waypoint);
}
public static void render(WorldRenderContext context) {
@@ -184,12 +186,12 @@ public class CrystalsLocationsManager {
}
//get if the player is in the crystals
- String location = Utils.getIslandArea().replace("⏣ ", "");
+ String location = Utils.getIslandArea().substring(2);
//if new location and needs waypoint add waypoint
if (!location.equals("Unknown") && WAYPOINT_LOCATIONS.containsKey(location) && !activeWaypoints.containsKey(location)) {
//add waypoint at player location
BlockPos playerLocation = CLIENT.player.getBlockPos();
- addCustomWaypoint(Text.of(location), playerLocation);
+ addCustomWaypoint(location, playerLocation);
}
}
}