diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-03-07 01:21:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-07 01:21:33 +0100 |
commit | f1af1a44c66733cca564b5fbad32fa4c9de01bd4 (patch) | |
tree | 2c22280af285748966eb514f678a32c1edbd09e2 /src/main/java/at/hannibal2/skyhanni/features/fishing | |
parent | 84589e27e919acd6f8972bb053e209b175950cfc (diff) | |
download | skyhanni-f1af1a44c66733cca564b5fbad32fa4c9de01bd4.tar.gz skyhanni-f1af1a44c66733cca564b5fbad32fa4c9de01bd4.tar.bz2 skyhanni-f1af1a44c66733cca564b5fbad32fa4c9de01bd4.zip |
Internal Change: Code cleanup in FishingAPI (#1056)
Co-authored-by: Obsidianninja11 <obsidianninja11@gmail.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/fishing')
3 files changed, 18 insertions, 12 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt index 2403e430f..239e2a9aa 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt @@ -11,10 +11,9 @@ 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.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.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.NEUInternalName @@ -84,8 +83,12 @@ object FishingAPI { } } - private fun NEUInternalName.isFishingRod() = contains("ROD") - fun ItemStack.isFishingRod() = getItemCategoryOrNull() == ItemCategory.FISHING_ROD || getItemCategoryOrNull() == ItemCategory.FISHING_WEAPON + fun ItemStack.isFishingRod() = getInternalName().isFishingRod() + fun NEUInternalName.isFishingRod() = isLavaRod() || isWaterRod() + + fun NEUInternalName?.isLavaRod() = this in lavaRods + + fun NEUInternalName?.isWaterRod() = this in waterRods fun ItemStack.isBait(): Boolean = stackSize == 1 && getItemCategoryOrNull() == ItemCategory.FISHING_BAIT @@ -93,20 +96,18 @@ object FishingAPI { fun onItemInHandChange(event: ItemInHandChangeEvent) { // TODO correct rod type per island water/lava holdingRod = event.newItem.isFishingRod() - holdingLavaRod = event.newItem in lavaRods - holdingWaterRod = event.newItem in waterRods + holdingLavaRod = event.newItem.isLavaRod() + holdingWaterRod = event.newItem.isWaterRod() } @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { val data = event.getConstant<ItemsJson>("Items") - lavaRods = data.lava_fishing_rods ?: error("§clava_fishing_rods is missing from repo.") - waterRods = data.water_fishing_rods ?: error("§cwater_fishing_rods is missing from repo.") + lavaRods = data.lava_fishing_rods + waterRods = data.water_fishing_rods } - fun isLavaRod() = InventoryUtils.getItemInHand()?.getLore()?.any { it.contains("Lava Rod") } ?: false - - private fun getAllowedBlocks() = if (isLavaRod()) lavaBlocks else waterBlocks + private fun getAllowedBlocks() = if (holdingLavaRod) lavaBlocks else waterBlocks fun getFilletPerTrophy(internalName: NEUInternalName): Int { val internal = internalName.asString() 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 8f201648b..f1c876049 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt @@ -73,7 +73,7 @@ class SharkFishCounter { else -> "How???" } - private fun isWaterFishingRod() = FishingAPI.isFishing() && !FishingAPI.isLavaRod() + private fun isWaterFishingRod() = FishingAPI.isFishing() && !FishingAPI.holdingLavaRod @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/GeyserFishing.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/GeyserFishing.kt index f17ec4587..aa2920742 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/GeyserFishing.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/GeyserFishing.kt @@ -60,6 +60,11 @@ class GeyserFishing { val geyser = geyser ?: return if (geyser.distanceToPlayerIgnoreY() > 96) return + if (!config.drawBox) return + if (!IslandType.CRIMSON_ISLE.isInIsland()) return + if (config.onlyWithRod && !FishingAPI.holdingLavaRod) return + if (geyser.distanceToPlayerIgnoreY() > 96) return + val geyserBox = geyserBox ?: return val color = Color(SpecialColour.specialToChromaRGB(config.boxColor), true) event.drawFilledBoundingBox_nea(geyserBox, color) |