aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2024-05-04 20:10:39 +1000
committerGitHub <noreply@github.com>2024-05-04 12:10:39 +0200
commit827037fe460ae52a277fd97f1a04f5066e474a8c (patch)
tree2603a8648d222b12d0333dbe6055a3e97c7dc1af /src/main/java/at
parent8b170c0dd2685358bb00cd73da06063cdb011961 (diff)
downloadskyhanni-827037fe460ae52a277fd97f1a04f5066e474a8c.tar.gz
skyhanni-827037fe460ae52a277fd97f1a04f5066e474a8c.tar.bz2
skyhanni-827037fe460ae52a277fd97f1a04f5066e474a8c.zip
Fix: Some cases where egg locator solver would trigger incorrectly (#1689)
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt7
2 files changed, 12 insertions, 9 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt
index 8b6ce2ad3..9d11d8b62 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt
@@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.ReceiveParticleEvent
+import at.hannibal2.skyhanni.features.fame.ReminderUtils
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI
import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
@@ -116,7 +117,7 @@ object HoppityEggLocator {
}
if (!config.showAllWaypoints) return
- if (hasLocatorInInventory()) return
+ if (hasLocatorInHotbar()) return
if (!HoppityEggType.eggsRemaining()) return
val islandEggsLocations = getCurrentIslandEggLocations() ?: return
@@ -137,8 +138,7 @@ object HoppityEggLocator {
@SubscribeEvent
fun onReceiveParticle(event: ReceiveParticleEvent) {
if (!isEnabled()) return
- if (!hasLocatorInInventory()) return
- if (GardenAPI.inGarden()) return
+ if (!hasLocatorInHotbar()) return
if (!event.isVillagerParticle() && !event.isEnchantmentParticle()) return
val lastParticlePosition = lastParticlePosition ?: run {
@@ -231,13 +231,13 @@ object HoppityEggLocator {
private fun ReceiveParticleEvent.isEnchantmentParticle() =
type == EnumParticleTypes.ENCHANTMENT_TABLE && speed == -2.0f && count == 10
- private fun isEnabled() = LorenzUtils.inSkyBlock && config.waypoints
- && ChocolateFactoryAPI.isHoppityEvent()
+ private fun isEnabled() = LorenzUtils.inSkyBlock && config.waypoints && !GardenAPI.inGarden()
+ && !ReminderUtils.isBusy(true) && ChocolateFactoryAPI.isHoppityEvent()
private val ItemStack.isLocatorItem get() = getInternalName() == locatorItem
- fun hasLocatorInInventory() = RecalculatingValue(1.seconds) {
- LorenzUtils.inSkyBlock && InventoryUtils.getItemsInOwnInventory().any { it.isLocatorItem }
+ fun hasLocatorInHotbar() = RecalculatingValue(1.seconds) {
+ LorenzUtils.inSkyBlock && InventoryUtils.getItemsInHotbar().any { it.isLocatorItem }
}.getValue()
private fun LorenzVec.getEggLocationWeight(firstPoint: LorenzVec, secondPoint: LorenzVec): Double {
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt
index 69ca8fc59..f72be2a3a 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt
@@ -37,9 +37,12 @@ object InventoryUtils {
fun ContainerChest.getInventoryName() = this.lowerChestInventory.displayName.unformattedText.trim()
fun getItemsInOwnInventory() =
- Minecraft.getMinecraft().thePlayer?.inventory?.mainInventory?.filterNotNull() ?: emptyList()
+ getItemsInOwnInventoryWithNull()?.filterNotNull() ?: emptyList()
- fun getItemsInOwnInventoryWithNull() = Minecraft.getMinecraft().thePlayer.inventory.mainInventory
+ fun getItemsInOwnInventoryWithNull() = Minecraft.getMinecraft().thePlayer?.inventory?.mainInventory
+
+ fun getItemsInHotbar() =
+ getItemsInOwnInventoryWithNull()?.sliceArray(0..8)?.filterNotNull() ?: emptyList()
fun countItemsInLowerInventory(predicate: (ItemStack) -> Boolean) =
getItemsInOwnInventory().filter { predicate(it) }.sumOf { it.stackSize }