From a01ebfa0b30c6d7c8bd31057d31062106bc52e39 Mon Sep 17 00:00:00 2001 From: olim Date: Sun, 5 May 2024 12:02:06 +0100 Subject: add waypoints for current commision still need to get locations in the mines --- .../java/de/hysky/skyblocker/SkyblockerMod.java | 6 +- .../skyblock/dwarven/CommissionWaypoints.java | 69 +++++++ .../skyblocker/skyblock/dwarven/CrystalsHud.java | 4 +- .../skyblock/dwarven/CrystalsLocationsManager.java | 10 +- .../skyblocker/skyblock/dwarven/DwarvenHud.java | 6 +- .../skyblocker/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 (limited to 'src/main/java/de') diff --git a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java index 3336cefb..7d7acfbf 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.boulder.Boulder; 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 class SkyblockerMod implements ClientModInitializer { 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 00000000..a73e89b9 --- /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 a74dbc5e..34667d12 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 @@ public class CrystalsHud { 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 6f4c86a7..d9889b37 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 class CrystalsLocationsManager { 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 242c513a..44e4535f 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 @@ import java.util.stream.Stream; 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 class DwarvenHud { return; } + List oldCommissionList = commissionList; commissionList = new ArrayList<>(); for (PlayerListEntry playerListEntry : CLIENT.getNetworkHandler().getPlayerList().stream().sorted(PlayerListHudAccessor.getOrdering()).toList()) { @@ -197,6 +198,9 @@ public class DwarvenHud { 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 dd97e5d1..1d7a4db8 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 @@ public class MetalDetector { } 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 00000000..7b09e51d --- /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; + } + + } +} -- cgit From b47ebd85b5ecb2c9b2adbbcd80f750ca15fd433e Mon Sep 17 00:00:00 2001 From: olim Date: Mon, 6 May 2024 11:14:56 +0100 Subject: rework to use labels instead of trying to use crystal waypoints --- .../java/de/hysky/skyblocker/SkyblockerMod.java | 2 +- .../skyblock/dwarven/CommissionLabels.java | 69 +++++++ .../skyblock/dwarven/CommissionWaypoints.java | 69 ------- .../skyblocker/skyblock/dwarven/CrystalsHud.java | 8 +- .../skyblock/dwarven/CrystalsLocationsManager.java | 12 +- .../skyblocker/skyblock/dwarven/DwarvenHud.java | 7 +- .../skyblock/dwarven/MiningLocationLabels.java | 124 +++++++++++++ .../skyblock/dwarven/MiningWaypoints.java | 201 --------------------- 8 files changed, 208 insertions(+), 284 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 create mode 100644 src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabels.java delete mode 100644 src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningWaypoints.java (limited to 'src/main/java/de') diff --git a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java index 7d7acfbf..f3bb8d9d 100644 --- a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java +++ b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java @@ -120,7 +120,7 @@ public class SkyblockerMod implements ClientModInitializer { 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 00000000..f3e8e935 --- /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 a73e89b9..00000000 --- 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 34667d12..ff4a23b8 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 @@ import java.util.Map; 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 @@ public class CrystalsHud { 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 class CrystalsHud { //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 d9889b37..3aa4dc4d 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 class CrystalsLocationsManager { 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 class CrystalsLocationsManager { 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 44e4535f..82e03969 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 class DwarvenHud { 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 class DwarvenHud { 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/MiningLocationLabels.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabels.java new file mode 100644 index 00000000..7808bec3 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabels.java @@ -0,0 +1,124 @@ +package de.hysky.skyblocker.skyblock.dwarven; + +import de.hysky.skyblocker.utils.render.RenderHelper; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; +import net.minecraft.client.MinecraftClient; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; + +import java.awt.*; + +public class MiningLocationLabels { + final Text name; + final Category category; + private final Vec3d centerPos; + + MiningLocationLabels(Category category, Text name, BlockPos pos) { + this.name = name; + this.category = category; + this.centerPos = pos.toCenterPos(); + } + + 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)); + 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(); + + } + + 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)); + + + 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 String getName() { + return name; + } + + @Override + public float[] getColorComponents() { + return colorComponents; + } + + } + + 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) }); + + 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 String getName() { + return name; + } + + @Override + public float[] getColorComponents() { + return colorComponents; + } + + } +} diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningWaypoints.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningWaypoints.java deleted file mode 100644 index 7b09e51d..00000000 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningWaypoints.java +++ /dev/null @@ -1,201 +0,0 @@ -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; - } - - } -} -- cgit From 0cd6b2b3cbd9d86672030ab01772006b3f80d8fb Mon Sep 17 00:00:00 2001 From: olim Date: Mon, 6 May 2024 12:03:24 +0100 Subject: fix formatting and add better colours --- .../skyblock/dwarven/CommissionLabels.java | 12 ++--- .../skyblock/dwarven/CrystalsWaypoint.java | 4 +- .../skyblocker/skyblock/dwarven/MetalDetector.java | 2 +- .../skyblock/dwarven/MiningLocationLabels.java | 60 ++++++++++------------ 4 files changed, 32 insertions(+), 46 deletions(-) (limited to 'src/main/java/de') 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 f3e8e935..24b91780 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 @@ public class CommissionLabels { 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 @@ public class CommissionLabels { 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 @@ public class CommissionLabels { 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 053f3536..dc40f82c 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 @@ public class CrystalsWaypoint extends Waypoint { @Override public boolean shouldRender() { - return super.shouldRender() ; + return super.shouldRender(); } @Override @@ -84,7 +84,7 @@ public class CrystalsWaypoint extends Waypoint { 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 1d7a4db8..dd97e5d1 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 @@ public class MetalDetector { } 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 7808bec3..4b0e2d7b 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 class MiningLocationLabels { 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 class MiningLocationLabels { 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 class MiningLocationLabels { } @Override - public float[] getColorComponents() { - return colorComponents; + public int getColor() { + return color; } - } } -- cgit From decdfbadbd3abd8bb4de617ef37add1dd03c8eee Mon Sep 17 00:00:00 2001 From: olim Date: Mon, 6 May 2024 15:04:07 +0100 Subject: add config options --- .../skyblock/dwarven/CommissionLabels.java | 35 +++--- .../skyblock/dwarven/MiningLocationLabel.java | 119 +++++++++++++++++++++ .../skyblock/dwarven/MiningLocationLabels.java | 116 -------------------- 3 files changed, 139 insertions(+), 131 deletions(-) create mode 100644 src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java delete mode 100644 src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabels.java (limited to 'src/main/java/de') 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 24b91780..9bdd2776 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 @@ 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())); + 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/MiningLocationLabel.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java new file mode 100644 index 00000000..ce5f5ccb --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java @@ -0,0 +1,119 @@ +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; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +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; + + 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(); + } + + 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)); + 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(); + + int getColor(); //all the color codes are the color of the block the waypoint is for + } + + enum dwarvenCategory implements Category { + LAVA_SPRINGS("Lava Springs", new BlockPos(60, 197, -15)), + CLIFFSIDE_VEINS("Cliffside Veins", new BlockPos(40, 128, 40)), + RAMPARTS_QUARRY("Rampart's Quarry", new BlockPos(-100, 150, -20)), + UPPER_MINES("Upper Mines", new BlockPos(-130, 174, -50)), + ROYAL_MINES("Royal Mines", new BlockPos(130, 154, 30)), + GLACITE_WALKER("Glacite Walker", new BlockPos(0, 128, 150)); + + + boolean isTitanium; + private final String name; + private final BlockPos location; + + dwarvenCategory(String name, BlockPos location) { + this.name = name; + this.location = location; + } + + public BlockPos getLocation() { + return location; + } + + @Override + public String toString() { + return name; + } + +