aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorObsidian <108832807+Obsidianninja11@users.noreply.github.com>2024-02-26 06:23:35 -0900
committerGitHub <noreply@github.com>2024-02-26 16:23:35 +0100
commit8d7eb45435c328792638cba18eed498e139706a8 (patch)
tree1c4ff64e3903ad7d49702e6ce5e02c64522b63fa /src/main/java
parent1ba5a48080de0c1ecbc55885a4c5711d36a06968 (diff)
downloadskyhanni-8d7eb45435c328792638cba18eed498e139706a8.tar.gz
skyhanni-8d7eb45435c328792638cba18eed498e139706a8.tar.bz2
skyhanni-8d7eb45435c328792638cba18eed498e139706a8.zip
Geyser fixes + fishingAPI #1054
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/crimsonisle/SulphurSkitterBoxConfig.java2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/fishing/trophyfishing/GeyserFishingConfig.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt17
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/GeyserFishing.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/SulphurSkitterBox.kt17
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt2
6 files changed, 33 insertions, 19 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/crimsonisle/SulphurSkitterBoxConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/crimsonisle/SulphurSkitterBoxConfig.java
index c37b16172..7eb2419c2 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/crimsonisle/SulphurSkitterBoxConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/crimsonisle/SulphurSkitterBoxConfig.java
@@ -47,6 +47,4 @@ public class SulphurSkitterBoxConfig {
@ConfigOption(name = "Only With Rods", desc = "Render the box only when holding a lava fishing rod.")
@ConfigEditorBoolean
public boolean onlyWithRods = true;
-
-
}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/trophyfishing/GeyserFishingConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/trophyfishing/GeyserFishingConfig.java
index a0f243ce5..9e3edfcb8 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/trophyfishing/GeyserFishingConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/trophyfishing/GeyserFishingConfig.java
@@ -28,4 +28,9 @@ public class GeyserFishingConfig {
@ConfigOption(name = "Geyser Box Color", desc = "Color of the Geyser Box.")
@ConfigEditorColour
public String boxColor = "0:245:85:255:85";
+
+ @Expose
+ @ConfigOption(name = "Only With Rod", desc = "Only render the geyser box while holding a lava rod.")
+ @ConfigEditorBoolean
+ public boolean onlyWithRod = true;
}
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 e3ac0c219..ae58bec30 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt
@@ -1,7 +1,9 @@
package at.hannibal2.skyhanni.features.fishing
+import at.hannibal2.skyhanni.data.jsonobjects.repo.ItemsJson
import at.hannibal2.skyhanni.events.FishingBobberCastEvent
import at.hannibal2.skyhanni.events.ItemInHandChangeEvent
+import at.hannibal2.skyhanni.events.RepositoryReloadEvent
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
@@ -29,6 +31,11 @@ object FishingAPI {
var lastCastTime = SimpleTimeMark.farPast()
var holdingRod = false
+ var holdingLavaRod = false
+ var holdingWaterRod = false
+
+ private var lavaRods = listOf<NEUInternalName>()
+ private var waterRods = listOf<NEUInternalName>()
@SubscribeEvent
fun onJoinWorld(event: EntityJoinWorldEvent) {
@@ -52,6 +59,16 @@ 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
+ }
+
+
+ @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.")
}
fun isLavaRod() = InventoryUtils.getItemInHand()?.getLore()?.any { it.contains("Lava Rod") } ?: false
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 da46ec7b2..e4ffe0053 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
@@ -7,7 +7,9 @@ import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.ReceiveParticleEvent
+import at.hannibal2.skyhanni.features.fishing.FishingAPI
import at.hannibal2.skyhanni.utils.LocationUtils.distanceTo
+import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayerIgnoreY
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.LorenzVec
@@ -69,7 +71,12 @@ class GeyserFishing {
@SubscribeEvent
fun onRenderWorld(event: LorenzRenderWorldEvent) {
- if (!config.drawBox || !IslandType.CRIMSON_ISLE.isInIsland()) return
+ if (!config.drawBox) return
+ if (!IslandType.CRIMSON_ISLE.isInIsland()) return
+ if (config.onlyWithRod && !FishingAPI.holdingLavaRod) return
+ val geyser = geyser ?: return
+ if (geyser.distanceToPlayerIgnoreY() > 96) return
+
val geyserBox = geyserBox ?: return
val color = Color(SpecialColour.specialToChromaRGB(config.boxColor), true)
event.drawFilledBoundingBox_nea(geyserBox, color)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/SulphurSkitterBox.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/SulphurSkitterBox.kt
index 5db95b246..7b73d1fd4 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/nether/SulphurSkitterBox.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/nether/SulphurSkitterBox.kt
@@ -4,18 +4,14 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.config.features.crimsonisle.SulphurSkitterBoxConfig
import at.hannibal2.skyhanni.data.IslandType
-import at.hannibal2.skyhanni.data.jsonobjects.repo.ItemsJson
import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
-import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.features.fishing.FishingAPI
import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt
-import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
-import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.RenderUtils
import at.hannibal2.skyhanni.utils.RenderUtils.expandBlock
import at.hannibal2.skyhanni.utils.SpecialColour
@@ -29,7 +25,6 @@ import java.awt.Color
class SulphurSkitterBox {
private val config get() = SkyHanniMod.feature.fishing.trophyFishing.sulphurSkitterBox
- private var rods = listOf<NEUInternalName>()
private var spongeBlocks = listOf<BlockPos>()
private var closestBlock: BlockPos? = null
private val radius = 8
@@ -102,18 +97,8 @@ class SulphurSkitterBox {
}
}
- @SubscribeEvent
- fun onRepoReload(event: RepositoryReloadEvent) {
- val data = event.getConstant<ItemsJson>("Items")
- rods = data.lava_fishing_rods ?: emptyList()
-
- if (rods.isEmpty()) {
- error("§cConstants Items is missing data, please use /shupdaterepo")
- }
- }
-
fun isEnabled() =
- IslandType.CRIMSON_ISLE.isInIsland() && config.enabled && (!config.onlyWithRods || InventoryUtils.itemInHandId in rods)
+ IslandType.CRIMSON_ISLE.isInIsland() && config.enabled && (!config.onlyWithRods || FishingAPI.holdingLavaRod)
@SubscribeEvent
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt
index 654974d5c..819f2c7f6 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt
@@ -13,6 +13,8 @@ object LocationUtils {
fun LorenzVec.distanceToPlayer() = distance(playerLocation())
+ fun LorenzVec.distanceToPlayerIgnoreY() = distanceIgnoreY(playerLocation())
+
fun LorenzVec.distanceSqToPlayer() = distanceSq(playerLocation())
fun LorenzVec.distanceToPlayerSqIgnoreY() = distanceSqIgnoreY(playerLocation())