diff options
author | Kevin <92656833+kevinthegreat1@users.noreply.github.com> | 2024-06-30 14:35:28 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-30 14:35:28 +0800 |
commit | 690f047cc285ac8d4c96f889478906657882db60 (patch) | |
tree | a09641a8da5a7b1c3f1b1ac9ef6b020b5aa4905f /src/main/java/de/hysky | |
parent | b75bfdbeae151253d60c01c2c268dfa511997883 (diff) | |
parent | 712bb432351bb92facf0497ac7dc5412508ef268 (diff) | |
download | Skyblocker-690f047cc285ac8d4c96f889478906657882db60.tar.gz Skyblocker-690f047cc285ac8d4c96f889478906657882db60.tar.bz2 Skyblocker-690f047cc285ac8d4c96f889478906657882db60.zip |
Merge pull request #738 from UpFault/NucleusWaypoints
Nucleus waypoints
Diffstat (limited to 'src/main/java/de/hysky')
4 files changed, 83 insertions, 1 deletions
diff --git a/src/main/java/de/hysky/skyblocker/config/categories/MiningCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/MiningCategory.java index e77e9f4b..cb4399ef 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/MiningCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/MiningCategory.java @@ -95,7 +95,15 @@ public class MiningCategory { 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() diff --git a/src/main/java/de/hysky/skyblocker/config/configs/MiningConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/MiningConfig.java index a2a9bcf7..412a13ed 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/MiningConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/MiningConfig.java @@ -61,6 +61,9 @@ public class MiningConfig { public static class CrystalHollows { @SerialEntry public boolean metalDetectorHelper = true; + + @SerialEntry + public boolean nucleusWaypoints = false; } public static class CrystalsHud { 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 6f4c86a7..d709181f 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java @@ -42,6 +42,12 @@ import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.arg 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(); @@ -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) { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/NucleusWaypoints.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/NucleusWaypoints.java new file mode 100644 index 00000000..8046ed19 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/NucleusWaypoints.java @@ -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); + } + } +} |