diff options
Diffstat (limited to 'src')
14 files changed, 203 insertions, 88 deletions
diff --git a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java index ad3b6318..cbe82667 100644 --- a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java +++ b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java @@ -5,7 +5,7 @@ import com.google.gson.GsonBuilder; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.debug.Debug; import de.hysky.skyblocker.skyblock.*; -import de.hysky.skyblocker.skyblock.diana.MythologicalRitual; +import de.hysky.skyblocker.skyblock.waypoint.MythologicalRitual; import de.hysky.skyblocker.skyblock.dungeon.*; import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonSecrets; import de.hysky.skyblocker.skyblock.dungeon.secrets.SecretsTracker; @@ -18,10 +18,11 @@ import de.hysky.skyblocker.skyblock.quicknav.QuickNav; import de.hysky.skyblocker.skyblock.rift.TheRift; import de.hysky.skyblocker.skyblock.shortcut.Shortcuts; import de.hysky.skyblocker.skyblock.special.SpecialEffects; -import de.hysky.skyblocker.skyblock.spidersden.Relics; +import de.hysky.skyblocker.skyblock.waypoint.Relics; import de.hysky.skyblocker.skyblock.tabhud.TabHud; import de.hysky.skyblocker.skyblock.tabhud.screenbuilder.ScreenMaster; import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; +import de.hysky.skyblocker.skyblock.waypoint.FairySouls; import de.hysky.skyblocker.utils.ApiUtils; import de.hysky.skyblocker.utils.NEURepoManager; import de.hysky.skyblocker.utils.Utils; diff --git a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java index 6f3a8e4a..59203269 100644 --- a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java @@ -189,6 +189,9 @@ public class SkyblockerConfig { public Shortcuts shortcuts = new Shortcuts(); @SerialEntry + public Waypoints waypoints = new Waypoints(); + + @SerialEntry public QuiverWarning quiverWarning = new QuiverWarning(); @SerialEntry @@ -254,8 +257,8 @@ public class SkyblockerConfig { @Override public String toString() { return switch (this) { - case DEFAULT -> "Default"; - case ALPHABETICAL -> "Alphabetical"; + case DEFAULT -> "Default"; + case ALPHABETICAL -> "Alphabetical"; }; } } @@ -293,10 +296,10 @@ public class SkyblockerConfig { public int toInt() { return switch (this) { - case LAYER1 -> 0; - case LAYER2 -> 1; - case RIGHT -> 2; - case NONE -> -1; + case LAYER1 -> 0; + case LAYER2 -> 1; + case RIGHT -> 2; + case NONE -> -1; }; } } @@ -349,6 +352,14 @@ public class SkyblockerConfig { public boolean enableCommandArgShortcuts = true; } + public static class Waypoints { + @SerialEntry + public boolean enableWaypoints = true; + + @SerialEntry + public Waypoint.Type waypointType = Waypoint.Type.WAYPOINT; + } + public static class QuiverWarning { @SerialEntry public boolean enableQuiverWarning = true; @@ -419,8 +430,8 @@ public class SkyblockerConfig { @Override public String toString() { return switch (this) { - case HORIZONTAL -> "Horizontal"; - case VERTICAL -> "Vertical"; + case HORIZONTAL -> "Horizontal"; + case VERTICAL -> "Vertical"; }; } } @@ -431,9 +442,9 @@ public class SkyblockerConfig { @Override public String toString() { return switch (this) { - case LEFT -> "Left"; - case RIGHT -> "Right"; - case MIDDLE -> "Middle"; + case LEFT -> "Left"; + case RIGHT -> "Right"; + case MIDDLE -> "Middle"; }; } } @@ -515,7 +526,7 @@ public class SkyblockerConfig { public final Identifier tex; - private RarityBackgroundStyle(Identifier tex) { + RarityBackgroundStyle(Identifier tex) { this.tex = tex; } @@ -743,9 +754,9 @@ public class SkyblockerConfig { @Override public String toString() { return switch (this) { - case SIMPLE -> "Simple"; - case FANCY -> "Fancy"; - case CLASSIC -> "Classic"; + case SIMPLE -> "Simple"; + case FANCY -> "Fancy"; + case CLASSIC -> "Classic"; }; } } diff --git a/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java index 007d974c..7bb6414c 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java @@ -45,8 +45,8 @@ public class DungeonsCategory { .flag(OptionFlag.GAME_RESTART) .build()) .option(Option.<Type>createBuilder() - .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.waypointType")) - .description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.waypointType.@Tooltip"))) + .name(Text.translatable("text.autoconfig.skyblocker.option.general.waypoints.waypointType")) + .description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.general.waypoints.waypointType.@Tooltip"))) .binding(defaults.locations.dungeons.secretWaypoints.waypointType, () -> config.locations.dungeons.secretWaypoints.waypointType, newValue -> config.locations.dungeons.secretWaypoints.waypointType = newValue) diff --git a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java index 7e7a91fd..0f49be7b 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java @@ -4,6 +4,7 @@ import de.hysky.skyblocker.config.ConfigUtils; import de.hysky.skyblocker.config.SkyblockerConfig; import de.hysky.skyblocker.skyblock.shortcut.ShortcutsConfigScreen; import de.hysky.skyblocker.utils.render.title.TitleContainerConfigScreen; +import de.hysky.skyblocker.utils.waypoint.Waypoint; import dev.isxander.yacl3.api.*; import dev.isxander.yacl3.api.controller.FloatFieldControllerBuilder; import dev.isxander.yacl3.api.controller.FloatSliderControllerBuilder; @@ -261,6 +262,27 @@ public class GeneralCategory { .build()) .build()) + //Waypoints + .group(OptionGroup.createBuilder() + .name(Text.translatable("text.autoconfig.skyblocker.option.general.waypoints")) + .collapsed(true) + .option(Option.<Boolean>createBuilder() + .name(Text.translatable("text.autoconfig.skyblocker.option.general.waypoints.enableWaypoints")) + .binding(defaults.general.waypoints.enableWaypoints, + () -> config.general.waypoints.enableWaypoints, + newValue -> config.general.waypoints.enableWaypoints = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) + .option(Option.<Waypoint.Type>createBuilder() + .name(Text.translatable("text.autoconfig.skyblocker.option.general.waypoints.waypointType")) + .description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.general.waypoints.waypointType.@Tooltip"))) + .binding(defaults.general.waypoints.waypointType, + () -> config.general.waypoints.waypointType, + newValue -> config.general.waypoints.waypointType = newValue) + .controller(ConfigUtils::createEnumCyclingListController) + .build()) + .build()) + //Quiver Warning .group(OptionGroup.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.quiverWarning")) diff --git a/src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java b/src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java index f68a4e94..384986ae 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java @@ -3,7 +3,7 @@ package de.hysky.skyblocker.mixin; import com.llamalad7.mixinextras.injector.WrapWithCondition; import com.llamalad7.mixinextras.sugar.Local; import de.hysky.skyblocker.skyblock.FishingHelper; -import de.hysky.skyblocker.skyblock.diana.MythologicalRitual; +import de.hysky.skyblocker.skyblock.waypoint.MythologicalRitual; import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonSecrets; import de.hysky.skyblocker.utils.Utils; import dev.cbyrne.betterinject.annotations.Inject; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/Trivia.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/Trivia.java index 262d4a4e..53368c14 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/Trivia.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/Trivia.java @@ -1,7 +1,7 @@ package de.hysky.skyblocker.skyblock.dungeon; import de.hysky.skyblocker.config.SkyblockerConfigManager; -import de.hysky.skyblocker.skyblock.FairySouls; +import de.hysky.skyblocker.skyblock.waypoint.FairySouls; import de.hysky.skyblocker.utils.chat.ChatFilterResult; import de.hysky.skyblocker.utils.chat.ChatPatternListener; import net.minecraft.client.MinecraftClient; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/FairySouls.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/FairySouls.java index e9bc3ebd..c3cd6fe2 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/FairySouls.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/FairySouls.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.skyblock; +package de.hysky.skyblocker.skyblock.waypoint; import com.google.gson.JsonArray; import com.google.gson.JsonElement; @@ -13,6 +13,8 @@ import de.hysky.skyblocker.utils.NEURepoManager; import de.hysky.skyblocker.utils.PosUtils; import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.render.RenderHelper; +import de.hysky.skyblocker.utils.waypoint.ProfileAwareWaypoint; +import de.hysky.skyblocker.utils.waypoint.Waypoint; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; @@ -29,21 +31,24 @@ import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.*; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.NoSuchFileException; import java.util.*; import java.util.concurrent.CompletableFuture; +import java.util.function.Supplier; import java.util.stream.Collectors; import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; public class FairySouls { private static final Logger LOGGER = LoggerFactory.getLogger(FairySouls.class); + private static final Supplier<Waypoint.Type> TYPE_SUPPLIER = () -> SkyblockerConfigManager.get().general.waypoints.waypointType; private static CompletableFuture<Void> fairySoulsLoaded; private static int maxSouls = 0; - private static final Map<String, Set<BlockPos>> fairySouls = new HashMap<>(); - private static final Map<String, Map<String, Set<BlockPos>>> foundFairies = new HashMap<>(); + private static final Map<String, Map<BlockPos, ProfileAwareWaypoint>> fairySouls = new HashMap<>(); @SuppressWarnings("UnusedReturnValue") public static CompletableFuture<Void> runAsyncAfterFairySoulsLoad(Runnable runnable) { @@ -69,32 +74,41 @@ public class FairySouls { private static void loadFairySouls() { fairySoulsLoaded = NEURepoManager.runAsyncAfterLoad(() -> { maxSouls = NEURepoManager.NEU_REPO.getConstants().getFairySouls().getMaxSouls(); - NEURepoManager.NEU_REPO.getConstants().getFairySouls().getSoulLocations().forEach((location, fairySoulsForLocation) -> fairySouls.put(location, fairySoulsForLocation.stream().map(coordinate -> new BlockPos(coordinate.getX(), coordinate.getY(), coordinate.getZ())).collect(Collectors.toUnmodifiableSet()))); - LOGGER.debug("[Skyblocker] Loaded {} fairy souls across {} locations", fairySouls.values().stream().mapToInt(Set::size).sum(), fairySouls.size()); + NEURepoManager.NEU_REPO.getConstants().getFairySouls().getSoulLocations().forEach((location, fairiesForLocation) -> fairySouls.put(location, fairiesForLocation.stream().map(coordinate -> new BlockPos(coordinate.getX(), coordinate.getY(), coordinate.getZ())).collect(Collectors.toUnmodifiableMap(pos -> pos, pos -> new ProfileAwareWaypoint(pos, TYPE_SUPPLIER, DyeColor.GREEN.getColorComponents(), DyeColor.RED.getColorComponents()))))); + LOGGER.debug("[Skyblocker] Loaded {} fairy souls across {} locations", fairySouls.values().stream().mapToInt(Map::size).sum(), fairySouls.size()); try (BufferedReader reader = Files.newBufferedReader(SkyblockerMod.CONFIG_DIR.resolve("found_fairy_souls.json"))) { for (Map.Entry<String, JsonElement> foundFairiesForProfileJson : JsonParser.parseReader(reader).getAsJsonObject().asMap().entrySet()) { - Map<String, Set<BlockPos>> foundFairiesForProfile = new HashMap<>(); for (Map.Entry<String, JsonElement> foundFairiesForLocationJson : foundFairiesForProfileJson.getValue().getAsJsonObject().asMap().entrySet()) { - Set<BlockPos> foundFairiesForLocation = new HashSet<>(); + String profile = foundFairiesForLocationJson.getKey(); + Map<BlockPos, ProfileAwareWaypoint> fairiesForLocation = fairySouls.get(profile); for (JsonElement foundFairy : foundFairiesForLocationJson.getValue().getAsJsonArray().asList()) { - foundFairiesForLocation.add(PosUtils.parsePosString(foundFairy.getAsString())); + fairiesForLocation.get(PosUtils.parsePosString(foundFairy.getAsString())).setFound(profile); } - foundFairiesForProfile.put(foundFairiesForLocationJson.getKey(), foundFairiesForLocation); } - foundFairies.put(foundFairiesForProfileJson.getKey(), foundFairiesForProfile); } LOGGER.debug("[Skyblocker] Loaded found fairy souls"); } catch (NoSuchFileException ignored) { } catch (IOException e) { LOGGER.error("[Skyblocker] Failed to load found fairy souls", e); } - LOGGER.info("[Skyblocker] Loaded {} fairy souls across {} locations and {} found fairy souls across {} locations in {} profiles", fairySouls.values().stream().mapToInt(Set::size).sum(), fairySouls.size(), foundFairies.values().stream().map(Map::values).flatMap(Collection::stream).mapToInt(Set::size).sum(), foundFairies.values().stream().mapToInt(Map::size).sum(), foundFairies.size()); + LOGGER.info("[Skyblocker] Loaded {} fairy souls across {} locations", fairySouls.values().stream().mapToInt(Map::size).sum(), fairySouls.size()); }); } private static void saveFoundFairySouls(MinecraftClient client) { try (BufferedWriter writer = Files.newBufferedWriter(SkyblockerMod.CONFIG_DIR.resolve("found_fairy_souls.json"))) { + Map<String, Map<String, Set<BlockPos>>> foundFairies = new HashMap<>(); + for (Map.Entry<String, Map<BlockPos, ProfileAwareWaypoint>> fairiesForLocation : fairySouls.entrySet()) { + for (ProfileAwareWaypoint fairySoul : fairiesForLocation.getValue().values()) { + for (String profile : fairySoul.foundProfiles) { + foundFairies.putIfAbsent(profile, new HashMap<>()); + foundFairies.get(profile).putIfAbsent(fairiesForLocation.getKey(), new HashSet<>()); + foundFairies.get(profile).get(fairiesForLocation.getKey()).add(fairySoul.pos); + } + } + } + JsonObject foundFairiesJson = new JsonObject(); for (Map.Entry<String, Map<String, Set<BlockPos>>> foundFairiesForProfile : foundFairies.entrySet()) { JsonObject foundFairiesForProfileJson = new JsonObject(); @@ -133,13 +147,13 @@ public class FairySouls { SkyblockerConfig.FairySouls fairySoulsConfig = SkyblockerConfigManager.get().general.fairySouls; if (fairySoulsConfig.enableFairySoulsHelper && fairySoulsLoaded.isDone() && fairySouls.containsKey(Utils.getLocationRaw())) { - for (BlockPos fairySoulPos : fairySouls.get(Utils.getLocationRaw())) { - boolean fairySoulNotFound = isFairySoulMissing(fairySoulPos); - if (!fairySoulsConfig.highlightFoundSouls && !fairySoulNotFound || fairySoulsConfig.highlightOnlyNearbySouls && fairySoulPos.getSquaredDistance(context.camera().getPos()) > 2500) { + for (Waypoint fairySoul : fairySouls.get(Utils.getLocationRaw()).values()) { + boolean fairySoulNotFound = fairySoul.shouldRender(); + if (!fairySoulsConfig.highlightFoundSouls && !fairySoulNotFound || fairySoulsConfig.highlightOnlyNearbySouls && fairySoul.pos.getSquaredDistance(context.camera().getPos()) > 2500) { continue; } float[] colorComponents = fairySoulNotFound ? DyeColor.GREEN.getColorComponents() : DyeColor.RED.getColorComponents(); - RenderHelper.renderFilledThroughWallsWithBeaconBeam(context, fairySoulPos, colorComponents, 0.5F); + RenderHelper.renderFilledThroughWallsWithBeaconBeam(context, fairySoul.pos, colorComponents, 0.5F); } } } @@ -160,54 +174,30 @@ public class FairySouls { return; } - Set<BlockPos> fairiesOnCurrentIsland = fairySouls.get(Utils.getLocationRaw()); + Map<BlockPos, ProfileAwareWaypoint> fairiesOnCurrentIsland = fairySouls.get(Utils.getLocationRaw()); if (fairiesOnCurrentIsland == null) { LOGGER.warn("[Skyblocker] Failed to mark closest fairy soul as found because there are no fairy souls loaded on the current island. NEU repo probably failed to load."); return; } - fairiesOnCurrentIsland.stream() - .filter(FairySouls::isFairySoulMissing) - .min(Comparator.comparingDouble(fairySoulPos -> fairySoulPos.getSquaredDistance(player.getPos()))) - .filter(fairySoulPos -> fairySoulPos.getSquaredDistance(player.getPos()) <= 16) - .ifPresent(fairySoulPos -> { - initializeFoundFairiesForCurrentProfileAndLocation(); - foundFairies.get(Utils.getProfile()).get(Utils.getLocationRaw()).add(fairySoulPos); - }); - } - - private static boolean isFairySoulMissing(BlockPos fairySoulPos) { - Map<String, Set<BlockPos>> foundFairiesForProfile = foundFairies.get(Utils.getProfile()); - if (foundFairiesForProfile == null) { - return true; - } - Set<BlockPos> foundFairiesForProfileAndLocation = foundFairiesForProfile.get(Utils.getLocationRaw()); - if (foundFairiesForProfileAndLocation == null) { - return true; - } - return !foundFairiesForProfileAndLocation.contains(fairySoulPos); + fairiesOnCurrentIsland.values().stream() + .filter(Waypoint::shouldRender) + .min(Comparator.comparingDouble(fairySoul -> fairySoul.pos.getSquaredDistance(player.getPos()))) + .filter(fairySoul -> fairySoul.pos.getSquaredDistance(player.getPos()) <= 16) + .ifPresent(ProfileAwareWaypoint::setFound); } public static void markAllFairiesOnCurrentIslandFound() { - if (fairySouls.get(Utils.getLocationRaw()) != null) { - initializeFoundFairiesForCurrentProfileAndLocation(); - foundFairies.get(Utils.getProfile()).get(Utils.getLocationRaw()).addAll(fairySouls.get(Utils.getLocationRaw())); + Map<BlockPos, ProfileAwareWaypoint> fairiesForLocation = fairySouls.get(Utils.getLocationRaw()); + if (fairiesForLocation != null) { + fairiesForLocation.values().forEach(ProfileAwareWaypoint::setFound); } } public static void markAllFairiesOnCurrentIslandMissing() { - Map<String, Set<BlockPos>> foundFairiesForProfile = foundFairies.get(Utils.getProfile()); - if (foundFairiesForProfile != null) { - foundFairiesForProfile.remove(Utils.getLocationRaw()); + Map<BlockPos, ProfileAwareWaypoint> fairiesForLocation = fairySouls.get(Utils.getLocationRaw()); + if (fairiesForLocation != null) { + fairiesForLocation.values().forEach(ProfileAwareWaypoint::setMissing); } } - - private static void initializeFoundFairiesForCurrentProfileAndLocation() { - initializeFoundFairiesForProfileAndLocation(Utils.getProfile(), Utils.getLocationRaw()); - } - - private static void initializeFoundFairiesForProfileAndLocation(String profile, String location) { - foundFairies.computeIfAbsent(profile, profileKey -> new HashMap<>()); - foundFairies.get(profile).computeIfAbsent(location, locationKey -> new HashSet<>()); - } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/diana/MythologicalRitual.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/MythologicalRitual.java index f36a8a24..5b5f4715 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/diana/MythologicalRitual.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/MythologicalRitual.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.skyblock.diana; +package de.hysky.skyblocker.skyblock.waypoint; import com.mojang.brigadier.Command; import de.hysky.skyblocker.SkyblockerMod; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/spidersden/Relics.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/Relics.java index df68c57b..f25b7497 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/spidersden/Relics.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/Relics.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.skyblock.spidersden; +package de.hysky.skyblocker.skyblock.waypoint; import com.google.gson.JsonArray; import com.google.gson.JsonElement; diff --git a/src/main/java/de/hysky/skyblocker/utils/waypoint/ProfileAwareWaypoint.java b/src/main/java/de/hysky/skyblocker/utils/waypoint/ProfileAwareWaypoint.java new file mode 100644 index 00000000..7aa99d14 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/utils/waypoint/ProfileAwareWaypoint.java @@ -0,0 +1,44 @@ +package de.hysky.skyblocker.utils.waypoint; + +import de.hysky.skyblocker.utils.Utils; +import net.minecraft.util.math.BlockPos; + +import java.util.HashSet; +import java.util.Set; +import java.util.function.Supplier; + +public class ProfileAwareWaypoint extends Waypoint { + public final Set<String> foundProfiles = new HashSet<>(); + private final float[] missingColor; + private final float[] foundColor; + + public ProfileAwareWaypoint(BlockPos pos, Supplier<Type> typeSupplier, float[] missingColor, float[] foundColor) { + super(pos, typeSupplier, null); + this.missingColor = missingColor; + this.foundColor = foundColor; + } + + @Override + public boolean shouldRender() { + return !foundProfiles.contains(Utils.getProfile()); + } + + @Override + public void setFound() { + foundProfiles.add(Utils.getProfile()); + } + + public void setFound(String profile) { + foundProfiles.add(profile); + } + + @Override + public void setMissing() { + foundProfiles.remove(Utils.getProfile()); + } + + @Override + protected float[] getColorComponents() { + return foundProfiles.contains(Utils.getProfile()) ? foundColor : missingColor; + } +} diff --git a/src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java b/src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java index a8e62a94..f65e20f7 100644 --- a/src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java +++ b/src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java @@ -62,19 +62,25 @@ public class Waypoint { this.shouldRender = true; } + protected float[] getColorComponents() { + return colorComponents; + } + public void render(WorldRenderContext context) { switch (typeSupplier.get()) { - case WAYPOINT -> RenderHelper.renderFilledThroughWallsWithBeaconBeam(context, pos, colorComponents, alpha); + case WAYPOINT -> RenderHelper.renderFilledThroughWallsWithBeaconBeam(context, pos, getColorComponents(), alpha); case OUTLINED_WAYPOINT -> { + float[] colorComponents = getColorComponents(); RenderHelper.renderFilledThroughWallsWithBeaconBeam(context, pos, colorComponents, alpha); RenderHelper.renderOutline(context, box, colorComponents, lineWidth, throughWalls); } - case HIGHLIGHT -> RenderHelper.renderFilledThroughWalls(context, pos, colorComponents, alpha); + case HIGHLIGHT -> RenderHelper.renderFilledThroughWalls(context, pos, getColorComponents(), alpha); case OUTLINED_HIGHLIGHT -> { + float[] colorComponents = getColorComponents(); RenderHelper.renderFilledThroughWalls(context, pos, colorComponents, alpha); RenderHelper.renderOutline(context, box, colorComponents, lineWidth, throughWalls); } - case OUTLINE -> RenderHelper.renderOutline(context, box, colorComponents, lineWidth, throughWalls); + case OUTLINE -> RenderHelper.renderOutline(context, box, getColorComponents(), lineWidth, throughWalls); } } diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 063b7255..1cba3f80 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -50,6 +50,10 @@ "text.autoconfig.skyblocker.option.general.shortcuts.enableCommandArgShortcuts": "Enable Command Argument Shortcuts", "text.autoconfig.skyblocker.option.general.shortcuts.enableCommandArgShortcuts.@Tooltip": "Shortcuts that replace one or more word(s)/argument(s) of a command which has multiple words/arguments. Edit shortcuts with \"/skyblocker shortcuts\". Shortcuts must be enabled for this to take effect.", "text.autoconfig.skyblocker.option.general.shortcuts.config": "Shortcuts Config...", + "text.autoconfig.skyblocker.option.general.waypoints": "Waypoints", + "text.autoconfig.skyblocker.option.general.waypoints.enableWaypoints": "Enable Waypoints", + "text.autoconfig.skyblocker.option.general.waypoints.waypointType": "Waypoint Type", + "text.autoconfig.skyblocker.option.general.waypoints.waypointType.@Tooltip": "Waypoint: Displays a highlight and beam.\n\nOutlined Waypoint: Displays both a waypoint and an outline.\n\nHighlight: Only displays a highlight.\n\nOutlined Highlight: Displays both a highlight and an outline.\n\nOutline: Outlines the secret in a box.", "text.autoconfig.skyblocker.option.general.quiverWarning": "Quiver Warning", "text.autoconfig.skyblocker.option.general.quiverWarning.enableQuiverWarning": "Enable Quiver Warning", "text.autoconfig.skyblocker.option.general.quiverWarning.enableQuiverWarningInDungeons": "Enable Quiver Warning In Dungeons", @@ -156,8 +160,6 @@ "text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.enableSecretWaypoints": "Enable Dungeon Secret Waypoints", "text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.noInitSecretWaypoints": "Do Not Initialize Secret Waypoints", "text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.noInitSecretWaypoints.@Tooltip": "This option can save around 20 MB of ram if enabled, but Secret Waypoint will require a restart after turning off this option to work.", - "text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.waypointType": "Waypoint Type", - "text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.waypointType.@Tooltip": "Waypoint: Displays a highlight and beam.\n\nOutlined Waypoint: Displays both a waypoint and an outline.\n\nHighlight: Only displays a highlight.\n\nOutlined Highlight: Displays both a highlight and an outline.\n\nOutline: Outlines the secret in a box.", "text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.showSecretText": "Show Secret Text", "text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.enableEntranceWaypoints" : "Enable Entrance Waypoints", "text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.enableSuperboomWaypoints" : "Enable Superboom Waypoints", diff --git a/src/test/java/de/hysky/skyblocker/utils/waypoint/ProfileAwareWaypointTest.java b/src/test/java/de/hysky/skyblocker/utils/waypoint/ProfileAwareWaypointTest.java new file mode 100644 index 00000000..9dc5b2b9 --- /dev/null +++ b/src/test/java/de/hysky/skyblocker/utils/waypoint/ProfileAwareWaypointTest.java @@ -0,0 +1,38 @@ +package de.hysky.skyblocker.utils.waypoint; + +import net.minecraft.util.math.BlockPos; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class ProfileAwareWaypointTest { + @Test + void testShouldRender() { + ProfileAwareWaypoint waypoint = new ProfileAwareWaypoint(BlockPos.ORIGIN, null, null, null); + waypoint.setFound("profile"); + Assertions.assertTrue(waypoint.shouldRender()); + waypoint.setFound(""); + Assertions.assertFalse(waypoint.shouldRender()); + waypoint.setMissing(); + Assertions.assertTrue(waypoint.shouldRender()); + } + + @Test + void testGetColorComponents() { + ProfileAwareWaypoint waypoint = new ProfileAwareWaypoint(BlockPos.ORIGIN, null, new float[]{0f, 0.5f, 1f}, new float[]{1f, 0.5f, 0f}); + waypoint.setFound("profile"); + float[] colorComponents = waypoint.getColorComponents(); + Assertions.assertEquals(0f, colorComponents[0]); + Assertions.assertEquals(0.5f, colorComponents[1]); + Assertions.assertEquals(1f, colorComponents[2]); + waypoint.setFound(""); + colorComponents = waypoint.getColorComponents(); + Assertions.assertEquals(1f, colorComponents[0]); + Assertions.assertEquals(0.5f, colorComponents[1]); + Assertions.assertEquals(0f, colorComponents[2]); + waypoint.setMissing(); + colorComponents = waypoint.getColorComponents(); + Assertions.assertEquals(0f, colorComponents[0]); + Assertions.assertEquals(0.5f, colorComponents[1]); + Assertions.assertEquals(1f, colorComponents[2]); + } +} diff --git a/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointTest.java b/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointTest.java index 41f5a530..b3be64b7 100644 --- a/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointTest.java +++ b/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointTest.java @@ -7,10 +7,11 @@ import org.junit.jupiter.api.Test; public class WaypointTest { private Waypoint.Type type; + private final float[] colorComponents = new float[]{0f, 0.5f, 1f}; @Test void testDefaultConstructor() { - Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, new float[]{0f, 0.5f, 1f}); + Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents); Assertions.assertEquals(BlockPos.ORIGIN, waypoint.pos); Assertions.assertEquals(new Box(BlockPos.ORIGIN), waypoint.box); Assertions.assertEquals(type, waypoint.typeSupplier.get()); @@ -25,37 +26,37 @@ public class WaypointTest { @Test void testTypeConstructor() { - Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, Waypoint.Type.WAYPOINT, new float[]{0, 0, 0}, Waypoint.DEFAULT_HIGHLIGHT_ALPHA); + Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, Waypoint.Type.WAYPOINT, colorComponents, Waypoint.DEFAULT_HIGHLIGHT_ALPHA); Assertions.assertEquals(Waypoint.Type.WAYPOINT, waypoint.typeSupplier.get()); } @Test void testAlphaConstructor() { - Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, new float[]{0, 0, 0}, 1f); + Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents, 1f); Assertions.assertEquals(1f, waypoint.alpha); } @Test void testLineWidthConstructor() { - Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, new float[]{0, 0, 0}, Waypoint.DEFAULT_HIGHLIGHT_ALPHA, 10f); + Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents, Waypoint.DEFAULT_HIGHLIGHT_ALPHA, 10f); Assertions.assertEquals(10f, waypoint.lineWidth); } @Test void testThroughWallsConstructor() { - Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, new float[]{0, 0, 0}, Waypoint.DEFAULT_HIGHLIGHT_ALPHA, Waypoint.DEFAULT_LINE_WIDTH, false); + Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents, Waypoint.DEFAULT_HIGHLIGHT_ALPHA, Waypoint.DEFAULT_LINE_WIDTH, false); Assertions.assertFalse(waypoint.throughWalls); } @Test void testShouldRenderConstructor() { - Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, new float[]{0, 0, 0}, Waypoint.DEFAULT_HIGHLIGHT_ALPHA, Waypoint.DEFAULT_LINE_WIDTH, true, false); + Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents, Waypoint.DEFAULT_HIGHLIGHT_ALPHA, Waypoint.DEFAULT_LINE_WIDTH, true, false); Assertions.assertFalse(waypoint.shouldRender()); } @Test void testFound() { - Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, new float[]{0, 0, 0}); + Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents); Assertions.assertTrue(waypoint.shouldRender()); waypoint.setFound(); Assertions.assertFalse(waypoint.shouldRender()); @@ -65,7 +66,7 @@ public class WaypointTest { @Test void testType() { - Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, new float[]{0, 0, 0}); + Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents); Assertions.assertEquals(type, waypoint.typeSupplier.get()); type = Waypoint.Type.WAYPOINT; Assertions.assertEquals(type, waypoint.typeSupplier.get()); |