Skip to content

Commit

Permalink
Feature: Golden Fish Timer (hannibal002#1941)
Browse files Browse the repository at this point in the history
Co-authored-by: Cal <[email protected]>
Co-authored-by: hannibal2 <[email protected]>
Co-authored-by: ItsEmpa <[email protected]>
  • Loading branch information
4 people authored Sep 10, 2024
1 parent 9acb6e8 commit d6c9b63
Show file tree
Hide file tree
Showing 11 changed files with 437 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package at.hannibal2.skyhanni.config.features.fishing.trophyfishing;

import at.hannibal2.skyhanni.config.FeatureToggle;
import at.hannibal2.skyhanni.config.core.config.Position;
import com.google.gson.annotations.Expose;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider;
import io.github.notenoughupdates.moulconfig.annotations.ConfigLink;
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;

public class GoldenFishTimerConfig {

@Expose
@ConfigOption(name = "Enabled", desc = "Enable the Golden Fish Timer.")
@ConfigEditorBoolean
@FeatureToggle
public boolean enabled = true;

@Expose
@ConfigOption(name = "Nametag", desc = "Show a nametag on the Golden Fish showing how weak it is and when it will despawn.")
@ConfigEditorBoolean
public boolean nametag = true;

@Expose
@ConfigOption(name = "Highlight when ready", desc = "Highlight the Golden Fish when it is ready to be caught.")
@ConfigEditorBoolean
public boolean highlight = true;

@Expose
@ConfigOption(name = "Throw Rod Warning", desc = "Show a warning when you are close to the time limit of throwing your rod.")
@ConfigEditorBoolean
public boolean throwRodWarning = false;

@Expose
@ConfigOption(name = "Show Head", desc = "Show the Golden Fish head in the Golden Fish Timer GUI.")
@ConfigEditorBoolean
public boolean showHead = true;

@Expose
@ConfigOption(name = "Throw Rod Warning Time", desc = "The time in seconds before the throw rod warning appears.")
@ConfigEditorSlider(minValue = 1, maxValue = 60, minStep = 1)
public int throwRodWarningTime = 20;

@Expose
@ConfigLink(owner = GoldenFishTimerConfig.class, field = "enabled")
public Position position = new Position(50, 80);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public class TrophyFishingConfig {
@Expose
public SulphurSkitterBoxConfig sulphurSkitterBox = new SulphurSkitterBoxConfig();

@Expose
@ConfigOption(name = "Golden Fish Timer", desc = "")
@Accordion
public GoldenFishTimerConfig goldenFishTimer = new GoldenFishTimerConfig();

@Expose
@ConfigOption(name = "Fillet Tooltip", desc = "Show fillet value of Trophy Fish in tooltip.")
@ConfigEditorBoolean
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package at.hannibal2.skyhanni.events

import net.minecraft.entity.projectile.EntityFishHook

class FishingBobberInLiquidEvent(val bobber: EntityFishHook, val onWater: Boolean) : LorenzEvent()

This file was deleted.

24 changes: 13 additions & 11 deletions src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package at.hannibal2.skyhanni.features.fishing
import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.data.jsonobjects.repo.ItemsJson
import at.hannibal2.skyhanni.events.FishingBobberCastEvent
import at.hannibal2.skyhanni.events.FishingBobberInWaterEvent
import at.hannibal2.skyhanni.events.FishingBobberInLiquidEvent
import at.hannibal2.skyhanni.events.ItemInHandChangeEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
Expand All @@ -13,16 +13,15 @@ import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishManager
import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishManager.getFilletValue
import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemCategory
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.ItemUtils.getItemCategoryOrNull
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.getLorenzVec
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.client.Minecraft
Expand Down Expand Up @@ -52,7 +51,7 @@ object FishingAPI {
private var waterRods = listOf<NEUInternalName>()

var bobber: EntityFishHook? = null
var bobberHasTouchedWater = false
var bobberHasTouchedLiquid = false

var wearingTrophyArmor = false

Expand All @@ -63,13 +62,13 @@ object FishingAPI {

lastCastTime = SimpleTimeMark.now()
bobber = event.entity
bobberHasTouchedWater = false
bobberHasTouchedLiquid = false
FishingBobberCastEvent(event.entity).postAndCatch()
}

private fun resetBobber() {
bobber = null
bobberHasTouchedWater = false
bobberHasTouchedLiquid = false
}

@SubscribeEvent
Expand All @@ -89,12 +88,15 @@ object FishingAPI {
if (bobber.isDead) {
resetBobber()
} else {
if (!bobberHasTouchedWater) {
val block = bobber.getLorenzVec().getBlockAt()
if (block in getAllowedBlocks()) {
bobberHasTouchedWater = true
FishingBobberInWaterEvent().postAndCatch()
if (!bobberHasTouchedLiquid) {
val isWater = when {
bobber.isInLava && holdingLavaRod -> false
bobber.isInWater && holdingWaterRod -> true
else -> return
}

bobberHasTouchedLiquid = true
FishingBobberInLiquidEvent(bobber, isWater).postAndCatch()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package at.hannibal2.skyhanni.features.fishing

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.events.FishingBobberInWaterEvent
import at.hannibal2.skyhanni.events.FishingBobberInLiquidEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.entity.EntityEnterWorldEvent
import at.hannibal2.skyhanni.features.fishing.FishingAPI.isBait
Expand Down Expand Up @@ -48,7 +48,7 @@ object FishingBaitWarnings {
}

@SubscribeEvent
fun onBobberInWater(event: FishingBobberInWaterEvent) {
fun onBobber(event: FishingBobberInLiquidEvent) {
if (!isEnabled()) return
DelayedRun.runDelayed(500.milliseconds) {
checkBait()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package at.hannibal2.skyhanni.features.fishing

import at.hannibal2.skyhanni.events.FishingBobberInWaterEvent
import at.hannibal2.skyhanni.events.FishingBobberInLiquidEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.EntityUtils
Expand All @@ -26,7 +26,7 @@ object IsFishingDetection {
private var lastSeaCreatureKillAreaTime = SimpleTimeMark.farPast()

@SubscribeEvent
fun onBobberInWater(event: FishingBobberInWaterEvent) {
fun onBobber(event: FishingBobberInLiquidEvent) {
lastRodCastLocation = LocationUtils.playerLocation()
lastRodCastTime = SimpleTimeMark.now()
}
Expand Down
Loading

0 comments on commit d6c9b63

Please sign in to comment.