diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureMessageShortener.kt | 17 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt | 66 |
2 files changed, 73 insertions, 10 deletions
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 6670a4a3e..2c310a7bd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureMessageShortener.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureMessageShortener.kt @@ -1,24 +1,21 @@ package at.hannibal2.skyhanni.features.fishing import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.SeaCreatureFishEvent import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class SeaCreatureMessageShortener { @SubscribeEvent - fun onChatMessage(event: LorenzChatEvent) { - if (!LorenzUtils.inSkyBlock) return + fun onSeaCreatureFish(event: SeaCreatureFishEvent) { if (!SkyHanniMod.feature.fishing.shortenFishingMessage) return - val seaCreature = SeaCreatureManager.getSeaCreature(event.message) - if (seaCreature != null) { - event.blockedReason = "sea_create_caught" - LorenzUtils.chat("§9You caught a $seaCreature§9!") - if (seaCreature.fishingExperience == 0) { - LorenzUtils.debug("no fishing exp set for " + seaCreature.displayName) - } + val seaCreature = event.seaCreature + event.chatEvent.blockedReason = "sea_creature_caught" + LorenzUtils.chat("§9You caught a $seaCreature§9!") + if (seaCreature.fishingExperience == 0) { + LorenzUtils.debug("no fishing exp set for " + seaCreature.displayName) } } }
\ 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 new file mode 100644 index 000000000..a6253c25b --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt @@ -0,0 +1,66 @@ +package at.hannibal2.skyhanni.features.fishing + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.SeaCreatureFishEvent +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.ItemUtils.name +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RenderUtils.renderString +import net.minecraft.client.Minecraft +import net.minecraftforge.client.event.RenderGameOverlayEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent + +class SharkFishCounter { + + private var counter = 0 + private var display = "$counter sharks caught" + private var tick = 0 + private var hasWaterRodInHand = false + + @SubscribeEvent + fun onSeaCreatureFish(event: SeaCreatureFishEvent) { + if (!SkyHanniMod.feature.fishing.sharkFishCounter) return + + val displayName = event.seaCreature.displayName + if (displayName.contains("Shark")) { + counter++ + display = "$counter sharks caught" + } + } + + @SubscribeEvent + fun onTick(event: TickEvent.ClientTickEvent) { + if (event.phase != TickEvent.Phase.START) return + + if (!LorenzUtils.inSkyBlock) return + if (!SkyHanniMod.feature.fishing.sharkFishCounter) return + + tick++ + + if (tick % 10 == 0) { + hasWaterRodInHand = isWaterFishingRod() + } + } + + private fun isWaterFishingRod(): Boolean { + val heldItem = Minecraft.getMinecraft().thePlayer.heldItem ?: return false + val isRod = heldItem.name?.contains("Rod") ?: return false + if (!isRod) return false + + val isLavaRod = heldItem.getLore().any { it.contains("Lava Rod") } + if (isLavaRod) return false + + return true + } + + @SubscribeEvent + fun onRenderOverlay(event: RenderGameOverlayEvent.Post) { + if (event.type != RenderGameOverlayEvent.ElementType.ALL) return + if (!LorenzUtils.inSkyBlock) return + if (!SkyHanniMod.feature.fishing.sharkFishCounter) return + if (!hasWaterRodInHand) return + + SkyHanniMod.feature.fishing.sharkFishCounterPos.renderString(display) + } +}
\ No newline at end of file |