diff options
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt index 8943e74d6..79fdc21f3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt @@ -13,8 +13,10 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.SoundUtils +import at.hannibal2.skyhanni.utils.StringUtils import at.hannibal2.skyhanni.utils.TimeUnit import at.hannibal2.skyhanni.utils.TimeUtils +import at.hannibal2.skyhanni.utils.getLorenzVec import net.minecraft.client.Minecraft import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -75,15 +77,32 @@ class FishingTimer { } } - private fun countMobs() = EntityUtils.getEntities<EntityArmorStand>() - .map { entity -> - val name = entity.name - val isSummonedSoul = name.contains("'") - val hasFishingMobName = SeaCreatureManager.allFishingMobs.keys.any { name.contains(it) } - if (hasFishingMobName && !isSummonedSoul) { - if (name == "Sea Emperor" || name == "Rider of the Deep") 2 else 1 - } else 0 - }.sum() + private fun countMobs() = EntityUtils.getEntities<EntityArmorStand>().map { entity -> amount(entity) }.sum() + + private fun amount(entity: EntityArmorStand): Int { + val name = entity.name + // a dragon, will always be fought + if (name == "Reindrake") return 0 + + // a npc shop + if (name == "§5Frosty the Snow Blaster") return 0 + + if (name == "Frosty") { + val npcLocation = LorenzVec(-1.5, 76.0, 92.5) + if (entity.getLorenzVec().distance(npcLocation) < 1) { + return 0 + } + } + + val isSummonedSoul = name.contains("'") + val hasFishingMobName = SeaCreatureManager.allFishingMobs.keys.any { name.contains(it) } + if (!hasFishingMobName || isSummonedSoul) return 0 + + if (name == "Sea Emperor" || name == "Rider of the Deep") { + return 2 + } + return 1 + } private fun isRightLocation(): Boolean { inHollows = false @@ -117,7 +136,7 @@ class FishingTimer { val barnTimerAlertTime = config.alertTime * 1_000 val color = if (duration > barnTimerAlertTime) "§c" else "§e" val timeFormat = TimeUtils.formatDuration(duration, biggestUnit = TimeUnit.MINUTE) - val name = if (currentCount == 1) "sea creature" else "sea creatures" + val name = StringUtils.optionalPlural(currentCount, "sea creature", "sea creatures") val text = "$color$timeFormat §8(§e$currentCount §b$name§8)" config.pos.renderString(text, posLabel = "BarnTimer") |