Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: mark duplicate egg locations #1929

Merged
merged 10 commits into from
May 30, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ public class HoppityEggsConfig {
@FeatureToggle
public boolean showClaimedEggs = false;

@Expose
@ConfigOption(name = "Highlight Duplicate Egg Locations in Red", desc = "Marks egg locations which you have already found in red.")
appable0 marked this conversation as resolved.
Show resolved Hide resolved
@ConfigEditorBoolean
@FeatureToggle
public boolean highlightDuplicateEggLocations = false;

@Expose
@ConfigOption(name = "Show Nearby Duplicate Egg Locations", desc = "Always show duplicate eggs when nearby.")
appable0 marked this conversation as resolved.
Show resolved Hide resolved
@ConfigEditorBoolean
@FeatureToggle
public boolean showNearbyDuplicateEggLocations = false;

@Expose
@ConfigOption(name = "Warn When Unclaimed", desc = "Warn when all three eggs are ready to be found.")
@ConfigEditorBoolean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.config.storage;

import at.hannibal2.skyhanni.api.SkillAPI;
import at.hannibal2.skyhanni.data.IslandType;
import at.hannibal2.skyhanni.data.MaxwellAPI;
import at.hannibal2.skyhanni.data.model.ComposterUpgrade;
import at.hannibal2.skyhanni.features.combat.endernodetracker.EnderNodeTracker;
Expand Down Expand Up @@ -41,6 +42,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class ProfileSpecificStorage {

Expand Down Expand Up @@ -128,6 +130,9 @@ public static class PositionChange {
@Expose
public Map<String, Integer> rabbitCounts = new HashMap();

@Expose
public Map<IslandType, Set<LorenzVec>> collectedEggLocations = new HashMap();

@Expose
public Integer hoppityShopYearOpened = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactor
import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LocationUtils.distanceSqToPlayer
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.round
Expand Down Expand Up @@ -99,12 +101,14 @@ object HoppityEggLocator {
}
}
}

if (drawLocations) {
for ((index, eggLocation) in possibleEggLocations.withIndex()) {
val eggLabel = "§aGuess #${index + 1}"
var eggLabel = "§aGuess #${index + 1}"
if (shouldAddDuplicateText(eggLocation)) eggLabel += "§c(Duplicate Location!)"
event.drawWaypointFilled(
eggLocation,
LorenzColor.GREEN.toColor(),
getEggColor(eggLocation),
seeThroughBlocks = true,
)
event.drawDynamicText(eggLocation.add(y = 1), eggLabel, 1.5)
Expand All @@ -117,27 +121,53 @@ object HoppityEggLocator {

sharedEggLocation?.let {
if (config.sharedWaypoints) {
event.drawWaypointFilled(it, LorenzColor.GREEN.toColor(), seeThroughBlocks = true,)
var eggLabel = "§aShared Egg"
if (shouldAddDuplicateText(it)) eggLabel += "§c(Duplicate Location!)"
event.drawWaypointFilled(it, getEggColor(it), seeThroughBlocks = true,)
event.drawDynamicText(it.add(y = 1), "§aShared Egg", 1.5)
return
}
}

if (!config.showAllWaypoints) return
if (hasLocatorInHotbar()) return
if (!HoppityEggType.eggsRemaining()) return

val islandEggsLocations = getCurrentIslandEggLocations() ?: return
for (eggLocation in islandEggsLocations) {
event.drawWaypointFilled(
eggLocation,
LorenzColor.GREEN.toColor(),
seeThroughBlocks = true,
)
event.drawDynamicText(eggLocation.add(y = 1), "§aEgg", 1.5)

if (shouldShowAllEggs()) {
for (eggLocation in islandEggsLocations) {
var eggLabel = "§aEgg"
if (shouldAddDuplicateText(eggLocation)) eggLabel += "§c(Duplicate Location!)"
event.drawWaypointFilled(
eggLocation,
getEggColor(eggLocation),
seeThroughBlocks = true,
)
event.drawDynamicText(eggLocation.add(y = 1), eggLabel, 1.5)
}
} else if (config.highlightDuplicateEggLocations && config.showNearbyDuplicateEggLocations) {
for (eggLocation in islandEggsLocations) {
if (eggLocation.distanceSqToPlayer() < 100 && HoppityUniqueEggLocations.hasCollectedEgg(eggLocation)) {
event.drawWaypointFilled(
eggLocation,
LorenzColor.RED.toColor(),
seeThroughBlocks = true,
)
event.drawDynamicText(eggLocation.add(y = 1), "§cDuplicate Location!", 1.5)
}
}
}
}

private fun shouldAddDuplicateText(eggLocation: LorenzVec) =
config.highlightDuplicateEggLocations && HoppityUniqueEggLocations.hasCollectedEgg(eggLocation)

private fun shouldShowAllEggs() =
config.showAllWaypoints && !hasLocatorInHotbar() && HoppityEggType.eggsRemaining()

private fun getEggColor(location: LorenzVec) =
if (config.highlightDuplicateEggLocations && HoppityUniqueEggLocations.hasCollectedEgg(location)) {
LorenzColor.RED.toColor()
} else LorenzColor.GREEN.toColor()


fun eggFound() {
resetData()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ object HoppityEggsManager {
HoppityEggsCompactChat.handleChat(event)

eggFoundPattern.matchMatcher(event.message) {
HoppityUniqueEggLocations.saveNearestEgg()
HoppityEggLocator.eggFound()
val meal = getEggType(event)
val note = group("note").removeColor()
Expand Down
appable0 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package at.hannibal2.skyhanni.features.event.hoppity

import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI
import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LocationUtils.distanceSqToPlayer
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzVec
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

object HoppityUniqueEggLocations {

private val islandEggLocations: List<LorenzVec>?
get() = HoppityEggLocator.getCurrentIslandEggLocations()

private val collectedEggLocations
get() = ChocolateFactoryAPI.profileStorage?.collectedEggLocations

private fun getCurrentIslandCollectedEggs(): MutableSet<LorenzVec>? {
var currentSet = collectedEggLocations?.get(LorenzUtils.skyBlockIsland)
if (currentSet == null) {
currentSet = mutableSetOf<LorenzVec>()
collectedEggLocations?.set(LorenzUtils.skyBlockIsland, currentSet)
}
return currentSet
}

fun saveNearestEgg() {
val location = islandEggLocations?.minByOrNull { it.distanceSqToPlayer() } ?: return
if (location.distanceSqToPlayer() > 100) {
ChatUtils.debug("""
Player too far from any known egg location!
Player location: ${LocationUtils.playerLocation()}
Closest egg: $location
""".trimIndent())
appable0 marked this conversation as resolved.
Show resolved Hide resolved
return
}

val collectedEggs = getCurrentIslandCollectedEggs() ?: return
collectedEggs.add(location)
}

fun hasCollectedEgg(location: LorenzVec) =
getCurrentIslandCollectedEggs()?.contains(location) ?: false

}
Loading