diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-05-11 09:27:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-11 09:27:37 +0200 |
commit | a7219971c5101502ab2762506c1ac8561657aaeb (patch) | |
tree | a97ba166c1a263f94b4b10ae1ef5ebd250eaf039 /src/main/java/at/hannibal2/skyhanni | |
parent | 974cc48b355ff020cbb17dc036730616b159b855 (diff) | |
download | skyhanni-a7219971c5101502ab2762506c1ac8561657aaeb.tar.gz skyhanni-a7219971c5101502ab2762506c1ac8561657aaeb.tar.bz2 skyhanni-a7219971c5101502ab2762506c1ac8561657aaeb.zip |
Fix: oldest bug in skyhanni (#1630)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt | 25 |
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 |