aboutsummaryrefslogtreecommitdiff
path: root/src/main
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
parent99f7e28332662f44996e73194b9d5ea0c38e89b3 (diff)
downloadskyhanni-0344ab23929f77f4f339cb0dc83d84d3f118d679.tar.gz
skyhanni-0344ab23929f77f4f339cb0dc83d84d3f118d679.tar.bz2
skyhanni-0344ab23929f77f4f339cb0dc83d84d3f118d679.zip
Added Living Metal Helper
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/TitleData.kt21
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/TitleReceivedEvent.kt6
-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
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt2
9 files changed, 117 insertions, 31 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index ea5c42911..7d778f99d 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -156,6 +156,7 @@ class SkyHanniMod {
loadModule(GardenCropMilestoneAverage())
loadModule(GardenCropSpeed)
loadModule(ProfileStorageData)
+ loadModule(TitleData())
// APIs
loadModule(BazaarApi())
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java
index 3fde81172..11b415cfa 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java
@@ -469,14 +469,14 @@ public class RiftConfig {
}
@Expose
- @ConfigOption(name = "Living Metal Helper", desc = "")
+ @ConfigOption(name = "Defense Blocks", desc = "")
@Accordion
public DefenseBlockConfig defenseBlockConfig = new DefenseBlockConfig();
public static class DefenseBlockConfig {
@Expose
- @ConfigOption(name = "Defense Blocks", desc = "Show a line between Defense blocks and the mob and highlight the blocks.")
+ @ConfigOption(name = "Enabled", desc = "Show a line between Defense blocks and the mob and highlight the blocks.")
@ConfigEditorBoolean
public boolean enabled = true;
@@ -500,10 +500,15 @@ public class RiftConfig {
public static class LivingCaveLivingMetalConfig {
@Expose
- @ConfigOption(name = "Living Metal", desc = "Show the Living Metal.")
+ @ConfigOption(name = "Living Metal", desc = "Show a moving animation between Living Metal and the next block.")
@ConfigEditorBoolean
public boolean enabled = true;
+ @Expose
+ @ConfigOption(name = "Hide Particles", desc = "Hide particles Living Metal")
+ @ConfigEditorBoolean
+ public boolean hideParticles = false;
+
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/data/TitleData.kt b/src/main/java/at/hannibal2/skyhanni/data/TitleData.kt
new file mode 100644
index 000000000..fe776c8d0
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/data/TitleData.kt
@@ -0,0 +1,21 @@
+package at.hannibal2.skyhanni.data
+
+import at.hannibal2.skyhanni.events.PacketEvent
+import at.hannibal2.skyhanni.events.TitleReceivedEvent
+import net.minecraft.network.play.server.S45PacketTitle
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class TitleData {
+
+ @SubscribeEvent
+ fun onReceiveCurrentShield(event: PacketEvent.ReceiveEvent) {
+ val packet = event.packet
+
+ if (packet !is S45PacketTitle) return
+ val message = packet.message ?: return
+ val formattedText = message.formattedText
+ if (TitleReceivedEvent(formattedText).postAndCatch()) {
+ event.isCanceled = true
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/events/TitleReceivedEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/TitleReceivedEvent.kt
new file mode 100644
index 000000000..76961ccf6
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/TitleReceivedEvent.kt
@@ -0,0 +1,6 @@
+package at.hannibal2.skyhanni.events
+
+import net.minecraftforge.fml.common.eventhandler.Cancelable
+
+@Cancelable
+class TitleReceivedEvent(val title: String): LorenzEvent() \ No newline at end of file
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
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt
index ba1c0d8ac..503975822 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt
@@ -5,7 +5,7 @@ import at.hannibal2.skyhanni.data.ClickType
import at.hannibal2.skyhanni.events.BlockClickEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
-import at.hannibal2.skyhanni.events.PacketEvent
+import at.hannibal2.skyhanni.events.TitleReceivedEvent
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LocationUtils
@@ -18,7 +18,6 @@ import net.minecraft.client.Minecraft
import net.minecraft.client.gui.ScaledResolution
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.item.ItemStack
-import net.minecraft.network.play.server.S45PacketTitle
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
@@ -175,17 +174,12 @@ class BlazeSlayerDaggerHelper {
}
@SubscribeEvent
- fun onReceiveCurrentShield(event: PacketEvent.ReceiveEvent) {
+ fun onTitleReceived(event: TitleReceivedEvent) {
if (!isEnabled()) return
- val packet = event.packet
-
- if (packet !is S45PacketTitle) return // TODO add a title event
- val message = packet.message ?: return
- val formattedText = message.formattedText
for (shield in HellionShield.values()) {
- if (shield.formattedName + "§r" == formattedText) {
+ if (shield.formattedName + "§r" == event.title) {
Dagger.values().filter { shield in it.shields }.forEach {
it.shields.forEach { shield -> shield.active = false }
it.updated = true
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
index 7380c4c37..46f273b2d 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
@@ -96,6 +96,8 @@ data class LorenzVec(
fun round(decimals: Int) = LorenzVec(x.round(decimals), y.round(decimals), z.round(decimals))
+ fun slope(other: LorenzVec, factor: Double) = add(other.subtract(this).scale(factor))
+
fun roundLocation(): LorenzVec {
val x = if (this.x < 0) x.toInt().toDouble() - 1 else x.toInt().toDouble()
val y = y.toInt().toDouble() - 1
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt b/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt
index 73a529cbc..410c29aca 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt
@@ -141,7 +141,7 @@ class ParkourHelper(
if (LocationUtils.playerLocation().distance(nextPosition) > currentPosition.distance(nextPosition)) return null
val factor = LocationUtils.playerLocation().distance(currentPosition) / currentPosition.distance(nextPosition)
- val solpeLocation = lookAheadStart.add(lookAheadEnd.subtract(lookAheadStart).scale(factor))
+ val solpeLocation = lookAheadStart.slope(lookAheadEnd, factor)
return Pair(
IndexedValue(current + lookAhead - 1, lookAheadStart),
IndexedValue(current + lookAhead, solpeLocation)