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 @@ -116,6 +116,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.dungeon.TerracottaPhase
Expand Down Expand Up @@ -821,6 +822,7 @@ class SkyHanniMod {
loadModule(LimboPlaytime())
loadModule(RareDropMessages())
loadModule(CraftMaterialsFromBazaar())
loadModule(DungeonShadowAssassinNotification())
loadModule(PestProfitTracker)
loadModule(NoBitsWarning())

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

@Expose
@ConfigOption(name = "SA Jump Notification", desc = "Notifies you when a Shadow Assassin is about " +
"to jump on you.")
@ConfigEditorBoolean
@FeatureToggle
public boolean shadowAssassinJumpNotifier = false;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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.mixins.transformers.AccessorWorldBoarderPacket
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 kotlin.time.Duration.Companion.seconds

class DungeonShadowAssassinNotification {
private val config get() = SkyHanniMod.feature.dungeon

@SubscribeEvent
fun onWorldBoarderChange(event: PacketEvent.ReceiveEvent) {
if (!isEnabled()) return
if (DungeonAPI.dungeonFloor?.contains("3") == true && DungeonAPI.inBossRoom) return

val packet = event.packet as? AccessorWorldBoarderPacket ?: return
val action = packet.action
val warningTime = packet.warningTime

if (action == S44PacketWorldBorder.Action.INITIALIZE && warningTime == 10000) {
TitleManager.sendTitle("§cShadow Assassin Jumping!", 2.seconds, 3.6, 7.0f)
SoundUtils.playBeepSound()
}
}

private fun isEnabled() = LorenzUtils.inDungeons && config.shadowAssassinJumpNotifier
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package at.hannibal2.skyhanni.mixins.transformers;

import net.minecraft.network.play.server.S44PacketWorldBorder;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(S44PacketWorldBorder.class)
public interface AccessorWorldBoarderPacket {
@Accessor("action")
S44PacketWorldBorder.Action getAction();

@Accessor("warningTime")
int getWarningTime();
}
Loading