aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt
index 4a6fc8928..e0f787822 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt
@@ -23,12 +23,14 @@ import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
import at.hannibal2.skyhanni.utils.BlockUtils.getBlockStateAt
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy
+import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.cleanName
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LocationUtils.canBeSeen
+import at.hannibal2.skyhanni.utils.LocationUtils.distanceTo
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.LorenzVec
@@ -169,9 +171,11 @@ class MinionFeatures {
@SubscribeEvent
fun onMinionOpen(event: MinionOpenEvent) {
+ removeBuggedMinions()
val minions = minions ?: return
val entity = lastClickedEntity ?: return
+
val openInventory = event.inventoryName
val name = getMinionName(openInventory)
if (!minions.contains(entity) && LorenzUtils.skyBlockIsland != IslandType.HUB) {
@@ -194,6 +198,27 @@ class MinionFeatures {
lastMinionOpened = 0
}
+ private fun removeBuggedMinions() {
+ val minions = minions ?: return
+
+ val removedEntities = mutableListOf<LorenzVec>()
+ for (location in minions.keys) {
+ val entitiesNearby = EntityUtils.getEntities<EntityArmorStand>().map { it.distanceTo(location) }
+ if (!entitiesNearby.any { it == 0.0 }) {
+ removedEntities.add(location)
+ }
+ }
+
+ val size = removedEntities.size
+ if (size == 0) return
+ Companion.minions = minions.editCopy {
+ for (removedEntity in removedEntities) {
+ remove(removedEntity)
+ }
+ ChatUtils.chat("Removed $size wrong/bugged minion locations from your island.")
+ }
+ }
+
@SubscribeEvent
fun onInventoryClose(event: InventoryCloseEvent) {
if (event.reopenSameName) return