diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
6 files changed, 62 insertions, 33 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 2531b97bc..e90e550b9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt @@ -74,7 +74,7 @@ class FishingTimer { .map { entity -> val name = entity.name val isSummonedSoul = name.contains("'") - val hasFishingMobName = SeaCreatureManager.allFishingMobNames.any { name.contains(it) } + 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 diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreature.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreature.kt index 987a57d00..18ff93cc9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreature.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreature.kt @@ -1,18 +1,17 @@ package at.hannibal2.skyhanni.features.fishing +import at.hannibal2.skyhanni.utils.LorenzRarity + data class SeaCreature( - val displayName: String, + val name: String, val fishingExperience: Int, val chatColor: String, val rare: Boolean, + val rarity: LorenzRarity, ) { - override fun toString(): String { - return chatColor + rare() + displayName - } + val displayName by lazy { chatColor + rare() + name } - private fun rare(): String { - return if (rare) "§l" else "" - } + private fun rare() = if (rare) "§l" else "" } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureFeatures.kt index be4df98e4..a545a87a4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureFeatures.kt @@ -1,9 +1,12 @@ package at.hannibal2.skyhanni.features.fishing import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.data.TitleManager import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.RenderEntityOutlineEvent +import at.hannibal2.skyhanni.events.SeaCreatureFishEvent import at.hannibal2.skyhanni.events.withAlpha import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper @@ -13,17 +16,22 @@ import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.SoundUtils import net.minecraft.entity.Entity import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.monster.EntityGuardian +import net.minecraft.entity.monster.EntityIronGolem +import net.minecraft.entity.monster.EntitySkeleton import net.minecraft.entity.monster.EntityZombie import net.minecraft.entity.player.EntityPlayer import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - +import kotlin.time.Duration.Companion.seconds class SeaCreatureFeatures { - private val config get() = SkyHanniMod.feature.fishing + private val config get() = SkyHanniMod.feature.fishing.rareCatches private var rareSeaCreatures = listOf<EntityLivingBase>() + private var lastRareCatch = SimpleTimeMark.farPast() @SubscribeEvent fun onEntityHealthUpdate(event: EntityMaxHealthUpdateEvent) { @@ -39,8 +47,25 @@ class SeaCreatureFeatures { rareSeaCreatures = rareSeaCreatures.editCopy { add(entity) } RenderLivingEntityHelper.setEntityColor(entity, LorenzColor.RED.toColor().withAlpha(50)) - { config.rareSeaCreatureHighlight } - RenderLivingEntityHelper.setNoHurtTime(entity) { config.rareSeaCreatureHighlight } + { config.highlight } + RenderLivingEntityHelper.setNoHurtTime(entity) { config.highlight } + if (config.alertOtherCatches && lastRareCatch.passedSince() > 1.seconds) { + val creature = SeaCreatureManager.allFishingMobs[creatureType.nametag] + TitleManager.sendTitle("${creature?.rarity?.chatColorCode ?: "§6"}RARE SEA CREATURE!", 1.5.seconds, 3.6) + if (config.playSound) SoundUtils.playBeepSound() + } + } + } + + @SubscribeEvent + fun onSeaCreatureFish(event: SeaCreatureFishEvent) { + if (!LorenzUtils.inSkyBlock) return + if (!config.alertOwnCatches) return + + if (event.seaCreature.rare) { + TitleManager.sendTitle("${event.seaCreature.rarity.chatColorCode}RARE CATCH!", 3.seconds, 3.6) + if (config.playSound) SoundUtils.playBeepSound() + lastRareCatch = SimpleTimeMark.now() } } @@ -51,11 +76,16 @@ class SeaCreatureFeatures { @SubscribeEvent fun onRenderEntityOutlines(event: RenderEntityOutlineEvent) { - if (isEnabled() && config.rareSeaCreatureHighlight && event.type === RenderEntityOutlineEvent.Type.XRAY) { + if (isEnabled() && config.highlight && event.type === RenderEntityOutlineEvent.Type.XRAY) { event.queueEntitiesToOutline(getEntityOutlineColor) } } + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.move(2, "fishing.rareSeaCreatureHighlight", "fishing.rareCatches.highlight") + } + private fun isEnabled() = LorenzUtils.inSkyBlock && !LorenzUtils.inDungeons && !LorenzUtils.inKuudraFight private val getEntityOutlineColor: (entity: Entity) -> Int? = { entity -> @@ -71,12 +101,15 @@ class SeaCreatureFeatures { ) { WATER_HYDRA(EntityZombie::class.java, "Water Hydra", 500_000), SEA_EMPEROR(EntityGuardian::class.java, "Sea Emperor", 750_000, 800_000), + SEA_EMPEROR_RIDER(EntitySkeleton::class.java, "Sea Emperor", 750_000, 800_000), ZOMBIE_MINER(EntityPlayer::class.java, "Zombie Miner", 2_000_000), PHANTOM_FISHERMAN(EntityPlayer::class.java, "Phantom Fisher", 1_000_000), GRIM_REAPER(EntityPlayer::class.java, "Grim Reaper", 3_000_000), YETI(EntityPlayer::class.java, "Yeti", 2_000_000), NUTCRACKER(EntityZombie::class.java, "Nutcracker", 4_000_000), GREAT_WHITE_SHARK(EntityPlayer::class.java, "Great White Shark", 1_500_000), + THUNDER(EntityGuardian::class.java, "Thunder", 35_000_000), + LORD_JAWBUS(EntityIronGolem::class.java, "Lord Jawbus", 100_000_000), ; } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt index e40ad43df..1fcca06f2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.SeaCreatureFishEvent import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.jsonobjects.SeaCreatureJson import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class SeaCreatureManager { @@ -34,26 +35,23 @@ class SeaCreatureManager { var counter = 0 try { - val data = event.getConstant("SeaCreatures") ?: return + val data = event.getConstant<Map<String, SeaCreatureJson.Variant>>("SeaCreatures", SeaCreatureJson.TYPE) ?: return + val allFishingMobs = mutableMapOf<String,SeaCreature>() - val fishingMobNames = mutableListOf<String>() - for (variant in data.entrySet().map { it.value.asJsonObject }) { - val chatColor = variant["chat_color"].asString - for ((displayName, value) in variant["sea_creatures"].asJsonObject.entrySet()) { - val seaCreature = value.asJsonObject - val chatMessage = seaCreature["chat_message"].asString - val fishingExperience = seaCreature["fishing_experience"].asInt + for (variant in data.values) { + val chatColor = variant.chat_color + for ((displayName, seaCreature) in variant.sea_creatures) { + val chatMessage = seaCreature.chat_message + val fishingExperience = seaCreature.fishing_experience + val rarity = seaCreature.rarity + val rare = seaCreature.rare ?: false - val rare = if (seaCreature.has("rare")) { - seaCreature["rare"].asBoolean - } else false - - seaCreatureMap[chatMessage] = SeaCreature(displayName, fishingExperience, chatColor, rare) - fishingMobNames.add(displayName) + val creature = SeaCreature(displayName, fishingExperience, chatColor, rare, rarity) + seaCreatureMap[chatMessage] = creature + allFishingMobs[displayName] = creature counter++ } } - allFishingMobNames = fishingMobNames LorenzUtils.debug("Loaded $counter sea creatures from repo") } catch (e: Exception) { @@ -64,7 +62,7 @@ class SeaCreatureManager { companion object { private val seaCreatureMap = mutableMapOf<String, SeaCreature>() - var allFishingMobNames = emptyList<String>() + var allFishingMobs = mutableMapOf<String, SeaCreature>() private val doubleHookMessages = setOf( "§eIt's a §r§aDouble Hook§r§e! Woot woot!", diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureMessageShortener.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureMessageShortener.kt index 9226c46c2..f9cb0d861 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureMessageShortener.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureMessageShortener.kt @@ -16,7 +16,7 @@ class SeaCreatureMessageShortener { event.chatEvent.blockedReason = "sea_creature_caught" var message = if (config.shortenFishingMessage) { - "§9You caught a $seaCreature§9!" + "§9You caught a ${seaCreature.displayName}§9!" } else event.chatEvent.message if (config.compactDoubleHook && event.doubleHook) { @@ -25,7 +25,7 @@ class SeaCreatureMessageShortener { LorenzUtils.chat(message) if (seaCreature.fishingExperience == 0) { - LorenzUtils.debug("no fishing exp set for " + seaCreature.displayName) + LorenzUtils.debug("no fishing exp set for " + seaCreature.name) } } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt index becdddf16..c592e72a4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt @@ -22,8 +22,7 @@ class SharkFishCounter { fun onSeaCreatureFish(event: SeaCreatureFishEvent) { if (!SkyHanniMod.feature.fishing.sharkFishCounter) return - val displayName = event.seaCreature.displayName - if (displayName.contains("Shark")) { + if (event.seaCreature.name.contains("Shark")) { counter += if (event.doubleHook) 2 else 1 display = "§7Sharks caught: §e${counter.addSeparators()}" } |