diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-03-06 23:51:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-06 23:51:02 +0100 |
commit | 0a95a791eb57a546fb5421594abae740faf1dfdb (patch) | |
tree | 82bfc13c544a60d496bab081b66ddd73e07d62a3 /src/main/java/at/hannibal2/skyhanni/features/fishing | |
parent | 28430fe85115334fb06fb7e3cc36da819f08dace (diff) | |
download | skyhanni-0a95a791eb57a546fb5421594abae740faf1dfdb.tar.gz skyhanni-0a95a791eb57a546fb5421594abae740faf1dfdb.tar.bz2 skyhanni-0a95a791eb57a546fb5421594abae740faf1dfdb.zip |
Internal Changes: Many small code cleanups (#1101)
Co-authored-by: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/fishing')
4 files changed, 8 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 3335f61ca..2403e430f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt @@ -12,13 +12,13 @@ import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishManager.getFillet 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.getItemCategoryOrNull 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.LorenzVec import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.SimpleTimeMark -import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.getLorenzVec import net.minecraft.client.Minecraft import net.minecraft.entity.item.EntityArmorStand @@ -85,11 +85,9 @@ object FishingAPI { } private fun NEUInternalName.isFishingRod() = contains("ROD") + fun ItemStack.isFishingRod() = getItemCategoryOrNull() == ItemCategory.FISHING_ROD || getItemCategoryOrNull() == ItemCategory.FISHING_WEAPON - fun ItemStack.isBait(): Boolean { - val name = name ?: return false - return stackSize == 1 && (name.removeColor().startsWith("Obfuscated") || name.endsWith(" Bait")) - } + fun ItemStack.isBait(): Boolean = stackSize == 1 && getItemCategoryOrNull() == ItemCategory.FISHING_BAIT @SubscribeEvent fun onItemInHandChange(event: ItemInHandChangeEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingBaitWarnings.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingBaitWarnings.kt index 352b36d16..854165823 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingBaitWarnings.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingBaitWarnings.kt @@ -69,10 +69,9 @@ class FishingBaitWarnings { for (entity in EntityUtils.getEntitiesNearby<EntityItem>(bobber.getLorenzVec(), 6.0)) { val itemStack = entity.entityItem ?: continue if (!itemStack.isBait()) continue - val name = itemStack.name ?: continue val ticksExisted = entity.ticksExisted if (ticksExisted in 6..15) { - return name + return itemStack.name } val distance = "distance: ${entity.getDistanceToEntity(bobber).addSeparators()}" diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/ShowFishingItemName.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/ShowFishingItemName.kt index e2d1b297e..28c2aa27f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/ShowFishingItemName.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/ShowFishingItemName.kt @@ -49,7 +49,7 @@ class ShowFishingItemName { val location = event.exactLocation(entityItem).add(y = 0.8) if (location.distance(LocationUtils.playerLocation()) > 15) continue val itemStack = entityItem.entityItem - var name = itemStack.name ?: continue + var name = itemStack.name // Hypixel sometimes replaces the bait item mid air with a stone if (name.removeColor() == "Stone") continue diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/OdgerWaypoint.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/OdgerWaypoint.kt index bdd085ac1..d26ec6b90 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/OdgerWaypoint.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/OdgerWaypoint.kt @@ -5,10 +5,10 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.features.fishing.FishingAPI.isFishingRod import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore -import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.LorenzVec @@ -37,8 +37,7 @@ class OdgerWaypoint { private fun isLavaFishingRod(): Boolean { val heldItem = InventoryUtils.getItemInHand() ?: return false - val isRod = heldItem.name?.contains("Rod") ?: return false - if (!isRod) return false + if (!heldItem.isFishingRod()) return false return heldItem.getLore().any { it.contains("Lava Rod") } } |