From a01ebfa0b30c6d7c8bd31057d31062106bc52e39 Mon Sep 17 00:00:00 2001 From: olim Date: Sun, 5 May 2024 12:02:06 +0100 Subject: [PATCH 01/14] add waypoints for current commision still need to get locations in the mines --- .../de/hysky/skyblocker/SkyblockerMod.java | 6 +- .../skyblock/dwarven/CommissionWaypoints.java | 69 ++++++ .../skyblock/dwarven/CrystalsHud.java | 4 +- .../dwarven/CrystalsLocationsManager.java | 10 +- .../skyblock/dwarven/DwarvenHud.java | 6 +- .../skyblock/dwarven/MetalDetector.java | 2 +- .../skyblock/dwarven/MiningWaypoints.java | 201 ++++++++++++++++++ 7 files changed, 285 insertions(+), 13 deletions(-) create mode 100644 src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionWaypoints.java create mode 100644 src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningWaypoints.java diff --git a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java index 3336cefb75..7d7acfbf2d 100644 --- a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java +++ b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java @@ -17,10 +17,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; @@ -123,6 +120,7 @@ public void onInitializeClient() { ItemCooldowns.init(); TabHud.init(); DwarvenHud.init(); + CommissionWaypoints.init(); CrystalsHud.init(); FarmingHud.init(); LowerSensitivity.init(); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionWaypoints.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionWaypoints.java new file mode 100644 index 0000000000..a73e89b9ae --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionWaypoints.java @@ -0,0 +1,69 @@ +package de.hysky.skyblocker.skyblock.dwarven; + +import de.hysky.skyblocker.utils.Utils; +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; +import net.minecraft.text.Text; +import net.minecraft.util.math.BlockPos; + +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +public class CommissionWaypoints { + + private static final Map DWARVEN_LOCATIONS = Arrays.stream(MiningWaypoints.dwarvenCategory.values()).collect(Collectors.toMap(MiningWaypoints.dwarvenCategory::toString, Function.identity())); + private static final Map GLACITE_LOCATIONS = Arrays.stream(MiningWaypoints.glaciteCategory.values()).collect(Collectors.toMap(MiningWaypoints.glaciteCategory::toString, Function.identity())); + + + protected static List activeWaypoints = new ArrayList<>(); + + public static void init() { + WorldRenderEvents.AFTER_TRANSLUCENT.register(CommissionWaypoints::render); + ClientPlayConnectionEvents.JOIN.register((_handler, _sender, _client) -> reset()); + } + + protected static void update(List newCommissions) { + activeWaypoints.clear(); + String location = Utils.getIslandArea().substring(2); + //find commission locations in glacite + if (location.equals("Dwarven Base Camp") || location.equals("Glacite Tunnels")) { + for (DwarvenHud.Commission commission : newCommissions) { + String commissionName = commission.commission(); + for (Map.Entry glaciteLocation : GLACITE_LOCATIONS.entrySet()) { + if (commissionName.contains(glaciteLocation.getKey())) { + MiningWaypoints.glaciteCategory category = glaciteLocation.getValue(); + for (BlockPos gemstoneLocation : category.getLocations()) { + activeWaypoints.add(new MiningWaypoints(category, Text.of(category.getName()), gemstoneLocation)); + } + } + } + } + return; + } + //find commission locations in dwarven mines + for (DwarvenHud.Commission commission : newCommissions) { + String commissionName = commission.commission(); + for (Map.Entry dwarvenLocation : DWARVEN_LOCATIONS.entrySet()) { + if (commissionName.contains(dwarvenLocation.getKey())) { + MiningWaypoints.dwarvenCategory category = dwarvenLocation.getValue(); + activeWaypoints.add(new MiningWaypoints(category, Text.of(category.getName()), category.getLocation())); + } + } + } + } + + private static void render(WorldRenderContext context) { + for (MiningWaypoints miningWaypoints : activeWaypoints) { + if (miningWaypoints.shouldRender()) { + miningWaypoints.render(context); + } + } + + } + + private static void reset() { + activeWaypoints.clear(); + } +} 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..34667d12e2 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java @@ -75,8 +75,8 @@ private static void render(DrawContext context, float tickDelta, int hudX, int h if (SkyblockerConfigManager.get().mining.crystalsHud.showLocations) { Map ActiveWaypoints = CrystalsLocationsManager.activeWaypoints; - for (CrystalsWaypoint waypoint : ActiveWaypoints.values()) { - Color waypointColor = waypoint.category.color; + for (MiningWaypoints waypoint : ActiveWaypoints.values()) { + Color waypointColor = waypoint.category.getColor(); Vector2ic renderPos = transformLocation(waypoint.pos.getX(), waypoint.pos.getZ()); int locationSize = SkyblockerConfigManager.get().mining.crystalsHud.locationSize; 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 6f4c86a75e..d9889b37ab 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java @@ -47,12 +47,12 @@ public class CrystalsLocationsManager { private static final MinecraftClient CLIENT = MinecraftClient.getInstance(); /** - * A look-up table to convert between location names and waypoint in the {@link CrystalsWaypoint.Category} values. + * A look-up table to convert between location names and waypoint in the {@link MiningWaypoints.crystalCategory} values. */ - private static final Map WAYPOINT_LOCATIONS = Arrays.stream(CrystalsWaypoint.Category.values()).collect(Collectors.toMap(CrystalsWaypoint.Category::toString, Function.identity())); + private static final Map WAYPOINT_LOCATIONS = Arrays.stream(MiningWaypoints.crystalCategory.values()).collect(Collectors.toMap(MiningWaypoints.crystalCategory::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 activeWaypoints = new HashMap<>(); + protected static Map activeWaypoints = new HashMap<>(); public static void init() { Scheduler.INSTANCE.scheduleCyclic(CrystalsLocationsManager::update, 40); @@ -185,8 +185,8 @@ public static int shareWaypoint(String place) { private static void addCustomWaypoint(String waypointName, BlockPos pos) { - CrystalsWaypoint.Category category = WAYPOINT_LOCATIONS.get(waypointName); - CrystalsWaypoint waypoint = new CrystalsWaypoint(category, Text.literal(waypointName), pos); + MiningWaypoints.crystalCategory category = WAYPOINT_LOCATIONS.get(waypointName); + MiningWaypoints waypoint = new MiningWaypoints(category, Text.literal(waypointName), pos); activeWaypoints.put(waypointName, waypoint); } 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..44e4535fa4 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHud.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHud.java @@ -25,7 +25,7 @@ public class DwarvenHud { private static final MinecraftClient CLIENT = MinecraftClient.getInstance(); - private static List commissionList = new ArrayList<>(); + protected static List commissionList = new ArrayList<>(); public static String mithrilPowder = "0"; public static String gemStonePowder = "0"; @@ -169,6 +169,7 @@ public static void update() { return; } + List oldCommissionList = commissionList; commissionList = new ArrayList<>(); for (PlayerListEntry playerListEntry : CLIENT.getNetworkHandler().getPlayerList().stream().sorted(PlayerListHudAccessor.getOrdering()).toList()) { @@ -197,6 +198,9 @@ public static void update() { glacitePowder = glaciteMatcher.group(0).split(": ")[1]; } } + if (!oldCommissionList.equals(commissionList)) { + CommissionWaypoints.update(commissionList); + } } // steamroller tactics to get visibility from outside classes (HudCommsWidget) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MetalDetector.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MetalDetector.java index dd97e5d1ff..1d7a4db8b4 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MetalDetector.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MetalDetector.java @@ -249,7 +249,7 @@ private static void render(WorldRenderContext context) { } for (Vec3i block : possibleBlocks) { - CrystalsWaypoint waypoint = new CrystalsWaypoint(CrystalsWaypoint.Category.CORLEONE, Text.translatable("skyblocker.dwarvenMines.metalDetectorHelper.possible"), new BlockPos(block.getX(), block.getY(), block.getZ())); + MiningWaypoints waypoint = new MiningWaypoints(MiningWaypoints.crystalCategory.CORLEONE, Text.translatable("skyblocker.dwarvenMines.metalDetectorHelper.possible"), new BlockPos(block.getX(), block.getY(), block.getZ())); waypoint.render(context); } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningWaypoints.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningWaypoints.java new file mode 100644 index 0000000000..7b09e51d0d --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningWaypoints.java @@ -0,0 +1,201 @@ +package de.hysky.skyblocker.skyblock.dwarven; + +import de.hysky.skyblocker.config.SkyblockerConfig; +import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.utils.render.RenderHelper; +import de.hysky.skyblocker.utils.waypoint.Waypoint; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; +import net.minecraft.client.MinecraftClient; +import net.minecraft.text.Text; +import net.minecraft.util.DyeColor; +import net.minecraft.util.Formatting; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; + +import java.util.List; +import java.awt.*; +import java.util.function.Supplier; + +public class MiningWaypoints extends Waypoint { + private static final Supplier CONFIG = () -> SkyblockerConfigManager.get().general.waypoints; + private static final Supplier TYPE_SUPPLIER = () -> CONFIG.get().waypointType; + final Text name; + final Category category; + private final Vec3d centerPos; + + MiningWaypoints(Category category, Text name, BlockPos pos) { + super(pos, TYPE_SUPPLIER, category.getColorComponents()); + this.name = name; + this.category = category; + this.centerPos = pos.toCenterPos(); + } + + @Override + public boolean shouldRender() { + return super.shouldRender(); + } + + @Override + public boolean equals(Object obj) { + return super.equals(obj) || obj instanceof MiningWaypoints other && name.equals(other.name) && pos.equals(other.pos); + } + + /** + * Renders the secret waypoint, including a waypoint through {@link Waypoint#render(WorldRenderContext)}, the name, and the distance from the player. + */ + @Override + public void render(WorldRenderContext context) { + super.render(context); + + Vec3d posUp = centerPos.add(0, 1, 0); + RenderHelper.renderText(context, name, posUp, true); + double distance = context.camera().getPos().distanceTo(centerPos); + RenderHelper.renderText(context, Text.literal(Math.round(distance) + "m").formatted(Formatting.YELLOW), posUp, 1, MinecraftClient.getInstance().textRenderer.fontHeight + 1, true); + + } + + interface Category { + Color getColor(); + + String getName(); + + float[] getColorComponents(); + + } + + /** + * enum for the different waypoints used int the crystals hud each with a {@link crystalCategory#name} and associated {@link crystalCategory#color} + */ + + enum crystalCategory implements Category { + JUNGLE_TEMPLE("Jungle Temple", new Color(DyeColor.PURPLE.getSignColor())), + MINES_OF_DIVAN("Mines of Divan", Color.GREEN), + GOBLIN_QUEENS_DEN("Goblin Queen's Den", new Color(DyeColor.ORANGE.getSignColor())), + LOST_PRECURSOR_CITY("Lost Precursor City", Color.CYAN), + KHAZAD_DUM("Khazad-dûm", Color.YELLOW), + FAIRY_GROTTO("Fairy Grotto", Color.PINK), + DRAGONS_LAIR("Dragon's Lair", Color.BLACK), + CORLEONE("Corleone", Color.WHITE), + KING_YOLKAR("King Yolkar", Color.RED), + ODAWA("Odawa", Color.MAGENTA), + KEY_GUARDIAN("Key Guardian", Color.LIGHT_GRAY); + + public final Color color; + private final String name; + private final float[] colorComponents; + + crystalCategory(String name, Color color) { + this.name = name; + this.color = color; + this.colorComponents = color.getColorComponents(null); + } + + @Override + public String toString() { + return name; + } + + @Override + public Color getColor() { + return color; + } + + @Override + public String getName() { + return name; + } + + @Override + public float[] getColorComponents() { + return colorComponents; + } + } + + + enum dwarvenCategory implements Category { + SOMTHING("s", Color.BLACK, new BlockPos(0, 0, 0)); + + public final Color color; + private final String name; + private final float[] colorComponents; + private final BlockPos location; + + dwarvenCategory(String name, Color color, BlockPos location) { + this.name = name; + this.color = color; + this.colorComponents = color.getColorComponents(null); + this.location = location; + + } + + public BlockPos getLocation() { + return location; + } + + @Override + public String toString() { + return name; + } + + @Override + public Color getColor() { + return color; + } + + @Override + public String getName() { + return name; + } + + @Override + public float[] getColorComponents() { + return colorComponents; + } + + } + + enum glaciteCategory implements Category { + AQUAMARINE("Aquamarine", Color.CYAN, new BlockPos[]{new BlockPos(-1, 139, 437), new BlockPos(90, 151, 229), new BlockPos(56, 151, 400), new BlockPos(51, 117, 303)}), + ONYX("Onyx", Color.BLACK, 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", Color.GREEN, new BlockPos[]{new BlockPos(-61, 147, 302), new BlockPos(91, 122, 397),new BlockPos(-73, 122, 458), new BlockPos(-77, 120, 282)}), + CITRINE("Citrine", Color.YELLOW, new BlockPos[]{new BlockPos(-104, 144, 244), new BlockPos(39, 119, 386), new BlockPos(-57, 144, 421), new BlockPos(-47, 126, 418) }); + + public final Color color; + private final String name; + private final float[] colorComponents; + private final BlockPos[] location; + + glaciteCategory(String name, Color color, BlockPos[] location) { + this.name = name; + this.color = color; + this.colorComponents = color.getColorComponents(null); + this.location = location; + + } + + public BlockPos[] getLocations() { + return location; + } + + @Override + public String toString() { + return name; + } + + @Override + public Color getColor() { + return color; + } + + @Override + public String getName() { + return name; + } + + @Override + public float[] getColorComponents() { + return colorComponents; + } + + } +} From b47ebd85b5ecb2c9b2adbbcd80f750ca15fd433e Mon Sep 17 00:00:00 2001 From: olim Date: Mon, 6 May 2024 11:14:56 +0100 Subject: [PATCH 02/14] rework to use labels instead of trying to use crystal waypoints --- .../de/hysky/skyblocker/SkyblockerMod.java | 2 +- .../skyblock/dwarven/CommissionLabels.java | 69 ++++++++++++ .../skyblock/dwarven/CommissionWaypoints.java | 69 ------------ .../skyblock/dwarven/CrystalsHud.java | 8 +- .../dwarven/CrystalsLocationsManager.java | 12 +- .../skyblock/dwarven/DwarvenHud.java | 7 +- ...ypoints.java => MiningLocationLabels.java} | 105 +++--------------- 7 files changed, 98 insertions(+), 174 deletions(-) create mode 100644 src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java delete mode 100644 src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionWaypoints.java rename src/main/java/de/hysky/skyblocker/skyblock/dwarven/{MiningWaypoints.java => MiningLocationLabels.java} (50%) diff --git a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java index 7d7acfbf2d..f3bb8d9dfd 100644 --- a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java +++ b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java @@ -120,7 +120,7 @@ public void onInitializeClient() { ItemCooldowns.init(); TabHud.init(); DwarvenHud.init(); - CommissionWaypoints.init(); + CommissionLabels.init(); CrystalsHud.init(); FarmingHud.init(); LowerSensitivity.init(); 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..f3e8e935cc --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java @@ -0,0 +1,69 @@ +package de.hysky.skyblocker.skyblock.dwarven; + +import de.hysky.skyblocker.utils.Utils; +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; +import net.minecraft.text.Text; +import net.minecraft.util.math.BlockPos; + +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +public class CommissionLabels { + + private static final Map DWARVEN_LOCATIONS = Arrays.stream(MiningLocationLabels.dwarvenCategory.values()).collect(Collectors.toMap(MiningLocationLabels.dwarvenCategory::toString, Function.identity())); + private static final Map GLACITE_LOCATIONS = Arrays.stream(MiningLocationLabels.glaciteCategory.values()).collect(Collectors.toMap(MiningLocationLabels.glaciteCategory::toString, Function.identity())); + + + protected static List activeWaypoints = new ArrayList<>(); + + public static void init() { + WorldRenderEvents.AFTER_TRANSLUCENT.register(CommissionLabels::render); + ClientPlayConnectionEvents.JOIN.register((_handler, _sender, _client) -> reset()); + } + + protected static void update(List newCommissions) { + System.out.println(newCommissions); + activeWaypoints.clear(); + String location = Utils.getIslandArea().substring(2); + //find commission locations in glacite + if (location.equals("Dwarven Base Camp") || location.equals("Glacite Tunnels")) { + for (String commission : newCommissions) { + for (Map.Entry glaciteLocation : GLACITE_LOCATIONS.entrySet()) { + if (commission.contains(glaciteLocation.getKey())) { + MiningLocationLabels.glaciteCategory category = glaciteLocation.getValue(); + for (BlockPos gemstoneLocation : category.getLocations()) { + activeWaypoints.add(new MiningLocationLabels(category, Text.of(category.getName()), gemstoneLocation)); + } + } + } + } + return; + } + //find commission locations in dwarven mines + for (String commission : newCommissions) { + for (Map.Entry dwarvenLocation : DWARVEN_LOCATIONS.entrySet()) { + if (commission.contains(dwarvenLocation.getKey())) { + MiningLocationLabels.dwarvenCategory category = dwarvenLocation.getValue(); + activeWaypoints.add(new MiningLocationLabels(category, Text.of(category.getName()), category.getLocation())); + } + } + } + } + + private static void render(WorldRenderContext context) { + if (!Utils.isInDwarvenMines()) { + return; + } + for (MiningLocationLabels MiningLocationLabels : activeWaypoints) { + MiningLocationLabels.render(context); + } + + } + + private static void reset() { + + } +} diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionWaypoints.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionWaypoints.java deleted file mode 100644 index a73e89b9ae..0000000000 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionWaypoints.java +++ /dev/null @@ -1,69 +0,0 @@ -package de.hysky.skyblocker.skyblock.dwarven; - -import de.hysky.skyblocker.utils.Utils; -import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; -import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; -import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; -import net.minecraft.text.Text; -import net.minecraft.util.math.BlockPos; - -import java.util.*; -import java.util.function.Function; -import java.util.stream.Collectors; - -public class CommissionWaypoints { - - private static final Map DWARVEN_LOCATIONS = Arrays.stream(MiningWaypoints.dwarvenCategory.values()).collect(Collectors.toMap(MiningWaypoints.dwarvenCategory::toString, Function.identity())); - private static final Map GLACITE_LOCATIONS = Arrays.stream(MiningWaypoints.glaciteCategory.values()).collect(Collectors.toMap(MiningWaypoints.glaciteCategory::toString, Function.identity())); - - - protected static List activeWaypoints = new ArrayList<>(); - - public static void init() { - WorldRenderEvents.AFTER_TRANSLUCENT.register(CommissionWaypoints::render); - ClientPlayConnectionEvents.JOIN.register((_handler, _sender, _client) -> reset()); - } - - protected static void update(List newCommissions) { - activeWaypoints.clear(); - String location = Utils.getIslandArea().substring(2); - //find commission locations in glacite - if (location.equals("Dwarven Base Camp") || location.equals("Glacite Tunnels")) { - for (DwarvenHud.Commission commission : newCommissions) { - String commissionName = commission.commission(); - for (Map.Entry glaciteLocation : GLACITE_LOCATIONS.entrySet()) { - if (commissionName.contains(glaciteLocation.getKey())) { - MiningWaypoints.glaciteCategory category = glaciteLocation.getValue(); - for (BlockPos gemstoneLocation : category.getLocations()) { - activeWaypoints.add(new MiningWaypoints(category, Text.of(category.getName()), gemstoneLocation)); - } - } - } - } - return; - } - //find commission locations in dwarven mines - for (DwarvenHud.Commission commission : newCommissions) { - String commissionName = commission.commission(); - for (Map.Entry dwarvenLocation : DWARVEN_LOCATIONS.entrySet()) { - if (commissionName.contains(dwarvenLocation.getKey())) { - MiningWaypoints.dwarvenCategory category = dwarvenLocation.getValue(); - activeWaypoints.add(new MiningWaypoints(category, Text.of(category.getName()), category.getLocation())); - } - } - } - } - - private static void render(WorldRenderContext context) { - for (MiningWaypoints miningWaypoints : activeWaypoints) { - if (miningWaypoints.shouldRender()) { - miningWaypoints.render(context); - } - } - - } - - private static void reset() { - activeWaypoints.clear(); - } -} 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 34667d12e2..ff4a23b8e4 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"); @@ -75,8 +75,8 @@ private static void render(DrawContext context, float tickDelta, int hudX, int h if (SkyblockerConfigManager.get().mining.crystalsHud.showLocations) { Map ActiveWaypoints = CrystalsLocationsManager.activeWaypoints; - for (MiningWaypoints waypoint : ActiveWaypoints.values()) { - Color waypointColor = waypoint.category.getColor(); + for (CrystalsWaypoint waypoint : ActiveWaypoints.values()) { + Color waypointColor = waypoint.category.color; Vector2ic renderPos = transformLocation(waypoint.pos.getX(), waypoint.pos.getZ()); int locationSize = SkyblockerConfigManager.get().mining.crystalsHud.locationSize; @@ -158,4 +158,4 @@ public static void update() { //get if the player is in the crystals visible = Utils.isInCrystalHollows(); } -} +} \ No newline at end of file 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 d9889b37ab..3aa4dc4de8 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java @@ -47,12 +47,12 @@ public class CrystalsLocationsManager { private static final MinecraftClient CLIENT = MinecraftClient.getInstance(); /** - * A look-up table to convert between location names and waypoint in the {@link MiningWaypoints.crystalCategory} values. + * A look-up table to convert between location names and waypoint in the {@link CrystalsWaypoint.Category} values. */ - private static final Map WAYPOINT_LOCATIONS = Arrays.stream(MiningWaypoints.crystalCategory.values()).collect(Collectors.toMap(MiningWaypoints.crystalCategory::toString, Function.identity())); + private static final Map 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 activeWaypoints = new HashMap<>(); + protected static Map activeWaypoints = new HashMap<>(); public static void init() { Scheduler.INSTANCE.scheduleCyclic(CrystalsLocationsManager::update, 40); @@ -185,8 +185,8 @@ public static int shareWaypoint(String place) { private static void addCustomWaypoint(String waypointName, BlockPos pos) { - MiningWaypoints.crystalCategory category = WAYPOINT_LOCATIONS.get(waypointName); - MiningWaypoints waypoint = new MiningWaypoints(category, Text.literal(waypointName), pos); + CrystalsWaypoint.Category category = WAYPOINT_LOCATIONS.get(waypointName); + CrystalsWaypoint waypoint = new CrystalsWaypoint(category, Text.literal(waypointName), pos); activeWaypoints.put(waypointName, waypoint); } @@ -218,4 +218,4 @@ public static void update() { addCustomWaypoint(location, playerLocation); } } -} +} \ No newline at end of file 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 44e4535fa4..82e0396990 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHud.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHud.java @@ -169,7 +169,7 @@ public static void update() { return; } - List oldCommissionList = commissionList; + List oldCommissionNames = commissionList.stream().map(Commission::commission).toList(); commissionList = new ArrayList<>(); for (PlayerListEntry playerListEntry : CLIENT.getNetworkHandler().getPlayerList().stream().sorted(PlayerListHudAccessor.getOrdering()).toList()) { @@ -198,8 +198,9 @@ public static void update() { glacitePowder = glaciteMatcher.group(0).split(": ")[1]; } } - if (!oldCommissionList.equals(commissionList)) { - CommissionWaypoints.update(commissionList); + List newCommissionNames = commissionList.stream().map(Commission::commission).toList(); + if (!oldCommissionNames.equals(newCommissionNames)) { + CommissionLabels.update(newCommissionNames); } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningWaypoints.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabels.java similarity index 50% rename from src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningWaypoints.java rename to src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabels.java index 7b09e51d0d..7808bec37a 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningWaypoints.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabels.java @@ -1,119 +1,51 @@ package de.hysky.skyblocker.skyblock.dwarven; -import de.hysky.skyblocker.config.SkyblockerConfig; -import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.utils.render.RenderHelper; -import de.hysky.skyblocker.utils.waypoint.Waypoint; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; import net.minecraft.client.MinecraftClient; import net.minecraft.text.Text; -import net.minecraft.util.DyeColor; import net.minecraft.util.Formatting; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; -import java.util.List; import java.awt.*; -import java.util.function.Supplier; -public class MiningWaypoints extends Waypoint { - private static final Supplier CONFIG = () -> SkyblockerConfigManager.get().general.waypoints; - private static final Supplier TYPE_SUPPLIER = () -> CONFIG.get().waypointType; +public class MiningLocationLabels { final Text name; final Category category; private final Vec3d centerPos; - MiningWaypoints(Category category, Text name, BlockPos pos) { - super(pos, TYPE_SUPPLIER, category.getColorComponents()); + MiningLocationLabels(Category category, Text name, BlockPos pos) { this.name = name; this.category = category; this.centerPos = pos.toCenterPos(); } - @Override - public boolean shouldRender() { - return super.shouldRender(); - } - - @Override - public boolean equals(Object obj) { - return super.equals(obj) || obj instanceof MiningWaypoints other && name.equals(other.name) && pos.equals(other.pos); - } - - /** - * Renders the secret waypoint, including a waypoint through {@link Waypoint#render(WorldRenderContext)}, the name, and the distance from the player. - */ - @Override public void render(WorldRenderContext context) { - super.render(context); - Vec3d posUp = centerPos.add(0, 1, 0); - RenderHelper.renderText(context, name, posUp, true); double distance = context.camera().getPos().distanceTo(centerPos); - RenderHelper.renderText(context, Text.literal(Math.round(distance) + "m").formatted(Formatting.YELLOW), posUp, 1, MinecraftClient.getInstance().textRenderer.fontHeight + 1, true); + float scale = (float) (1 * (distance / 10)); + RenderHelper.renderText(context, name, posUp, scale, true); + RenderHelper.renderText(context, Text.literal(Math.round(distance) + "m").formatted(Formatting.YELLOW), posUp, scale, MinecraftClient.getInstance().textRenderer.fontHeight + 1, true); } - interface Category { - Color getColor(); + interface Category { String getName(); float[] getColorComponents(); } - /** - * enum for the different waypoints used int the crystals hud each with a {@link crystalCategory#name} and associated {@link crystalCategory#color} - */ - - enum crystalCategory implements Category { - JUNGLE_TEMPLE("Jungle Temple", new Color(DyeColor.PURPLE.getSignColor())), - MINES_OF_DIVAN("Mines of Divan", Color.GREEN), - GOBLIN_QUEENS_DEN("Goblin Queen's Den", new Color(DyeColor.ORANGE.getSignColor())), - LOST_PRECURSOR_CITY("Lost Precursor City", Color.CYAN), - KHAZAD_DUM("Khazad-dûm", Color.YELLOW), - FAIRY_GROTTO("Fairy Grotto", Color.PINK), - DRAGONS_LAIR("Dragon's Lair", Color.BLACK), - CORLEONE("Corleone", Color.WHITE), - KING_YOLKAR("King Yolkar", Color.RED), - ODAWA("Odawa", Color.MAGENTA), - KEY_GUARDIAN("Key Guardian", Color.LIGHT_GRAY); - - public final Color color; - private final String name; - private final float[] colorComponents; - - crystalCategory(String name, Color color) { - this.name = name; - this.color = color; - this.colorComponents = color.getColorComponents(null); - } - - @Override - public String toString() { - return name; - } - - @Override - public Color getColor() { - return color; - } - - @Override - public String getName() { - return name; - } - - @Override - public float[] getColorComponents() { - return colorComponents; - } - } - - enum dwarvenCategory implements Category { - SOMTHING("s", Color.BLACK, new BlockPos(0, 0, 0)); + LAVA_SPRINGS("Lava Springs", Color.CYAN, new BlockPos(60, 197, -15)), + CLIFFSIDE_VEINS("Cliffside Veins", Color.CYAN, new BlockPos(40, 128, 40)), + RAMPARTS_QUARRY("Rampart's Quarry", Color.CYAN, new BlockPos(-100, 150, -20)), + UPPER_MINES("Upper Mines", Color.CYAN, new BlockPos(-130, 174, -50)), + ROYAL_MINES("Royal Mines", Color.CYAN, new BlockPos(130, 154, 30)), + GLACITE_WALKER("Glacite Walker", Color.CYAN, new BlockPos(0, 128, 150)); + public final Color color; private final String name; @@ -137,10 +69,6 @@ public String toString() { return name; } - @Override - public Color getColor() { - return color; - } @Override public String getName() { @@ -155,7 +83,7 @@ public float[] getColorComponents() { } enum glaciteCategory implements Category { - AQUAMARINE("Aquamarine", Color.CYAN, new BlockPos[]{new BlockPos(-1, 139, 437), new BlockPos(90, 151, 229), new BlockPos(56, 151, 400), new BlockPos(51, 117, 303)}), + AQUAMARINE("Aquamarine", Color.BLUE, new BlockPos[]{new BlockPos(-1, 139, 437), new BlockPos(90, 151, 229), new BlockPos(56, 151, 400), new BlockPos(51, 117, 303)}), ONYX("Onyx", Color.BLACK, 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", Color.GREEN, new BlockPos[]{new BlockPos(-61, 147, 302), new BlockPos(91, 122, 397),new BlockPos(-73, 122, 458), new BlockPos(-77, 120, 282)}), CITRINE("Citrine", Color.YELLOW, new BlockPos[]{new BlockPos(-104, 144, 244), new BlockPos(39, 119, 386), new BlockPos(-57, 144, 421), new BlockPos(-47, 126, 418) }); @@ -182,11 +110,6 @@ public String toString() { return name; } - @Override - public Color getColor() { - return color; - } - @Override public String getName() { return name; From 0cd6b2b3cbd9d86672030ab01772006b3f80d8fb Mon Sep 17 00:00:00 2001 From: olim Date: Mon, 6 May 2024 12:03:24 +0100 Subject: [PATCH 03/14] fix formatting and add better colours --- .../skyblock/dwarven/CommissionLabels.java | 12 +--- .../skyblock/dwarven/CrystalsWaypoint.java | 4 +- .../skyblock/dwarven/MetalDetector.java | 2 +- .../dwarven/MiningLocationLabels.java | 60 ++++++++----------- 4 files changed, 32 insertions(+), 46 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java index f3e8e935cc..24b9178020 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java @@ -16,12 +16,10 @@ public class CommissionLabels { private static final Map DWARVEN_LOCATIONS = Arrays.stream(MiningLocationLabels.dwarvenCategory.values()).collect(Collectors.toMap(MiningLocationLabels.dwarvenCategory::toString, Function.identity())); private static final Map GLACITE_LOCATIONS = Arrays.stream(MiningLocationLabels.glaciteCategory.values()).collect(Collectors.toMap(MiningLocationLabels.glaciteCategory::toString, Function.identity())); - protected static List activeWaypoints = new ArrayList<>(); public static void init() { WorldRenderEvents.AFTER_TRANSLUCENT.register(CommissionLabels::render); - ClientPlayConnectionEvents.JOIN.register((_handler, _sender, _client) -> reset()); } protected static void update(List newCommissions) { @@ -35,7 +33,7 @@ protected static void update(List newCommissions) { if (commission.contains(glaciteLocation.getKey())) { MiningLocationLabels.glaciteCategory category = glaciteLocation.getValue(); for (BlockPos gemstoneLocation : category.getLocations()) { - activeWaypoints.add(new MiningLocationLabels(category, Text.of(category.getName()), gemstoneLocation)); + activeWaypoints.add(new MiningLocationLabels(category, gemstoneLocation)); } } } @@ -47,7 +45,8 @@ protected static void update(List newCommissions) { for (Map.Entry dwarvenLocation : DWARVEN_LOCATIONS.entrySet()) { if (commission.contains(dwarvenLocation.getKey())) { MiningLocationLabels.dwarvenCategory category = dwarvenLocation.getValue(); - activeWaypoints.add(new MiningLocationLabels(category, Text.of(category.getName()), category.getLocation())); + category.isTitanium = commission.contains("Titanium"); + activeWaypoints.add(new MiningLocationLabels(category, category.getLocation())); } } } @@ -60,10 +59,5 @@ private static void render(WorldRenderContext context) { for (MiningLocationLabels MiningLocationLabels : activeWaypoints) { MiningLocationLabels.render(context); } - - } - - private static void reset() { - } } 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/MetalDetector.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MetalDetector.java index 1d7a4db8b4..dd97e5d1ff 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MetalDetector.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MetalDetector.java @@ -249,7 +249,7 @@ private static void render(WorldRenderContext context) { } for (Vec3i block : possibleBlocks) { - MiningWaypoints waypoint = new MiningWaypoints(MiningWaypoints.crystalCategory.CORLEONE, Text.translatable("skyblocker.dwarvenMines.metalDetectorHelper.possible"), new BlockPos(block.getX(), block.getY(), block.getZ())); + CrystalsWaypoint waypoint = new CrystalsWaypoint(CrystalsWaypoint.Category.CORLEONE, Text.translatable("skyblocker.dwarvenMines.metalDetectorHelper.possible"), new BlockPos(block.getX(), block.getY(), block.getZ())); waypoint.render(context); } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabels.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabels.java index 7808bec37a..4b0e2d7ba0 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabels.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabels.java @@ -15,8 +15,8 @@ public class MiningLocationLabels { final Category category; private final Vec3d centerPos; - MiningLocationLabels(Category category, Text name, BlockPos pos) { - this.name = name; + MiningLocationLabels(Category category, BlockPos pos) { + this.name = Text.literal(category.getName()).withColor(category.getColor()); this.category = category; this.centerPos = pos.toCenterPos(); } @@ -27,37 +27,30 @@ public void render(WorldRenderContext context) { float scale = (float) (1 * (distance / 10)); RenderHelper.renderText(context, name, posUp, scale, true); RenderHelper.renderText(context, Text.literal(Math.round(distance) + "m").formatted(Formatting.YELLOW), posUp, scale, MinecraftClient.getInstance().textRenderer.fontHeight + 1, true); - } - interface Category { String getName(); - float[] getColorComponents(); - + int getColor(); //all the color codes are the color of the block the waypoint is for } enum dwarvenCategory implements Category { - LAVA_SPRINGS("Lava Springs", Color.CYAN, new BlockPos(60, 197, -15)), - CLIFFSIDE_VEINS("Cliffside Veins", Color.CYAN, new BlockPos(40, 128, 40)), - RAMPARTS_QUARRY("Rampart's Quarry", Color.CYAN, new BlockPos(-100, 150, -20)), - UPPER_MINES("Upper Mines", Color.CYAN, new BlockPos(-130, 174, -50)), - ROYAL_MINES("Royal Mines", Color.CYAN, new BlockPos(130, 154, 30)), - GLACITE_WALKER("Glacite Walker", Color.CYAN, new BlockPos(0, 128, 150)); + 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)); - public final Color color; + boolean isTitanium; private final String name; - private final float[] colorComponents; private final BlockPos location; - dwarvenCategory(String name, Color color, BlockPos location) { + dwarvenCategory(String name, BlockPos location) { this.name = name; - this.color = color; - this.colorComponents = color.getColorComponents(null); this.location = location; - } public BlockPos getLocation() { @@ -69,38 +62,38 @@ public String toString() { return name; } - @Override public String getName() { return name; } @Override - public float[] getColorComponents() { - return colorComponents; + public int getColor() { + if (isTitanium) { + return 0xd8d6d8; + } + return 0x45bde0; } - } enum glaciteCategory implements Category { - AQUAMARINE("Aquamarine", Color.BLUE, new BlockPos[]{new BlockPos(-1, 139, 437), new BlockPos(90, 151, 229), new BlockPos(56, 151, 400), new BlockPos(51, 117, 303)}), - ONYX("Onyx", Color.BLACK, 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", Color.GREEN, new BlockPos[]{new BlockPos(-61, 147, 302), new BlockPos(91, 122, 397),new BlockPos(-73, 122, 458), new BlockPos(-77, 120, 282)}), - CITRINE("Citrine", Color.YELLOW, new BlockPos[]{new BlockPos(-104, 144, 244), new BlockPos(39, 119, 386), new BlockPos(-57, 144, 421), new BlockPos(-47, 126, 418) }); + 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)}); - public final Color color; private final String name; - private final float[] colorComponents; + private final int color; private final BlockPos[] location; - glaciteCategory(String name, Color color, BlockPos[] location) { + glaciteCategory(String name, int color, BlockPos[] location) { this.name = name; this.color = color; - this.colorComponents = color.getColorComponents(null); this.location = location; - } + + public BlockPos[] getLocations() { return location; } @@ -116,9 +109,8 @@ public String getName() { } @Override - public float[] getColorComponents() { - return colorComponents; + public int getColor() { + return color; } - } } From decdfbadbd3abd8bb4de617ef37add1dd03c8eee Mon Sep 17 00:00:00 2001 From: olim Date: Mon, 6 May 2024 15:04:07 +0100 Subject: [PATCH 04/14] add config options --- .../skyblock/dwarven/CommissionLabels.java | 35 +++++++++++-------- ...onLabels.java => MiningLocationLabel.java} | 21 ++++++----- 2 files changed, 32 insertions(+), 24 deletions(-) rename src/main/java/de/hysky/skyblocker/skyblock/dwarven/{MiningLocationLabels.java => MiningLocationLabel.java} (84%) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java index 24b9178020..9bdd27760d 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java @@ -1,10 +1,9 @@ package de.hysky.skyblocker.skyblock.dwarven; +import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.utils.Utils; -import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; -import net.minecraft.text.Text; import net.minecraft.util.math.BlockPos; import java.util.*; @@ -13,51 +12,57 @@ public class CommissionLabels { - private static final Map DWARVEN_LOCATIONS = Arrays.stream(MiningLocationLabels.dwarvenCategory.values()).collect(Collectors.toMap(MiningLocationLabels.dwarvenCategory::toString, Function.identity())); - private static final Map GLACITE_LOCATIONS = Arrays.stream(MiningLocationLabels.glaciteCategory.values()).collect(Collectors.toMap(MiningLocationLabels.glaciteCategory::toString, Function.identity())); + private static final Map DWARVEN_LOCATIONS = Arrays.stream(MiningLocationLabel.dwarvenCategory.values()).collect(Collectors.toMap(MiningLocationLabel.dwarvenCategory::toString, Function.identity())); + 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<>(); + protected static List activeWaypoints = new ArrayList<>(); public static void init() { WorldRenderEvents.AFTER_TRANSLUCENT.register(CommissionLabels::render); } protected static void update(List newCommissions) { - System.out.println(newCommissions); + if (!SkyblockerConfigManager.get().locations.dwarvenMines.commissionWaypoints.enabled) { + return; + } activeWaypoints.clear(); String location = Utils.getIslandArea().substring(2); //find commission locations in glacite if (location.equals("Dwarven Base Camp") || location.equals("Glacite Tunnels")) { for (String commission : newCommissions) { - for (Map.Entry glaciteLocation : GLACITE_LOCATIONS.entrySet()) { + for (Map.Entry glaciteLocation : GLACITE_LOCATIONS.entrySet()) { if (commission.contains(glaciteLocation.getKey())) { - MiningLocationLabels.glaciteCategory category = glaciteLocation.getValue(); + MiningLocationLabel.glaciteCategory category = glaciteLocation.getValue(); for (BlockPos gemstoneLocation : category.getLocations()) { - activeWaypoints.add(new MiningLocationLabels(category, gemstoneLocation)); + activeWaypoints.add(new MiningLocationLabel(category, gemstoneLocation)); } } } } + //add base waypoint if enabled + if (SkyblockerConfigManager.get().locations.dwarvenMines.commissionWaypoints.showBaseCamp) { + activeWaypoints.add(new MiningLocationLabel(MiningLocationLabel.glaciteCategory.CAMPFIRE, MiningLocationLabel.glaciteCategory.CAMPFIRE.getLocations()[0])); + } return; } //find commission locations in dwarven mines for (String commission : newCommissions) { - for (Map.Entry dwarvenLocation : DWARVEN_LOCATIONS.entrySet()) { + for (Map.Entry dwarvenLocation : DWARVEN_LOCATIONS.entrySet()) { if (commission.contains(dwarvenLocation.getKey())) { - MiningLocationLabels.dwarvenCategory category = dwarvenLocation.getValue(); + MiningLocationLabel.dwarvenCategory category = dwarvenLocation.getValue(); category.isTitanium = commission.contains("Titanium"); - activeWaypoints.add(new MiningLocationLabels(category, category.getLocation())); + activeWaypoints.add(new MiningLocationLabel(category, category.getLocation())); } } } } private static void render(WorldRenderContext context) { - if (!Utils.isInDwarvenMines()) { + if (!Utils.isInDwarvenMines() || !SkyblockerConfigManager.get().locations.dwarvenMines.commissionWaypoints.enabled) { return; } - for (MiningLocationLabels MiningLocationLabels : activeWaypoints) { - MiningLocationLabels.render(context); + for (MiningLocationLabel MiningLocationLabel : activeWaypoints) { + MiningLocationLabel.render(context); } } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabels.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java similarity index 84% rename from src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabels.java rename to src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java index 4b0e2d7ba0..ce5f5ccb8c 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabels.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java @@ -1,5 +1,6 @@ package de.hysky.skyblocker.skyblock.dwarven; +import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.utils.render.RenderHelper; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; import net.minecraft.client.MinecraftClient; @@ -8,15 +9,18 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; -import java.awt.*; - -public class MiningLocationLabels { +public class MiningLocationLabel { final Text name; final Category category; private final Vec3d centerPos; - MiningLocationLabels(Category category, BlockPos pos) { - this.name = Text.literal(category.getName()).withColor(category.getColor()); + MiningLocationLabel(Category category, BlockPos pos) { + if (SkyblockerConfigManager.get().locations.dwarvenMines.commissionWaypoints.useColor) { + this.name = Text.literal(category.getName()).withColor(category.getColor()); + } else { + this.name = Text.literal(category.getName()); + } + this.category = category; this.centerPos = pos.toCenterPos(); } @@ -24,7 +28,7 @@ public class MiningLocationLabels { public void render(WorldRenderContext context) { Vec3d posUp = centerPos.add(0, 1, 0); double distance = context.camera().getPos().distanceTo(centerPos); - float scale = (float) (1 * (distance / 10)); + float scale = (float) (SkyblockerConfigManager.get().locations.dwarvenMines.commissionWaypoints.textScale * (distance / 10)); RenderHelper.renderText(context, name, posUp, scale, true); RenderHelper.renderText(context, Text.literal(Math.round(distance) + "m").formatted(Formatting.YELLOW), posUp, scale, MinecraftClient.getInstance().textRenderer.fontHeight + 1, true); } @@ -80,7 +84,8 @@ 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)}); + 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; @@ -92,8 +97,6 @@ enum glaciteCategory implements Category { this.location = location; } - - public BlockPos[] getLocations() { return location; } From f3ebd6529dc0a29fa561aa71564f2e20d3568dcb Mon Sep 17 00:00:00 2001 From: olim Date: Mon, 6 May 2024 15:12:45 +0100 Subject: [PATCH 05/14] tidy up last bits --- .../skyblocker/skyblock/dwarven/CommissionLabels.java | 8 ++++++++ .../de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java | 2 +- .../de/hysky/skyblocker/skyblock/dwarven/DwarvenHud.java | 2 +- .../skyblocker/skyblock/dwarven/MiningLocationLabel.java | 4 ++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java index 9bdd27760d..353d0e8a3a 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java @@ -21,6 +21,10 @@ 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 + */ protected static void update(List newCommissions) { if (!SkyblockerConfigManager.get().locations.dwarvenMines.commissionWaypoints.enabled) { return; @@ -57,6 +61,10 @@ protected static void update(List newCommissions) { } } + /** + * render all the active waypoints + * @param context render context + */ private static void render(WorldRenderContext context) { if (!Utils.isInDwarvenMines() || !SkyblockerConfigManager.get().locations.dwarvenMines.commissionWaypoints.enabled) { return; 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 ff4a23b8e4..6343048981 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java @@ -158,4 +158,4 @@ public static void update() { //get if the player is in the crystals visible = Utils.isInCrystalHollows(); } -} \ No newline at end of file +} 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 82e0396990..0ae502539a 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHud.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHud.java @@ -25,7 +25,7 @@ public class DwarvenHud { private static final MinecraftClient CLIENT = MinecraftClient.getInstance(); - protected static List commissionList = new ArrayList<>(); + private static List commissionList = new ArrayList<>(); public static String mithrilPowder = "0"; public static String gemStonePowder = "0"; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java index ce5f5ccb8c..ee82773c68 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java @@ -25,6 +25,10 @@ public class MiningLocationLabel { this.centerPos = pos.toCenterPos(); } + /** + * render the name and distance to the label scaled so can be seen at a distance + * @param context render context + */ public void render(WorldRenderContext context) { Vec3d posUp = centerPos.add(0, 1, 0); double distance = context.camera().getPos().distanceTo(centerPos); From eaac33822516e7bf5be9296f80bb0143ad1ddca2 Mon Sep 17 00:00:00 2001 From: olim Date: Mon, 6 May 2024 21:50:58 +0100 Subject: [PATCH 06/14] add emissary waypoints --- .../skyblock/dwarven/CommissionLabels.java | 10 +++++- .../skyblock/dwarven/DwarvenHud.java | 8 ++--- .../skyblock/dwarven/MiningLocationLabel.java | 36 +++++++++++++++++++ 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java index 353d0e8a3a..7e577beb73 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java @@ -13,6 +13,7 @@ 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_EMISSARYS = 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<>(); @@ -24,8 +25,9 @@ public static void init() { /** * 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) { + protected static void update(List newCommissions, boolean completed) { if (!SkyblockerConfigManager.get().locations.dwarvenMines.commissionWaypoints.enabled) { return; } @@ -59,6 +61,12 @@ protected static void update(List newCommissions) { } } } + //if there is a commission completed and enabled show emissary + if (SkyblockerConfigManager.get().locations.dwarvenMines.commissionWaypoints.showEmissary && completed) { + for (MiningLocationLabel.dwarvenEmissaries emissaries : DWARVEN_EMISSARYS) { + activeWaypoints.add(new MiningLocationLabel(emissaries, emissaries.getLocation())); + } + } } /** 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 0ae502539a..e77e5463c8 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHud.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHud.java @@ -168,10 +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; @@ -199,8 +198,9 @@ public static void update() { } } List newCommissionNames = commissionList.stream().map(Commission::commission).toList(); - if (!oldCommissionNames.equals(newCommissionNames)) { - CommissionLabels.update(newCommissionNames); + boolean newCompleted = commissionList.stream().anyMatch(commission -> commission.progression.equals("DONE")); + if (!oldCommissionNames.equals(newCommissionNames) || oldCompleted != newCompleted) { + CommissionLabels.update(newCommissionNames, newCompleted); } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java index ee82773c68..356e221473 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java @@ -84,6 +84,42 @@ public int getColor() { } } + 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)}), From 2af1e84bebc079249c095ee08e1956838989c08f Mon Sep 17 00:00:00 2001 From: olim Date: Mon, 6 May 2024 22:39:57 +0100 Subject: [PATCH 07/14] fix showing when in the mineshafts --- .../hysky/skyblocker/skyblock/dwarven/CommissionLabels.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java index 7e577beb73..2f3f7b58c8 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java @@ -28,11 +28,11 @@ public static void init() { * @param completed if there is a commission completed */ protected static void update(List newCommissions, boolean completed) { - if (!SkyblockerConfigManager.get().locations.dwarvenMines.commissionWaypoints.enabled) { + String location = Utils.getIslandArea().substring(2); + if (!SkyblockerConfigManager.get().locations.dwarvenMines.commissionWaypoints.enabled || location.equals("Glacite Mineshafts")) { return; } activeWaypoints.clear(); - String location = Utils.getIslandArea().substring(2); //find commission locations in glacite if (location.equals("Dwarven Base Camp") || location.equals("Glacite Tunnels")) { for (String commission : newCommissions) { From fabd4776ca61c542f3b22e2c2757538aee461f90 Mon Sep 17 00:00:00 2001 From: olim Date: Mon, 6 May 2024 22:55:31 +0100 Subject: [PATCH 08/14] glacite lake is also in tunnels this place is not in the wiki i did not realise it existed but it would show dwarven instead of glacite waypoints --- .../de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java index 2f3f7b58c8..9e299fb91a 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java @@ -34,7 +34,7 @@ protected static void update(List newCommissions, boolean completed) { } activeWaypoints.clear(); //find commission locations in glacite - if (location.equals("Dwarven Base Camp") || location.equals("Glacite Tunnels")) { + if (location.equals("Dwarven Base Camp") || location.equals("Glacite Tunnels")|| location.equals("Glacite Lake")) { for (String commission : newCommissions) { for (Map.Entry glaciteLocation : GLACITE_LOCATIONS.entrySet()) { if (commission.contains(glaciteLocation.getKey())) { From 3195bbdd8101230615a4160c270e0c81f877ebe7 Mon Sep 17 00:00:00 2001 From: olim Date: Tue, 7 May 2024 12:17:56 +0100 Subject: [PATCH 09/14] commisions update when in mineshaft fix commissions not updating while in a mineshaft --- .../skyblocker/skyblock/dwarven/CommissionLabels.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java index 9e299fb91a..3eb8d47767 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java @@ -24,17 +24,18 @@ public static void init() { /** * 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 + * @param completed if there is a commission completed */ protected static void update(List newCommissions, boolean completed) { - String location = Utils.getIslandArea().substring(2); - if (!SkyblockerConfigManager.get().locations.dwarvenMines.commissionWaypoints.enabled || location.equals("Glacite Mineshafts")) { + if (!SkyblockerConfigManager.get().locations.dwarvenMines.commissionWaypoints.enabled) { 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 Lake")) { + if (location.equals("Dwarven Base Camp") || location.equals("Glacite Tunnels") || location.equals("Glacite Mineshafts") || location.equals("Glacite Lake")) { for (String commission : newCommissions) { for (Map.Entry glaciteLocation : GLACITE_LOCATIONS.entrySet()) { if (commission.contains(glaciteLocation.getKey())) { @@ -71,6 +72,7 @@ protected static void update(List newCommissions, boolean completed) { /** * render all the active waypoints + * * @param context render context */ private static void render(WorldRenderContext context) { From f34fdf9bc3fd00ab9878682a1e331fb9b4d60397 Mon Sep 17 00:00:00 2001 From: olim Date: Tue, 7 May 2024 13:20:05 +0100 Subject: [PATCH 10/14] finer control on if enabled add options to only enable in dwarven or glacite locations --- .../skyblock/dwarven/CommissionLabels.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java index 3eb8d47767..57361ae521 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java @@ -1,5 +1,6 @@ package de.hysky.skyblocker.skyblock.dwarven; +import de.hysky.skyblocker.config.SkyblockerConfig; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.utils.Utils; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; @@ -29,13 +30,18 @@ public static void init() { * @param completed if there is a commission completed */ protected static void update(List newCommissions, boolean completed) { - if (!SkyblockerConfigManager.get().locations.dwarvenMines.commissionWaypoints.enabled) { + SkyblockerConfig.CommissionWaypointMode currentMode = SkyblockerConfigManager.get().locations.dwarvenMines.commissionWaypoints.mode; + if (currentMode == SkyblockerConfig.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 != SkyblockerConfig.CommissionWaypointMode.BOTH && currentMode != SkyblockerConfig.CommissionWaypointMode.GLACITE) { + return; + } + for (String commission : newCommissions) { for (Map.Entry glaciteLocation : GLACITE_LOCATIONS.entrySet()) { if (commission.contains(glaciteLocation.getKey())) { @@ -53,6 +59,10 @@ protected static void update(List newCommissions, boolean completed) { return; } //find commission locations in dwarven mines + if (currentMode != SkyblockerConfig.CommissionWaypointMode.BOTH && currentMode != SkyblockerConfig.CommissionWaypointMode.DWARVEN) { + return; + } + for (String commission : newCommissions) { for (Map.Entry dwarvenLocation : DWARVEN_LOCATIONS.entrySet()) { if (commission.contains(dwarvenLocation.getKey())) { @@ -76,7 +86,7 @@ protected static void update(List newCommissions, boolean completed) { * @param context render context */ private static void render(WorldRenderContext context) { - if (!Utils.isInDwarvenMines() || !SkyblockerConfigManager.get().locations.dwarvenMines.commissionWaypoints.enabled) { + if (!Utils.isInDwarvenMines() || SkyblockerConfigManager.get().locations.dwarvenMines.commissionWaypoints.mode == SkyblockerConfig.CommissionWaypointMode.OFF) { return; } for (MiningLocationLabel MiningLocationLabel : activeWaypoints) { From e81be5283360c6cf118c3b663b3d58df4dba10fd Mon Sep 17 00:00:00 2001 From: olim Date: Thu, 9 May 2024 23:10:38 +0100 Subject: [PATCH 11/14] fix to work with new config --- .../config/categories/MiningCategory.java | 50 +++++++++++++++++++ .../config/configs/MiningConfig.java | 34 +++++++++++++ .../skyblock/dwarven/CommissionLabels.java | 16 +++--- .../skyblock/dwarven/MiningLocationLabel.java | 4 +- .../assets/skyblocker/lang/en_us.json | 16 ++++++ 5 files changed, 110 insertions(+), 10 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 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 index 57361ae521..d8b40c439e 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java @@ -1,7 +1,7 @@ package de.hysky.skyblocker.skyblock.dwarven; -import de.hysky.skyblocker.config.SkyblockerConfig; 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; @@ -30,15 +30,15 @@ public static void init() { * @param completed if there is a commission completed */ protected static void update(List newCommissions, boolean completed) { - SkyblockerConfig.CommissionWaypointMode currentMode = SkyblockerConfigManager.get().locations.dwarvenMines.commissionWaypoints.mode; - if (currentMode == SkyblockerConfig.CommissionWaypointMode.OFF) { + 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 != SkyblockerConfig.CommissionWaypointMode.BOTH && currentMode != SkyblockerConfig.CommissionWaypointMode.GLACITE) { + if (currentMode != MiningConfig.CommissionWaypointMode.BOTH && currentMode != MiningConfig.CommissionWaypointMode.GLACITE) { return; } @@ -53,13 +53,13 @@ protected static void update(List newCommissions, boolean completed) { } } //add base waypoint if enabled - if (SkyblockerConfigManager.get().locations.dwarvenMines.commissionWaypoints.showBaseCamp) { + 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 != SkyblockerConfig.CommissionWaypointMode.BOTH && currentMode != SkyblockerConfig.CommissionWaypointMode.DWARVEN) { + if (currentMode != MiningConfig.CommissionWaypointMode.BOTH && currentMode != MiningConfig.CommissionWaypointMode.DWARVEN) { return; } @@ -73,7 +73,7 @@ protected static void update(List newCommissions, boolean completed) { } } //if there is a commission completed and enabled show emissary - if (SkyblockerConfigManager.get().locations.dwarvenMines.commissionWaypoints.showEmissary && completed) { + if (SkyblockerConfigManager.get().mining.commissionWaypoints.showEmissary && completed) { for (MiningLocationLabel.dwarvenEmissaries emissaries : DWARVEN_EMISSARYS) { activeWaypoints.add(new MiningLocationLabel(emissaries, emissaries.getLocation())); } @@ -86,7 +86,7 @@ protected static void update(List newCommissions, boolean completed) { * @param context render context */ private static void render(WorldRenderContext context) { - if (!Utils.isInDwarvenMines() || SkyblockerConfigManager.get().locations.dwarvenMines.commissionWaypoints.mode == SkyblockerConfig.CommissionWaypointMode.OFF) { + if (!Utils.isInDwarvenMines() || SkyblockerConfigManager.get().mining.commissionWaypoints.mode == MiningConfig.CommissionWaypointMode.OFF) { return; } for (MiningLocationLabel MiningLocationLabel : activeWaypoints) { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java index 356e221473..d41318ad0b 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java @@ -15,7 +15,7 @@ public class MiningLocationLabel { private final Vec3d centerPos; MiningLocationLabel(Category category, BlockPos pos) { - if (SkyblockerConfigManager.get().locations.dwarvenMines.commissionWaypoints.useColor) { + if (SkyblockerConfigManager.get().mining.commissionWaypoints.useColor) { this.name = Text.literal(category.getName()).withColor(category.getColor()); } else { this.name = Text.literal(category.getName()); @@ -32,7 +32,7 @@ public class MiningLocationLabel { public void render(WorldRenderContext context) { Vec3d posUp = centerPos.add(0, 1, 0); double distance = context.camera().getPos().distanceTo(centerPos); - float scale = (float) (SkyblockerConfigManager.get().locations.dwarvenMines.commissionWaypoints.textScale * (distance / 10)); + float scale = (float) (SkyblockerConfigManager.get().mining.commissionWaypoints.textScale * (distance / 10)); RenderHelper.renderText(context, name, posUp, scale, true); RenderHelper.renderText(context, Text.literal(Math.round(distance) + "m").formatted(Formatting.YELLOW), posUp, scale, MinecraftClient.getInstance().textRenderer.fontHeight + 1, true); } diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 283175d045..748841adf6 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -397,6 +397,22 @@ "skyblocker.config.mining.crystalsWaypoints.findInChat.@Tooltip": "When in crystal hollows read the chat to see if coordinates are sent and extract these to show as waypoint or on the map", "skyblocker.config.mining.crystalsWaypoints.shareFail": "Can only share waypoints you have found.", + "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 (takes effect when commissions updated).", + "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.dwarvenHud": "Dwarven HUD", "skyblocker.config.mining.dwarvenHud.enabledCommissions": "Enable Commissions", "skyblocker.config.mining.dwarvenHud.enabledPowder": "Enable Powder", From 100104f84dd53cf15d1252f8f79fd63ba2bde185 Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 10 May 2024 21:31:55 +0100 Subject: [PATCH 12/14] fix formmating problems --- .../skyblock/dwarven/CommissionLabels.java | 18 +++++------ .../skyblock/dwarven/MiningLocationLabel.java | 12 +++---- .../assets/skyblocker/lang/en_us.json | 32 +++++++++---------- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java index d8b40c439e..3d7c2c00c6 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java @@ -13,9 +13,9 @@ 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_EMISSARYS = 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())); + 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<>(); @@ -43,9 +43,9 @@ protected static void update(List newCommissions, boolean completed) { } for (String commission : newCommissions) { - for (Map.Entry glaciteLocation : GLACITE_LOCATIONS.entrySet()) { + for (Map.Entry glaciteLocation : GLACITE_LOCATIONS.entrySet()) { if (commission.contains(glaciteLocation.getKey())) { - MiningLocationLabel.glaciteCategory category = glaciteLocation.getValue(); + MiningLocationLabel.GlaciteCategory category = glaciteLocation.getValue(); for (BlockPos gemstoneLocation : category.getLocations()) { activeWaypoints.add(new MiningLocationLabel(category, gemstoneLocation)); } @@ -54,7 +54,7 @@ protected static void update(List newCommissions, boolean completed) { } //add base waypoint if enabled if (SkyblockerConfigManager.get().mining.commissionWaypoints.showBaseCamp) { - activeWaypoints.add(new MiningLocationLabel(MiningLocationLabel.glaciteCategory.CAMPFIRE, MiningLocationLabel.glaciteCategory.CAMPFIRE.getLocations()[0])); + activeWaypoints.add(new MiningLocationLabel(MiningLocationLabel.GlaciteCategory.CAMPFIRE, MiningLocationLabel.GlaciteCategory.CAMPFIRE.getLocations()[0])); } return; } @@ -64,9 +64,9 @@ protected static void update(List newCommissions, boolean completed) { } for (String commission : newCommissions) { - for (Map.Entry dwarvenLocation : DWARVEN_LOCATIONS.entrySet()) { + for (Map.Entry dwarvenLocation : DWARVEN_LOCATIONS.entrySet()) { if (commission.contains(dwarvenLocation.getKey())) { - MiningLocationLabel.dwarvenCategory category = dwarvenLocation.getValue(); + MiningLocationLabel.DwarvenCategory category = dwarvenLocation.getValue(); category.isTitanium = commission.contains("Titanium"); activeWaypoints.add(new MiningLocationLabel(category, category.getLocation())); } @@ -74,7 +74,7 @@ protected static void update(List newCommissions, boolean completed) { } //if there is a commission completed and enabled show emissary if (SkyblockerConfigManager.get().mining.commissionWaypoints.showEmissary && completed) { - for (MiningLocationLabel.dwarvenEmissaries emissaries : DWARVEN_EMISSARYS) { + for (MiningLocationLabel.DwarvenEmissaries emissaries : DWARVEN_EMISSARIES) { activeWaypoints.add(new MiningLocationLabel(emissaries, emissaries.getLocation())); } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java index d41318ad0b..7d5653862c 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java @@ -43,7 +43,7 @@ interface Category { int getColor(); //all the color codes are the color of the block the waypoint is for } - enum dwarvenCategory implements Category { + 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)), @@ -56,7 +56,7 @@ enum dwarvenCategory implements Category { private final String name; private final BlockPos location; - dwarvenCategory(String name, BlockPos location) { + DwarvenCategory(String name, BlockPos location) { this.name = name; this.location = location; } @@ -84,7 +84,7 @@ public int getColor() { } } - enum dwarvenEmissaries implements Category { + 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)), @@ -95,7 +95,7 @@ enum dwarvenEmissaries implements Category { private final BlockPos location; - dwarvenEmissaries( BlockPos location) { + DwarvenEmissaries(BlockPos location) { this.location = location; } @@ -120,7 +120,7 @@ public int getColor() { } } - enum glaciteCategory implements Category { + 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)}), @@ -131,7 +131,7 @@ enum glaciteCategory implements Category { private final int color; private final BlockPos[] location; - glaciteCategory(String name, int color, BlockPos[] location) { + GlaciteCategory(String name, int color, BlockPos[] location) { this.name = name; this.color = color; this.location = location; diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 748841adf6..07502b7f65 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 (takes effect when commissions updated).", + "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.", @@ -397,22 +413,6 @@ "skyblocker.config.mining.crystalsWaypoints.findInChat.@Tooltip": "When in crystal hollows read the chat to see if coordinates are sent and extract these to show as waypoint or on the map", "skyblocker.config.mining.crystalsWaypoints.shareFail": "Can only share waypoints you have found.", - "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 (takes effect when commissions updated).", - "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.dwarvenHud": "Dwarven HUD", "skyblocker.config.mining.dwarvenHud.enabledCommissions": "Enable Commissions", "skyblocker.config.mining.dwarvenHud.enabledPowder": "Enable Powder", From 991988cd92d49dd29a66e82eaf114a9252d0ad69 Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 10 May 2024 21:46:18 +0100 Subject: [PATCH 13/14] turn the lables into a record --- .../skyblock/dwarven/CommissionLabels.java | 9 +++++---- .../skyblock/dwarven/MiningLocationLabel.java | 17 +++++------------ .../resources/assets/skyblocker/lang/en_us.json | 2 +- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java index 3d7c2c00c6..b4f9eb2227 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java @@ -5,6 +5,7 @@ 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.text.Text; import net.minecraft.util.math.BlockPos; import java.util.*; @@ -47,14 +48,14 @@ protected static void update(List newCommissions, boolean completed) { if (commission.contains(glaciteLocation.getKey())) { MiningLocationLabel.GlaciteCategory category = glaciteLocation.getValue(); for (BlockPos gemstoneLocation : category.getLocations()) { - activeWaypoints.add(new MiningLocationLabel(category, gemstoneLocation)); + activeWaypoints.add(new MiningLocationLabel(category, gemstoneLocation.toCenterPos())); } } } } //add base waypoint if enabled if (SkyblockerConfigManager.get().mining.commissionWaypoints.showBaseCamp) { - activeWaypoints.add(new MiningLocationLabel(MiningLocationLabel.GlaciteCategory.CAMPFIRE, MiningLocationLabel.GlaciteCategory.CAMPFIRE.getLocations()[0])); + activeWaypoints.add(new MiningLocationLabel(MiningLocationLabel.GlaciteCategory.CAMPFIRE, MiningLocationLabel.GlaciteCategory.CAMPFIRE.getLocations()[0].toCenterPos())); } return; } @@ -68,14 +69,14 @@ protected static void update(List newCommissions, boolean completed) { if (commission.contains(dwarvenLocation.getKey())) { MiningLocationLabel.DwarvenCategory category = dwarvenLocation.getValue(); category.isTitanium = commission.contains("Titanium"); - activeWaypoints.add(new MiningLocationLabel(category, category.getLocation())); + activeWaypoints.add(new MiningLocationLabel(category, category.getLocation().toCenterPos())); } } } //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())); + activeWaypoints.add(new MiningLocationLabel(emissaries, emissaries.getLocation().toCenterPos())); } } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java index 7d5653862c..45462400e1 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java @@ -9,20 +9,13 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; -public class MiningLocationLabel { - final Text name; - final Category category; - private final Vec3d centerPos; +public record MiningLocationLabel (Category category, Vec3d centerPos){ - MiningLocationLabel(Category category, BlockPos pos) { + private Text getName() { if (SkyblockerConfigManager.get().mining.commissionWaypoints.useColor) { - this.name = Text.literal(category.getName()).withColor(category.getColor()); - } else { - this.name = Text.literal(category.getName()); + return Text.literal(category.getName()).withColor(category.getColor()); } - - this.category = category; - this.centerPos = pos.toCenterPos(); + return Text.literal(category.getName()); } /** @@ -33,7 +26,7 @@ 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, name, posUp, scale, true); + 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); } diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 07502b7f65..c5ebd9d442 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -385,7 +385,7 @@ "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 (takes effect when commissions updated).", + "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", From 6cf8e7eaa586105835b85719139c974f93656619 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sat, 11 May 2024 22:50:03 -0400 Subject: [PATCH 14/14] Refactor MiningLocationLabel and formatting --- .../skyblock/dwarven/CommissionLabels.java | 14 ++++++++------ .../dwarven/CrystalsLocationsManager.java | 2 +- .../skyblocker/skyblock/dwarven/DwarvenHud.java | 2 +- .../skyblock/dwarven/MiningLocationLabel.java | 15 ++++++++++----- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java index b4f9eb2227..a14c71f769 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java @@ -5,10 +5,12 @@ 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.text.Text; import net.minecraft.util.math.BlockPos; -import java.util.*; +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; @@ -48,14 +50,14 @@ protected static void update(List newCommissions, boolean completed) { if (commission.contains(glaciteLocation.getKey())) { MiningLocationLabel.GlaciteCategory category = glaciteLocation.getValue(); for (BlockPos gemstoneLocation : category.getLocations()) { - activeWaypoints.add(new MiningLocationLabel(category, gemstoneLocation.toCenterPos())); + 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].toCenterPos())); + activeWaypoints.add(new MiningLocationLabel(MiningLocationLabel.GlaciteCategory.CAMPFIRE, MiningLocationLabel.GlaciteCategory.CAMPFIRE.getLocations()[0])); } return; } @@ -69,14 +71,14 @@ protected static void update(List newCommissions, boolean completed) { if (commission.contains(dwarvenLocation.getKey())) { MiningLocationLabel.DwarvenCategory category = dwarvenLocation.getValue(); category.isTitanium = commission.contains("Titanium"); - activeWaypoints.add(new MiningLocationLabel(category, category.getLocation().toCenterPos())); + 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().toCenterPos())); + activeWaypoints.add(new MiningLocationLabel(emissaries, emissaries.getLocation())); } } } 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 3aa4dc4de8..6f4c86a75e 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java @@ -218,4 +218,4 @@ public static void update() { addCustomWaypoint(location, playerLocation); } } -} \ No newline at end of file +} 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 e77e5463c8..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,7 +168,7 @@ public static void update() { || !Utils.isInCrystalHollows() && !Utils.isInDwarvenMines()) { return; } - List oldCommissionNames = commissionList.stream().map(Commission::commission).toList(); + 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()) { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java index 45462400e1..1f373b5572 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java @@ -2,6 +2,7 @@ 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; @@ -9,7 +10,10 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; -public record MiningLocationLabel (Category category, Vec3d centerPos){ +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) { @@ -19,9 +23,10 @@ private Text getName() { } /** - * render the name and distance to the label scaled so can be seen at a distance + * 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); @@ -30,7 +35,7 @@ public void render(WorldRenderContext context) { RenderHelper.renderText(context, Text.literal(Math.round(distance) + "m").formatted(Formatting.YELLOW), posUp, scale, MinecraftClient.getInstance().textRenderer.fontHeight + 1, true); } - interface Category { + public interface Category { String getName(); int getColor(); //all the color codes are the color of the block the waypoint is for @@ -83,8 +88,8 @@ enum DwarvenEmissaries implements Category { 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)); + DWARVEN_VILLAGE(new BlockPos(-37, 200, -92)), + DWARVEN_MINES(new BlockPos(89, 198, -92)); private final BlockPos location;