Skip to content

Commit

Permalink
Merge pull request #738 from UpFault/NucleusWaypoints
Browse files Browse the repository at this point in the history
Nucleus waypoints
  • Loading branch information
kevinthegreat1 authored Jun 30, 2024
2 parents b75bfdb + 712bb43 commit 690f047
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,15 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
newValue -> config.mining.crystalHollows.metalDetectorHelper = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.mining.crystalHollows.nucleusWaypoints"))
.description(OptionDescription.of(Text.translatable("skyblocker.config.mining.crystalHollows.nucleusWaypoints.@Tooltip")))
.binding(defaults.mining.crystalHollows.nucleusWaypoints,
() -> config.mining.crystalHollows.nucleusWaypoints,
newValue -> config.mining.crystalHollows.nucleusWaypoints = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.build())

//Crystal Hollows Map
.group(OptionGroup.createBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public static class DwarvenHud {
public static class CrystalHollows {
@SerialEntry
public boolean metalDetectorHelper = true;

@SerialEntry
public boolean nucleusWaypoints = false;
}

public static class CrystalsHud {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal;
import static net.minecraft.command.CommandSource.suggestMatching;

/**
* Manager for Crystal Hollows waypoints that handles {@link #update() location detection},
* {@link #extractLocationFromMessage(Text, Boolean) waypoints receiving}, {@link #shareWaypoint(String) sharing},
* {@link #registerWaypointLocationCommands(CommandDispatcher, CommandRegistryAccess) commands}, and
* {@link #render(WorldRenderContext) rendering}.
*/
public class CrystalsLocationsManager {
private static final Logger LOGGER = LogUtils.getLogger();
private static final MinecraftClient CLIENT = MinecraftClient.getInstance();
Expand All @@ -55,11 +61,15 @@ public class CrystalsLocationsManager {
protected static Map<String, CrystalsWaypoint> activeWaypoints = new HashMap<>();

public static void init() {
// Crystal Hollows Waypoints
Scheduler.INSTANCE.scheduleCyclic(CrystalsLocationsManager::update, 40);
WorldRenderEvents.AFTER_TRANSLUCENT.register(CrystalsLocationsManager::render);
ClientReceiveMessageEvents.GAME.register(CrystalsLocationsManager::extractLocationFromMessage);
ClientCommandRegistrationCallback.EVENT.register(CrystalsLocationsManager::registerWaypointLocationCommands);
ClientPlayConnectionEvents.JOIN.register((_handler, _sender, _client) -> reset());

// Nucleus Waypoints
WorldRenderEvents.AFTER_TRANSLUCENT.register(NucleusWaypoints::render);
}

private static void extractLocationFromMessage(Text message, Boolean overlay) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package de.hysky.skyblocker.skyblock.dwarven;

import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.utils.Utils;
import de.hysky.skyblocker.utils.render.RenderHelper;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.text.TextColor;
import net.minecraft.text.Style;
import net.minecraft.util.DyeColor;
import net.minecraft.util.math.BlockPos;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

public class NucleusWaypoints {
private static final Logger LOGGER = LoggerFactory.getLogger(NucleusWaypoints.class);

private static class Waypoint {
BlockPos position;
String name;
DyeColor color;

Waypoint(BlockPos position, String name, DyeColor color) {
this.position = position;
this.name = name;
this.color = color;
}
}

private static final List<Waypoint> WAYPOINTS = List.of(
new Waypoint(new BlockPos(551, 116, 551), "Precursor Remnants", DyeColor.LIGHT_BLUE),
new Waypoint(new BlockPos(551, 116, 475), "Mithril Deposits", DyeColor.LIME),
new Waypoint(new BlockPos(475, 116, 551), "Goblin Holdout", DyeColor.ORANGE),
new Waypoint(new BlockPos(475, 116, 475), "Jungle", DyeColor.PURPLE),
new Waypoint(new BlockPos(513, 106, 524), "Nucleus", DyeColor.RED)
);

public static void render(WorldRenderContext context) {
try {
boolean enabled = SkyblockerConfigManager.get().mining.crystalHollows.nucleusWaypoints;
boolean inCrystalHollows = Utils.isInCrystalHollows();

if (enabled && inCrystalHollows) {
for (Waypoint waypoint : WAYPOINTS) {

int rgb = waypoint.color.getFireworkColor();
TextColor textColor = TextColor.fromRgb(rgb);

MutableText text = Text.literal(waypoint.name).setStyle(Style.EMPTY.withColor(textColor));

RenderHelper.renderText(context, text, waypoint.position.toCenterPos().add(0, 5, 0), 8, true);
}
}
} catch (Exception e) {
LOGGER.error("[{}] Error occurred while rendering Nucleus waypoints. {}", LOGGER.getName(), e);
}
}
}
2 changes: 2 additions & 0 deletions src/main/resources/assets/skyblocker/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,8 @@
"skyblocker.config.mining.crystalHollows": "Crystal Hollows",
"skyblocker.config.mining.crystalHollows.metalDetectorHelper": "Metal Detector Helper",
"skyblocker.config.mining.crystalHollows.metalDetectorHelper.@Tooltip": "Helper for the metal detector puzzle in the Mines of Divan.",
"skyblocker.config.mining.crystalHollows.nucleusWaypoints": "Nucleus Waypoints",
"skyblocker.config.mining.crystalHollows.nucleusWaypoints.@Tooltip": "Show waypoints to the Nucleus in the Crystal Hollows.",

"skyblocker.config.mining.crystalsHud": "Crystal Hollows Map",
"skyblocker.config.mining.crystalsHud.enabled": "Enabled",
Expand Down

0 comments on commit 690f047

Please sign in to comment.