aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-09-16 00:25:42 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-09-16 00:25:42 +0200
commit26c9ff13df1a7e0a6508d11c98ff994cdc1d8902 (patch)
treef729af2dcba9b58baaed51b574b05209deed52f6 /src/main/java/at/hannibal2/skyhanni/features
parent2c36de4e212b59a2feca2e1b4c9727d6ed9aea0f (diff)
downloadskyhanni-26c9ff13df1a7e0a6508d11c98ff994cdc1d8902.tar.gz
skyhanni-26c9ff13df1a7e0a6508d11c98ff994cdc1d8902.tar.bz2
skyhanni-26c9ff13df1a7e0a6508d11c98ff994cdc1d8902.zip
Added Fishing Hook Display
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/FishingHookDisplay.kt70
2 files changed, 77 insertions, 0 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
new file mode 100644
index 000000000..973d7ac1e
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt
@@ -0,0 +1,7 @@
+package at.hannibal2.skyhanni.features.fishing
+
+import at.hannibal2.skyhanni.utils.InventoryUtils
+
+object FishingAPI {
+ fun hasFishingRodInHand() = InventoryUtils.itemInHandId.toString().contains("ROD")
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingHookDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingHookDisplay.kt
new file mode 100644
index 000000000..b91d74f26
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingHookDisplay.kt
@@ -0,0 +1,70 @@
+package at.hannibal2.skyhanni.features.fishing
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.CheckRenderEntityEvent
+import at.hannibal2.skyhanni.events.GuiRenderEvent
+import at.hannibal2.skyhanni.events.LorenzTickEvent
+import at.hannibal2.skyhanni.utils.EntityUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzVec
+import at.hannibal2.skyhanni.utils.RenderUtils.renderString
+import at.hannibal2.skyhanni.utils.getLorenzVec
+import net.minecraft.client.entity.EntityPlayerSP
+import net.minecraft.entity.item.EntityArmorStand
+import net.minecraft.entity.item.EntityXPOrb
+import net.minecraft.entity.projectile.EntityFishHook
+import net.minecraftforge.event.entity.EntityJoinWorldEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class FishingHookDisplay {
+ private val config get() = SkyHanniMod.feature.fishing.fishingHookDisplay
+ private var bobberLocation: LorenzVec? = null
+ private var armorStand: EntityArmorStand? = null
+ private var display = ""
+
+ @SubscribeEvent
+ fun onTick(event: LorenzTickEvent) {
+ if (!isEnabled()) return
+ if (!event.repeatSeconds(1)) return
+
+ val entities = EntityUtils.getEntities<EntityFishHook>()
+ bobberLocation = entities.firstOrNull { it.angler is EntityPlayerSP }?.getLorenzVec()
+ }
+
+ @SubscribeEvent
+ fun onJoinWorld(event: EntityJoinWorldEvent) {
+ if (!isEnabled()) return
+ val entity = event.entity ?: return
+ if (entity is EntityXPOrb) return
+ val bobberLocation = bobberLocation ?: return
+
+ val distance = entity.getLorenzVec().distance(bobberLocation)
+ if (distance > 0.1) return
+ if (entity is EntityArmorStand) {
+ armorStand = entity
+ }
+ }
+
+ @SubscribeEvent
+ fun onCheckRender(event: CheckRenderEntityEvent<*>) {
+ if (!isEnabled()) return
+ if (!config.hideArmorStand) return
+
+ if (event.entity == armorStand) {
+ event.isCanceled = true
+ }
+ }
+
+ @SubscribeEvent
+ fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) {
+ if (!isEnabled()) return
+
+ val armorStand = armorStand ?: return
+ if (armorStand.isDead) return
+ if (!armorStand.hasCustomName()) return
+
+ config.position.renderString(armorStand.name, posLabel = "Fishing Hook Display")
+ }
+
+ fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled && FishingAPI.hasFishingRodInHand()
+}