diff --git a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java index 8d0e0a1108..3c6f33a2be 100644 --- a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java +++ b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java @@ -18,10 +18,7 @@ import de.hysky.skyblocker.skyblock.dungeon.puzzle.waterboard.Waterboard; import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonManager; import de.hysky.skyblocker.skyblock.dungeon.secrets.SecretsTracker; -import de.hysky.skyblocker.skyblock.dwarven.CrystalsHud; -import de.hysky.skyblocker.skyblock.dwarven.CrystalsLocationsManager; -import de.hysky.skyblocker.skyblock.dwarven.DwarvenHud; -import de.hysky.skyblocker.skyblock.dwarven.MetalDetector; +import de.hysky.skyblocker.skyblock.dwarven.*; import de.hysky.skyblocker.skyblock.end.BeaconHighlighter; import de.hysky.skyblocker.skyblock.end.EnderNodes; import de.hysky.skyblocker.skyblock.end.TheEnd; @@ -125,6 +122,7 @@ public void onInitializeClient() { ItemCooldowns.init(); TabHud.init(); DwarvenHud.init(); + CommissionLabels.init(); CrystalsHud.init(); FarmingHud.init(); LowerSensitivity.init(); 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 8809ba44c2..8dc587fdc6 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/MiningCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/MiningCategory.java @@ -160,6 +160,56 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .build()) .build()) + + //commission waypoints + .group(OptionGroup.createBuilder() + .name(Text.translatable("skyblocker.config.mining.commissionWaypoints")) + .collapsed(false) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.mining.commissionWaypoints.mode")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.mining.commissionWaypoints.mode.@Tooltip[0]"), + Text.translatable("skyblocker.config.mining.commissionWaypoints.mode.@Tooltip[1]"), + Text.translatable("skyblocker.config.mining.commissionWaypoints.mode.@Tooltip[2]"), + Text.translatable("skyblocker.config.mining.commissionWaypoints.mode.@Tooltip[3]"), + Text.translatable("skyblocker.config.mining.commissionWaypoints.mode.@Tooltip[4]"))) + .binding(defaults.mining.commissionWaypoints.mode, + () -> config.mining.commissionWaypoints.mode, + newValue -> config.mining.commissionWaypoints.mode = newValue) + .controller(ConfigUtils::createEnumCyclingListController) + .build()) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.mining.commissionWaypoints.useColor")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.mining.commissionWaypoints.useColor.@Tooltip"))) + .binding(defaults.mining.commissionWaypoints.useColor, + () -> config.mining.commissionWaypoints.useColor, + newValue -> config.mining.commissionWaypoints.useColor = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.mining.commissionWaypoints.textScale")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.mining.commissionWaypoints.textScale.@Tooltip"))) + .binding(defaults.mining.commissionWaypoints.textScale, + () -> config.mining.commissionWaypoints.textScale, + newValue -> config.mining.commissionWaypoints.textScale = newValue) + .controller(FloatFieldControllerBuilder::create) + .build()) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.mining.commissionWaypoints.showBaseCamp")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.mining.commissionWaypoints.showBaseCamp.@Tooltip"))) + .binding(defaults.mining.commissionWaypoints.showBaseCamp, + () -> config.mining.commissionWaypoints.showBaseCamp, + newValue -> config.mining.commissionWaypoints.showBaseCamp = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.mining.commissionWaypoints.showEmissary")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.mining.commissionWaypoints.showEmissary.@Tooltip"))) + .binding(defaults.mining.commissionWaypoints.showEmissary, + () -> config.mining.commissionWaypoints.showEmissary, + newValue -> config.mining.commissionWaypoints.showEmissary = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) + .build()) .build(); } } 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 fe845e557e..65fd63ca6d 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/MiningConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/MiningConfig.java @@ -21,6 +21,9 @@ public class MiningConfig { @SerialEntry public CrystalsWaypoints crystalsWaypoints = new CrystalsWaypoints(); + @SerialEntry + public CommissionWaypoints commissionWaypoints = new CommissionWaypoints(); + public static class DwarvenMines { @SerialEntry public boolean solveFetchur = true; @@ -85,6 +88,37 @@ public static class CrystalsWaypoints { public boolean findInChat = true; } + public static class CommissionWaypoints { + @SerialEntry + public CommissionWaypointMode mode = CommissionWaypointMode.BOTH; + + @SerialEntry + public boolean useColor = true; + + @SerialEntry + public float textScale = 1; + + @SerialEntry + public boolean showBaseCamp = false; + + @SerialEntry + public boolean showEmissary = true; + } + + public enum CommissionWaypointMode { + OFF, DWARVEN, GLACITE, BOTH; + + @Override + public String toString() { + return switch (this) { + case OFF -> "Off"; + case DWARVEN -> "Dwarven"; + case GLACITE -> "Glacite"; + case BOTH -> "Both"; + }; + } + } + public enum DwarvenHudStyle { SIMPLE, FANCY, CLASSIC; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java new file mode 100644 index 0000000000..a14c71f769 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java @@ -0,0 +1,99 @@ +package de.hysky.skyblocker.skyblock.dwarven; + +import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.config.configs.MiningConfig; +import de.hysky.skyblocker.utils.Utils; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; +import net.minecraft.util.math.BlockPos; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; + +public class CommissionLabels { + + private static final Map DWARVEN_LOCATIONS = Arrays.stream(MiningLocationLabel.DwarvenCategory.values()).collect(Collectors.toMap(MiningLocationLabel.DwarvenCategory::toString, Function.identity())); + private static final List DWARVEN_EMISSARIES = Arrays.stream(MiningLocationLabel.DwarvenEmissaries.values()).toList(); + private static final Map GLACITE_LOCATIONS = Arrays.stream(MiningLocationLabel.GlaciteCategory.values()).collect(Collectors.toMap(MiningLocationLabel.GlaciteCategory::toString, Function.identity())); + + protected static List activeWaypoints = new ArrayList<>(); + + public static void init() { + WorldRenderEvents.AFTER_TRANSLUCENT.register(CommissionLabels::render); + } + + /** + * update the activeWaypoints when there is a change in commissions + * + * @param newCommissions the new commissions to get the waypoints from + * @param completed if there is a commission completed + */ + protected static void update(List newCommissions, boolean completed) { + MiningConfig.CommissionWaypointMode currentMode = SkyblockerConfigManager.get().mining.commissionWaypoints.mode; + if (currentMode == MiningConfig.CommissionWaypointMode.OFF) { + return; + } + activeWaypoints.clear(); + String location = Utils.getIslandArea().substring(2); + //find commission locations in glacite + if (location.equals("Dwarven Base Camp") || location.equals("Glacite Tunnels") || location.equals("Glacite Mineshafts") || location.equals("Glacite Lake")) { + if (currentMode != MiningConfig.CommissionWaypointMode.BOTH && currentMode != MiningConfig.CommissionWaypointMode.GLACITE) { + return; + } + + for (String commission : newCommissions) { + for (Map.Entry glaciteLocation : GLACITE_LOCATIONS.entrySet()) { + if (commission.contains(glaciteLocation.getKey())) { + MiningLocationLabel.GlaciteCategory category = glaciteLocation.getValue(); + for (BlockPos gemstoneLocation : category.getLocations()) { + activeWaypoints.add(new MiningLocationLabel(category, gemstoneLocation)); + } + } + } + } + //add base waypoint if enabled + if (SkyblockerConfigManager.get().mining.commissionWaypoints.showBaseCamp) { + activeWaypoints.add(new MiningLocationLabel(MiningLocationLabel.GlaciteCategory.CAMPFIRE, MiningLocationLabel.GlaciteCategory.CAMPFIRE.getLocations()[0])); + } + return; + } + //find commission locations in dwarven mines + if (currentMode != MiningConfig.CommissionWaypointMode.BOTH && currentMode != MiningConfig.CommissionWaypointMode.DWARVEN) { + return; + } + + for (String commission : newCommissions) { + for (Map.Entry dwarvenLocation : DWARVEN_LOCATIONS.entrySet()) { + if (commission.contains(dwarvenLocation.getKey())) { + MiningLocationLabel.DwarvenCategory category = dwarvenLocation.getValue(); + category.isTitanium = commission.contains("Titanium"); + activeWaypoints.add(new MiningLocationLabel(category, category.getLocation())); + } + } + } + //if there is a commission completed and enabled show emissary + if (SkyblockerConfigManager.get().mining.commissionWaypoints.showEmissary && completed) { + for (MiningLocationLabel.DwarvenEmissaries emissaries : DWARVEN_EMISSARIES) { + activeWaypoints.add(new MiningLocationLabel(emissaries, emissaries.getLocation())); + } + } + } + + /** + * render all the active waypoints + * + * @param context render context + */ + private static void render(WorldRenderContext context) { + if (!Utils.isInDwarvenMines() || SkyblockerConfigManager.get().mining.commissionWaypoints.mode == MiningConfig.CommissionWaypointMode.OFF) { + return; + } + for (MiningLocationLabel MiningLocationLabel : activeWaypoints) { + MiningLocationLabel.render(context); + } + } +} diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java index a74dbc5e7a..6343048981 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java @@ -21,7 +21,7 @@ public class CrystalsHud { private static final MinecraftClient CLIENT = MinecraftClient.getInstance(); - protected static final Identifier MAP_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/crystals_map.png"); + protected static final Identifier MAP_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/crystals_map.png"); private static final Identifier MAP_ICON = new Identifier("textures/map/decorations/player.png"); private static final List SMALL_LOCATIONS = List.of("Fairy Grotto", "King Yolkar", "Corleone", "Odawa", "Key Guardian"); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsWaypoint.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsWaypoint.java index 053f353606..dc40f82ca4 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsWaypoint.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsWaypoint.java @@ -42,7 +42,7 @@ static Predicate getRangePredicate(Entity entity) { @Override public boolean shouldRender() { - return super.shouldRender() ; + return super.shouldRender(); } @Override @@ -84,7 +84,7 @@ enum Category { private final String name; private final float[] colorComponents; - Category(String name,Color color) { + Category(String name, Color color) { this.name = name; this.color = color; this.colorComponents = color.getColorComponents(null); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHud.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHud.java index 242c513a71..2cf0ea9de3 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHud.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHud.java @@ -168,9 +168,9 @@ public static void update() { || !Utils.isInCrystalHollows() && !Utils.isInDwarvenMines()) { return; } - + List oldCommissionNames = commissionList.stream().map(Commission::commission).toList(); + boolean oldCompleted = commissionList.stream().anyMatch(commission -> commission.progression.equals("DONE")); commissionList = new ArrayList<>(); - for (PlayerListEntry playerListEntry : CLIENT.getNetworkHandler().getPlayerList().stream().sorted(PlayerListHudAccessor.getOrdering()).toList()) { if (playerListEntry.getDisplayName() == null) { continue; @@ -197,6 +197,11 @@ public static void update() { glacitePowder = glaciteMatcher.group(0).split(": ")[1]; } } + List newCommissionNames = commissionList.stream().map(Commission::commission).toList(); + boolean newCompleted = commissionList.stream().anyMatch(commission -> commission.progression.equals("DONE")); + if (!oldCommissionNames.equals(newCommissionNames) || oldCompleted != newCompleted) { + CommissionLabels.update(newCommissionNames, newCompleted); + } } // steamroller tactics to get visibility from outside classes (HudCommsWidget) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java new file mode 100644 index 0000000000..1f373b5572 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java @@ -0,0 +1,157 @@ +package de.hysky.skyblocker.skyblock.dwarven; + +import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.utils.render.RenderHelper; +import de.hysky.skyblocker.utils.render.Renderable; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; +import net.minecraft.client.MinecraftClient; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; + +public record MiningLocationLabel(Category category, Vec3d centerPos) implements Renderable { + public MiningLocationLabel(Category category, BlockPos pos) { + this(category, pos.toCenterPos()); + } + + private Text getName() { + if (SkyblockerConfigManager.get().mining.commissionWaypoints.useColor) { + return Text.literal(category.getName()).withColor(category.getColor()); + } + return Text.literal(category.getName()); + } + + /** + * Renders the name and distance to the label scaled so can be seen at a distance + * @param context render context + */ + @Override + public void render(WorldRenderContext context) { + Vec3d posUp = centerPos.add(0, 1, 0); + double distance = context.camera().getPos().distanceTo(centerPos); + float scale = (float) (SkyblockerConfigManager.get().mining.commissionWaypoints.textScale * (distance / 10)); + RenderHelper.renderText(context, getName(), posUp, scale, true); + RenderHelper.renderText(context, Text.literal(Math.round(distance) + "m").formatted(Formatting.YELLOW), posUp, scale, MinecraftClient.getInstance().textRenderer.fontHeight + 1, true); + } + + public interface Category { + String getName(); + + int getColor(); //all the color codes are the color of the block the waypoint is for + } + + enum DwarvenCategory implements Category { + LAVA_SPRINGS("Lava Springs", new BlockPos(60, 197, -15)), + CLIFFSIDE_VEINS("Cliffside Veins", new BlockPos(40, 128, 40)), + RAMPARTS_QUARRY("Rampart's Quarry", new BlockPos(-100, 150, -20)), + UPPER_MINES("Upper Mines", new BlockPos(-130, 174, -50)), + ROYAL_MINES("Royal Mines", new BlockPos(130, 154, 30)), + GLACITE_WALKER("Glacite Walker", new BlockPos(0, 128, 150)); + + + boolean isTitanium; + private final String name; + private final BlockPos location; + + DwarvenCategory(String name, BlockPos location) { + this.name = name; + this.location = location; + } + + public BlockPos getLocation() { + return location; + } + + @Override + public String toString() { + return name; + } + + @Override + public String getName() { + return name; + } + + @Override + public int getColor() { + if (isTitanium) { + return 0xd8d6d8; + } + return 0x45bde0; + } + } + + enum DwarvenEmissaries implements Category { + LAVA_SPRINGS(new BlockPos(58, 198, -8)), + CLIFFSIDE_VEINS(new BlockPos(42, 134, 22)), + RAMPARTS_QUARRY(new BlockPos(-72, 153, -10)), + UPPER_MINES(new BlockPos(-132, 174, -50)), + ROYAL_MINES(new BlockPos(171, 150, 31)), + DWARVEN_VILLAGE(new BlockPos(-37, 200, -92)), + DWARVEN_MINES(new BlockPos(89, 198, -92)); + + private final BlockPos location; + + DwarvenEmissaries(BlockPos location) { + + this.location = location; + } + + public BlockPos getLocation() { + return location; + } + + @Override + public String toString() { + return "Emissary"; + } + + @Override + public String getName() { + return "Emissary"; + } + + @Override + public int getColor() { + return 0xffffff; + } + } + + enum GlaciteCategory implements Category { + AQUAMARINE("Aquamarine", 0x334cb1, new BlockPos[]{new BlockPos(-1, 139, 437), new BlockPos(90, 151, 229), new BlockPos(56, 151, 400), new BlockPos(51, 117, 303)}), + ONYX("Onyx", 0x191919, new BlockPos[]{new BlockPos(79, 119, 411), new BlockPos(-14, 132, 386), new BlockPos(18, 136, 370), new BlockPos(16, 138, 411), new BlockPos(-68, 130, 408)}), + PERIDOT("Peridot", 0x667f33, new BlockPos[]{new BlockPos(-61, 147, 302), new BlockPos(91, 122, 397), new BlockPos(-73, 122, 458), new BlockPos(-77, 120, 282)}), + CITRINE("Citrine", 0x664c33, new BlockPos[]{new BlockPos(-104, 144, 244), new BlockPos(39, 119, 386), new BlockPos(-57, 144, 421), new BlockPos(-47, 126, 418)}), + CAMPFIRE("Base Camp", 0x983333, new BlockPos[]{new BlockPos(-7, 126, 229)}); + + private final String name; + private final int color; + private final BlockPos[] location; + + GlaciteCategory(String name, int color, BlockPos[] location) { + this.name = name; + this.color = color; + this.location = location; + } + + public BlockPos[] getLocations() { + return location; + } + + @Override + public String toString() { + return name; + } + + @Override + public String getName() { + return name; + } + + @Override + public int getColor() { + return color; + } + } +} diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 8f7bb2da29..6d2433c07f 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -377,6 +377,22 @@ "skyblocker.config.mining": "Mining", + "skyblocker.config.mining.commissionWaypoints": "Commission Waypoints", + "skyblocker.config.mining.commissionWaypoints.mode": "Enable Commission Waypoints", + "skyblocker.config.mining.commissionWaypoints.mode.@Tooltip[0]": "Off: Do not show Commission waypoint.", + "skyblocker.config.mining.commissionWaypoints.mode.@Tooltip[1]": "\nDwarven: Show waypoints only in dwarven mines.", + "skyblocker.config.mining.commissionWaypoints.mode.@Tooltip[2]": "\nGlacite: Show waypoints only in glacite tunnles.", + "skyblocker.config.mining.commissionWaypoints.mode.@Tooltip[3]": "\nBoth: Show waypoints in dwarven mines and glacite tunnels.", + "skyblocker.config.mining.commissionWaypoints.mode.@Tooltip[4]": "\n(takes effect when commissions updated)", + "skyblocker.config.mining.commissionWaypoints.useColor": "Colored Waypoints", + "skyblocker.config.mining.commissionWaypoints.useColor.@Tooltip": "Color the waypoint text to match the block it's for.", + "skyblocker.config.mining.commissionWaypoints.textScale": "Text Scale", + "skyblocker.config.mining.commissionWaypoints.textScale.@Tooltip": "Scale the size of the commission labels.", + "skyblocker.config.mining.commissionWaypoints.showBaseCamp": "Show Basecamp Waypoint", + "skyblocker.config.mining.commissionWaypoints.showBaseCamp.@Tooltip": "Show waypoint for basecamp when in glacite tunnels (takes effect when commissions updated).", + "skyblocker.config.mining.commissionWaypoints.showEmissary": "Show Emissary", + "skyblocker.config.mining.commissionWaypoints.showEmissary.@Tooltip": "When a commission in the dwarven mines is finished show emissary locations (takes effect when commissions updated).", + "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.",