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 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; + } + + @Override + public String getName() { + return name; + } + + @Override + public int getColor() { + if (isTitanium) { + return 0xd8d6d8; + } + return 0x45bde0; + } + } + + enum glaciteCategory implements Category { + AQUAMARINE("Aquamarine", 0x334cb1, new BlockPos[]{new BlockPos(-1, 139, 437), new BlockPos(90, 151, 229), new BlockPos(56, 151, 400), new BlockPos(51, 117, 303)}), + ONYX("Onyx", 0x191919, new BlockPos[]{new BlockPos(79, 119, 411), new BlockPos(-14, 132, 386), new BlockPos(18, 136, 370), new BlockPos(16, 138, 411), new BlockPos(-68, 130, 408)}), + PERIDOT("Peridot", 0x667f33, new BlockPos[]{new BlockPos(-61, 147, 302), new BlockPos(91, 122, 397), new BlockPos(-73, 122, 458), new BlockPos(-77, 120, 282)}), + CITRINE("Citrine", 0x664c33, new BlockPos[]{new BlockPos(-104, 144, 244), new BlockPos(39, 119, 386), new BlockPos(-57, 144, 421), new BlockPos(-47, 126, 418)}), + CAMPFIRE("Base Camp", 0x983333, new BlockPos[]{new BlockPos(-7, 126, 229)}); + + private final String name; + private final int color; + private final BlockPos[] location; + + glaciteCategory(String name, int color, BlockPos[] location) { + this.name = name; + this.color = color; + this.location = location; + } + + public BlockPos[] getLocations() { + return location; + } + + @Override + public String toString() { + return name; + } + + @Override + public String getName() { + return name; + } + + @Override + public int getColor() { + return color; + } + } +} diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabels.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabels.java deleted file mode 100644 index 4b0e2d7b..00000000 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabels.java +++ /dev/null @@ -1,116 +0,0 @@ -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, BlockPos pos) { - this.name = Text.literal(category.getName()).withColor(category.getColor()); - 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(); - - int getColor(); //all the color codes are the color of the block the waypoint is for - } - - enum dwarvenCategory implements Category { - LAVA_SPRINGS("Lava Springs", new BlockPos(60, 197, -15)), - CLIFFSIDE_VEINS("Cliffside Veins", new BlockPos(40, 128, 40)), - RAMPARTS_QUARRY("Rampart's Quarry", new BlockPos(-100, 150, -20)), - UPPER_MINES("Upper Mines", new BlockPos(-130, 174, -50)), - ROYAL_MINES("Royal Mines", new BlockPos(130, 154, 30)), - GLACITE_WALKER("Glacite Walker", new BlockPos(0, 128, 150)); - - - boolean isTitanium; - private final String name; - private final BlockPos location; - - dwarvenCategory(String name, BlockPos location) { - this.name = name; - this.location = location; - } - - public BlockPos getLocation() { - return location; - } - - @Override - public String toString() { - return name; - } - - @Override - public String getName() { - return name; - } - - @Override - public int getColor() { - if (isTitanium) { - return 0xd8d6d8; - } - return 0x45bde0; - } - } - - enum 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)}); - - private final String name; - private final int color; - private final BlockPos[] location; - - glaciteCategory(String name, int color, BlockPos[] location) { - this.name = name; - this.color = color; - this.location = location; - } - - - - public BlockPos[] getLocations() { - return location; - } - - @Override - public String toString() { - return name; - } - - @Override - public String getName() { - return name; - } - - @Override - public int getColor() { - return color; - } - } -} -- cgit