aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsWaypoint.java
diff options
context:
space:
mode:
authorAaron <51387595+AzureAaron@users.noreply.github.com>2024-02-04 12:49:53 -0500
committerGitHub <noreply@github.com>2024-02-04 12:49:53 -0500
commitfe1bc0589caef8ff9f2d616a3742e63e2668f00e (patch)
tree06e8e1b2ee3e3a9381dc042650f4fe6ac86582c5 /src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsWaypoint.java
parentce90376c4a8a934cc4d2f8bc4dd0e5e1c71b3748 (diff)
parent71467890a61eb4e05793b1856f6303787216f2ec (diff)
downloadSkyblocker-fe1bc0589caef8ff9f2d616a3742e63e2668f00e.tar.gz
Skyblocker-fe1bc0589caef8ff9f2d616a3742e63e2668f00e.tar.bz2
Skyblocker-fe1bc0589caef8ff9f2d616a3742e63e2668f00e.zip
Merge pull request #523 from olim88/crystal-hollows-fetures
Crystal hollows fetures
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsWaypoint.java')
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsWaypoint.java98
1 files changed, 98 insertions, 0 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsWaypoint.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsWaypoint.java
new file mode 100644
index 00000000..fbb43083
--- /dev/null
+++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsWaypoint.java
@@ -0,0 +1,98 @@
+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.entity.Entity;
+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.awt.*;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+import java.util.function.ToDoubleFunction;
+
+public class CrystalsWaypoint extends Waypoint {
+ private static final Supplier<SkyblockerConfig.Waypoints> CONFIG = () -> SkyblockerConfigManager.get().general.waypoints;
+ private static final Supplier<Type> TYPE_SUPPLIER = () -> CONFIG.get().waypointType;
+ final Category category;
+ final Text name;
+ private final Vec3d centerPos;
+
+ CrystalsWaypoint(Category category, Text name, BlockPos pos) {
+ super(pos, TYPE_SUPPLIER, category.colorComponents);
+ this.category = category;
+ this.name = name;
+ this.centerPos = pos.toCenterPos();
+ }
+
+ static ToDoubleFunction<CrystalsWaypoint> getSquaredDistanceToFunction(Entity entity) {
+ return crystalsWaypoint -> entity.squaredDistanceTo(crystalsWaypoint.centerPos);
+ }
+
+ static Predicate<CrystalsWaypoint> getRangePredicate(Entity entity) {
+ return crystalsWaypoint -> entity.squaredDistanceTo(crystalsWaypoint.centerPos) <= 36D;
+ }
+
+ @Override
+ public boolean shouldRender() {
+ return super.shouldRender() ;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return super.equals(obj) || obj instanceof CrystalsWaypoint other && category == other.category && 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);
+
+ }
+
+ /**
+ * enum for the different waypoints used int the crystals hud each with a {@link Category#name} and associated {@link Category#color}
+ */
+ enum 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;
+
+ Category(String name,Color color) {
+ this.name = name;
+ this.color = color;
+ this.colorComponents = color.getColorComponents(null);
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+ }
+}