Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Shadow Assassin Jump Notification #852

Merged
merged 14 commits into from
Apr 5, 2024
Merged
2 changes: 2 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ import at.hannibal2.skyhanni.features.dungeon.DungeonHighlightClickedBlocks
import at.hannibal2.skyhanni.features.dungeon.DungeonLividFinder
import at.hannibal2.skyhanni.features.dungeon.DungeonMilestonesDisplay
import at.hannibal2.skyhanni.features.dungeon.DungeonRankTabListColor
import at.hannibal2.skyhanni.features.dungeon.DungeonShadowAssassinNotification
import at.hannibal2.skyhanni.features.dungeon.DungeonTeammateOutlines
import at.hannibal2.skyhanni.features.dungeon.HighlightDungeonDeathmite
import at.hannibal2.skyhanni.features.event.UniqueGiftingOpportunitiesFeatures
Expand Down Expand Up @@ -694,6 +695,7 @@ class SkyHanniMod {
loadModule(NewYearCakeReminder())
loadModule(HighlightInquisitors())
loadModule(VerminTracker)
loadModule(DungeonShadowAssassinNotification())

init()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,11 @@ public class DungeonConfig {
@ConfigEditorBoolean
@FeatureToggle
public boolean croesusUnopenedChestTracker = true;

@Expose
@ConfigOption(name = "SA Jump Notify", desc = "Notifies you when a Shadow Assassin is about" +
"to jump on you.")
@ConfigEditorBoolean
@FeatureToggle
public boolean shadowAssassinJumpNotifier = true;
CalMWolfs marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package at.hannibal2.skyhanni.features.dungeon

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.TitleManager
import at.hannibal2.skyhanni.events.PacketEvent
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.SoundUtils
import net.minecraft.network.play.server.S44PacketWorldBorder
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.lang.reflect.Field
import kotlin.time.Duration.Companion.seconds

class DungeonShadowAssassinNotification {
@SubscribeEvent
fun onWorldBoarderChange(event: PacketEvent.ReceiveEvent) {
if (!LorenzUtils.inSkyBlock || !LorenzUtils.inDungeons) return
if (!SkyHanniMod.feature.dungeon.shadowAssassinJumpNotifier) return
//F7 and maybe newer, currently not released, floors have shadow assassins, so they are allowed to be listed here
val disable = if (DungeonAPI.dungeonFloor == null) true else DungeonAPI.dungeonFloor!!.contains("7")
if (DungeonAPI.inBossRoom && disable) return
CarsCupcake marked this conversation as resolved.
Show resolved Hide resolved
if (event.packet !is S44PacketWorldBorder) return
val packet: S44PacketWorldBorder = event.packet
//Did not find another way to read the packet :/
val action: Field = packet.javaClass.getDeclaredField("field_179795_a")
action.isAccessible = true
val warningTime: Field = packet.javaClass.getDeclaredField("field_179796_h")
warningTime.isAccessible = true
CarsCupcake marked this conversation as resolved.
Show resolved Hide resolved
if (action.get(packet) == S44PacketWorldBorder.Action.INITIALIZE && warningTime.getInt(packet) == 10000){
TitleManager.sendTitle("§cShadow Assassin Jump!", 2.seconds, 3.6, 7.0)
SoundUtils.playBeepSound()
}
}
}