aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/rift
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-07-12 04:48:34 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-07-12 04:48:34 +0200
commit0344ab23929f77f4f339cb0dc83d84d3f118d679 (patch)
tree251ed441be010d365a0c6d5bd3921eca702cdb3a /src/main/java/at/hannibal2/skyhanni/features/rift
parent99f7e28332662f44996e73194b9d5ea0c38e89b3 (diff)
downloadskyhanni-0344ab23929f77f4f339cb0dc83d84d3f118d679.tar.gz
skyhanni-0344ab23929f77f4f339cb0dc83d84d3f118d679.tar.bz2
skyhanni-0344ab23929f77f4f339cb0dc83d84d3f118d679.zip
Added Living Metal Helper
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/rift')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveLivingMetalHelper.kt88
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/DanceRoomHelper.kt5
2 files changed, 75 insertions, 18 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveLivingMetalHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveLivingMetalHelper.kt
index 696479a37..352e8270b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveLivingMetalHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveLivingMetalHelper.kt
@@ -1,32 +1,92 @@
package at.hannibal2.skyhanni.features.rift.area.livingcave
+import at.hannibal2.skyhanni.data.ClickType
+import at.hannibal2.skyhanni.events.BlockClickEvent
+import at.hannibal2.skyhanni.events.ReceiveParticleEvent
import at.hannibal2.skyhanni.events.ServerBlockChangeEvent
+import at.hannibal2.skyhanni.events.TitleReceivedEvent
import at.hannibal2.skyhanni.features.rift.everywhere.RiftAPI
+import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
+import at.hannibal2.skyhanni.utils.LorenzColor
+import at.hannibal2.skyhanni.utils.LorenzVec
+import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class LivingCaveLivingMetalHelper {
private val config get() = RiftAPI.config.area.livingCaveConfig.livingCaveLivingMetalConfig
+ private var lastClicked: LorenzVec? = null
+ private var pair: Pair<LorenzVec, LorenzVec>? = null
+ private var startTime = 0L
+
+ @SubscribeEvent
+ fun onBlockClick(event: BlockClickEvent) {
+ if (!isEnabled()) return
+ if (event.clickType == ClickType.LEFT_CLICK) {
+ val name = event.getBlockState.block.toString()
+ if (name.contains("lapis_ore")) {
+ lastClicked = event.position
+ }
+ }
+ }
@SubscribeEvent
fun onBlockChange(event: ServerBlockChangeEvent) {
+ if (!isEnabled()) return
val location = event.location
- val old = event.old
- val new = event.new
- val distanceToPlayer = location.distanceToPlayer()
+ if (location.distanceToPlayer() >= 7) return
+
+ if (event.old == "lapis_ore") {
+ pair?.let {
+ if (it.second == location) {
+ pair = null
+ }
+ }
+ }
+
+ if (event.new != "lapis_ore") return
- if (distanceToPlayer < 10) {
- if (old == "lapis_ore" || new == "lapis_ore") {
- println("block change: $old -> $new")
+ lastClicked?.let {
+ val distance = location.distance(it)
+ if (distance < 2) {
+ pair = Pair(it, location)
+ startTime = System.currentTimeMillis()
}
-// if (old == "wool") return
-// if (new == "wool") return
-// if (old == "lapis_block") return
-// if (new == "lapis_block") return
-// if (old == "stained_glass" && new == "stone") return
-// if (old == "stone" && new == "stained_glass") return
-// if (old == "stained_glass" && new == "stained_hardened_clay") return
-// println("block change: $old -> $new")
}
}
+
+ @SubscribeEvent
+ fun onRenderWorld(event: RenderWorldLastEvent) {
+ if (!isEnabled()) return
+ val (a, b) = pair ?: return
+ val maxTime = 500
+ val diff = startTime + maxTime - System.currentTimeMillis()
+ val location = if (diff > 0) {
+ val percentage = diff.toDouble() / maxTime
+ a.slope(b, 1 - percentage)
+ } else b
+ event.drawWaypointFilled(location, LorenzColor.AQUA.toColor(), seeThroughBlocks = true)
+ }
+
+ @SubscribeEvent
+ fun onReceiveParticle(event: ReceiveParticleEvent) {
+ if (!isEnabled()) return
+ if (!config.hideParticles) return
+
+ pair?.let {
+ if (it.second.distance(event.location) < 3) {
+ event.isCanceled = true
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onTitleReceived(event: TitleReceivedEvent) {
+ if (!isEnabled()) return
+ if (event.title.contains("Living Metal")) {
+ pair = null
+ }
+ }
+
+ fun isEnabled() = RiftAPI.inRift() && RiftAPI.inLivingCave() && config.enabled
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/DanceRoomHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/DanceRoomHelper.kt
index e84b668ed..dc12c0c22 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/DanceRoomHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/DanceRoomHelper.kt
@@ -9,7 +9,6 @@ import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase
import at.hannibal2.skyhanni.utils.jsonobjects.DanceRoomInstructionsJson
import kotlinx.coroutines.*
import net.minecraft.client.entity.EntityOtherPlayerMP
-import net.minecraft.network.play.server.S45PacketTitle
import net.minecraft.util.AxisAlignedBB
import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -112,10 +111,8 @@ object DanceRoomHelper {
}
@SubscribeEvent
- fun onPacket(event: PacketEvent.ReceiveEvent) {
+ fun onTitleReceived(event: TitleReceivedEvent) {
if (!isEnabled()) return
- val packet = event.packet
- if (packet !is S45PacketTitle) return // TODO add a title event
if (config.hideOriginalTitle && inRoom) event.isCanceled = true
}