diff options
author | MrFast <78495381+MrFast-js@users.noreply.github.com> | 2024-02-16 03:56:33 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-16 09:56:33 +0100 |
commit | 40745b8f209d16a9adbc0a21931d5f466c92c646 (patch) | |
tree | 9c6b0b163eea2108c43843b9aa377aa568c43638 /src/main/java/at/hannibal2/skyhanni/features | |
parent | 24b0c5f7313fd3f91e4f6e7686b6bac8c38d7750 (diff) | |
download | skyhanni-40745b8f209d16a9adbc0a21931d5f466c92c646.tar.gz skyhanni-40745b8f209d16a9adbc0a21931d5f466c92c646.tar.bz2 skyhanni-40745b8f209d16a9adbc0a21931d5f466c92c646.zip |
Crimson Isle Volcano Geyser features. #980
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/GeyserFishing.kt | 75 |
1 files changed, 75 insertions, 0 deletions
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 new file mode 100644 index 000000000..dd38b96f1 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/GeyserFishing.kt @@ -0,0 +1,75 @@ +package at.hannibal2.skyhanni.features.fishing.trophy + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.events.FishingBobberCastEvent +import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent +import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.utils.LocationUtils.distanceTo +import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland +import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.RenderUtils.drawFilledBoundingBox_nea +import at.hannibal2.skyhanni.utils.SpecialColour +import net.minecraft.entity.projectile.EntityFishHook +import net.minecraft.util.AxisAlignedBB +import net.minecraft.util.EnumParticleTypes +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.awt.Color + +class GeyserFishing { + private val config get() = SkyHanniMod.feature.fishing.trophyFishing.geyserOptions + + private var bobber: EntityFishHook? = null + private var geyser: LorenzVec? = null + private var geyserBox: AxisAlignedBB? = null + + @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) + fun onReceiveParticle(event: ReceiveParticleEvent) { + if (!shouldProcessParticles() || event.type != EnumParticleTypes.CLOUD) return + + geyser = event.location + val potentialGeyser = geyser ?: return + + geyserBox = AxisAlignedBB( + potentialGeyser.x - 2, 118.0 - 0.1, potentialGeyser.z - 2, + potentialGeyser.x + 2, 118.0 - 0.09, potentialGeyser.z + 2 + ) + + if (config.hideParticles && bobber != null) { + hideGeyserParticles(event) + } + } + + @SubscribeEvent + fun onWorldChange(event: LorenzWorldChangeEvent) { + bobber = null + geyser = null + geyserBox = null + } + + @SubscribeEvent + fun onBobberThrow(event: FishingBobberCastEvent) { + bobber = event.bobber + } + + @SubscribeEvent + fun onRenderWorld(event: LorenzRenderWorldEvent) { + if (!config.drawBox || !IslandType.CRIMSON_ISLE.isInIsland()) return + val geyserBox = geyserBox ?: return + val color = Color(SpecialColour.specialToChromaRGB(config.boxColor), true) + event.drawFilledBoundingBox_nea(geyserBox, color) + } + + private fun hideGeyserParticles(event: ReceiveParticleEvent) { + val bobber = bobber ?: return + val geyser = geyser ?: return + + if (bobber.distanceTo(event.location) < 3 && bobber.distanceTo(geyser) < 3) { + event.isCanceled = true + } + } + + private fun shouldProcessParticles() = IslandType.CRIMSON_ISLE.isInIsland() && (config.hideParticles || config.drawBox) +} |