diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-10-14 15:04:30 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-10-14 15:04:30 +0200 |
commit | 8152a3985c9b2f883030a1f8ee79a6f69570da76 (patch) | |
tree | 576247a2c8fc4a14c6dca428bc2a12967d172b59 /src/main/java/at/hannibal2 | |
parent | 5f220707f4b0a12addaef0ec80cc389f07d9ffcc (diff) | |
download | skyhanni-8152a3985c9b2f883030a1f8ee79a6f69570da76.tar.gz skyhanni-8152a3985c9b2f883030a1f8ee79a6f69570da76.tar.bz2 skyhanni-8152a3985c9b2f883030a1f8ee79a6f69570da76.zip |
Fixed fishing hook display showing wrongly damage numbers.
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/fishing/FishingHookDisplay.kt | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingHookDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingHookDisplay.kt index cf9b6141c..30a55a0ea 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingHookDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingHookDisplay.kt @@ -12,22 +12,25 @@ 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 bobber: EntityFishHook? = null private var bobberLocation: LorenzVec? = null private var armorStand: EntityArmorStand? = null + private val potentionArmorStands = mutableListOf<EntityArmorStand>() private var display = "" @SubscribeEvent fun onWorldChange(event: LorenzWorldChangeEvent) { display = "" bobberLocation = null + bobber = null armorStand = null + potentionArmorStands.clear() } @SubscribeEvent @@ -35,22 +38,37 @@ class FishingHookDisplay { if (!isEnabled()) return if (!event.isMod(config.debugUpdateInterval)) return + if (armorStand == null) { + val filter = potentionArmorStands.filter { it.hasCustomName() && it.hasCorrectName() } + if (filter.size == 1) { + armorStand = filter[0] + } + } + val entities = EntityUtils.getEntities<EntityFishHook>() - bobberLocation = entities.firstOrNull { it.angler is EntityPlayerSP }?.getLorenzVec() + val foundBobber = entities.firstOrNull { it.angler is EntityPlayerSP } + if (foundBobber != bobber) { + bobber = foundBobber + potentionArmorStands.clear() + armorStand = null + } + + if (bobber != null) { + bobberLocation = bobber?.getLorenzVec() + } } @SubscribeEvent fun onJoinWorld(event: EntityJoinWorldEvent) { if (!isEnabled()) return val entity = event.entity ?: return - if (entity is EntityXPOrb) return + if (entity !is EntityArmorStand) return val bobberLocation = bobberLocation ?: return val distance = entity.getLorenzVec().distance(bobberLocation) if (distance > config.debugMaxDistance) return - if (entity is EntityArmorStand) { - armorStand = entity - } + + potentionArmorStands.add(entity) } @SubscribeEvent @@ -74,5 +92,16 @@ class FishingHookDisplay { config.position.renderString(armorStand.name, posLabel = "Fishing Hook Display") } + private fun EntityArmorStand.hasCorrectName(): Boolean { + if (name == "§c§l!!!") { + return true + } + if (name.startsWith("§e§l")) { + return true + } + + return false + } + fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled && FishingAPI.hasFishingRodInHand() } |