aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/ItemClickEvent.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/HighlightBonzoMasks.kt57
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt44
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt89
5 files changed, 152 insertions, 53 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt b/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt
index a2a22a865..fc68e1a52 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt
@@ -2,12 +2,14 @@ package at.hannibal2.skyhanni.data
import at.hannibal2.skyhanni.events.BlockClickEvent
import at.hannibal2.skyhanni.events.EntityClickEvent
+import at.hannibal2.skyhanni.events.ItemClickEvent
import at.hannibal2.skyhanni.events.PacketEvent
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.toLorenzVec
import net.minecraft.client.Minecraft
import net.minecraft.network.play.client.C07PacketPlayerDigging
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement
+import net.minecraft.network.play.client.C0APacketAnimation
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.InputEvent
import org.lwjgl.input.Mouse
@@ -21,11 +23,14 @@ class ItemClickData {
val position = packet.position.toLorenzVec()
BlockClickEvent(ClickType.RIGHT_CLICK, position, packet.stack).postAndCatch()
}
+ val itemInHand = Minecraft.getMinecraft().thePlayer.heldItem
if (packet is C07PacketPlayerDigging && packet.status == C07PacketPlayerDigging.Action.START_DESTROY_BLOCK) {
val position = packet.position.toLorenzVec()
- val itemInHand = Minecraft.getMinecraft().thePlayer.heldItem
BlockClickEvent(ClickType.LEFT_CLICK, position, itemInHand).postAndCatch()
}
+ if (packet is C0APacketAnimation) {
+ ItemClickEvent(itemInHand).postAndCatch()
+ }
}
@SubscribeEvent
diff --git a/src/main/java/at/hannibal2/skyhanni/events/ItemClickEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/ItemClickEvent.kt
new file mode 100644
index 000000000..7b12f60cb
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/ItemClickEvent.kt
@@ -0,0 +1,8 @@
+package at.hannibal2.skyhanni.events
+
+import at.hannibal2.skyhanni.data.ClickType
+import at.hannibal2.skyhanni.utils.BlockUtils.getBlockStateAt
+import at.hannibal2.skyhanni.utils.LorenzVec
+import net.minecraft.item.ItemStack
+
+class ItemClickEvent(val itemInHand: ItemStack?) : LorenzEvent() \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HighlightBonzoMasks.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HighlightBonzoMasks.kt
index 371c0578d..ea1548117 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HighlightBonzoMasks.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HighlightBonzoMasks.kt
@@ -5,15 +5,13 @@ import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.RenderUtils.interpolate
+import net.minecraft.item.ItemStack
import net.minecraftforge.client.event.ClientChatReceivedEvent
import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.awt.Color
+import kotlin.time.*
import kotlin.time.Duration.Companion.seconds
-import kotlin.time.DurationUnit
-import kotlin.time.ExperimentalTime
-import kotlin.time.TimeMark
-import kotlin.time.TimeSource
/**
* @author Linnea Gräf
@@ -21,11 +19,14 @@ import kotlin.time.TimeSource
@OptIn(ExperimentalTime::class)
class HighlightBonzoMasks {
- val bonzoMaskTimers = mutableMapOf<String, TimeMark>()
+ val maskTimers = mutableMapOf<String, CooldownTimer>()
// Technically this timer is overestimating since the cooldown is affected by mage level, however I do not care.
val bonzoMaskCooldown = 360.seconds
- val bonzoMaskMessage = "Your (.*Bonzo's Mask) saved your life!".toRegex()
+ val bonzoMaskMessage = "^Your (.*Bonzo's Mask) saved your life!$".toRegex()
+
+ val spiritMaskCooldown = 30.seconds
+ val spiritMaskMessage = "^Second Wind Activated! Your Spirit Mask saved your life!$".toRegex()
val greenHue = Color.RGBtoHSB(0, 255, 0, null)[0].toDouble()
val redHue = Color.RGBtoHSB(255, 0, 0, null)[0].toDouble()
@@ -35,27 +36,47 @@ class HighlightBonzoMasks {
if (!SkyHanniMod.feature.inventory.highlightDepletedBonzosMasks) return
for (slot in event.gui.inventorySlots.inventorySlots) {
val item = slot.stack ?: continue
- val internalName = item.getInternalName()
- if (!internalName.endsWith("BONZO_MASK")) continue
- val timer = bonzoMaskTimers[internalName] ?: continue
- if (timer.elapsedNow() < bonzoMaskCooldown) {
- val progress =
- timer.elapsedNow().toDouble(DurationUnit.SECONDS) / bonzoMaskCooldown.toDouble(DurationUnit.SECONDS)
- val hue = interpolate(greenHue, redHue, progress.toFloat())
+ val maskType = maskType(item) ?: continue
+ val timer = maskTimers[maskType] ?: continue
+ if (timer.isActive) {
+ val hue = interpolate(greenHue, redHue, timer.percentComplete.toFloat())
slot.highlight(Color(Color.HSBtoRGB(hue.toFloat(), 1F, 1F)))
}
}
}
+ private fun maskType(item: ItemStack): String? {
+ return when (item.getInternalName()) {
+ "STARRED_BONZO_MASK" -> "BONZO_MASK"
+ "BONZO_MASK" -> "BONZO_MASK"
+ "SPIRIT_MASK" -> "SPIRIT_MASK"
+ else -> null
+ }
+ }
+
@SubscribeEvent
fun onChatReceived(event: ClientChatReceivedEvent) {
- val match = bonzoMaskMessage.matchEntire(event.message.unformattedText) ?: return
- val bonzoId = if ("⚚" in match.groupValues[1]) "STARRED_BONZO_MASK" else "BONZO_MASK"
- bonzoMaskTimers[bonzoId] = TimeSource.Monotonic.markNow()
+ val message = event.message.unformattedText
+ if (bonzoMaskMessage.matches(message)) {
+ maskTimers["BONZO_MASK"] = CooldownTimer(TimeSource.Monotonic.markNow(), bonzoMaskCooldown)
+ } else if (spiritMaskMessage.matches(message)) {
+ maskTimers["SPIRIT_MASK"] = CooldownTimer(TimeSource.Monotonic.markNow(), spiritMaskCooldown)
+ }
}
@SubscribeEvent
fun onJoinWorld(ignored: WorldEvent.Load) {
- bonzoMaskTimers.clear()
+ maskTimers.clear()
}
-} \ No newline at end of file
+
+ companion object {
+ data class CooldownTimer(val timeMark: TimeMark, val duration: Duration) {
+ val percentComplete: Double get() =
+ timeMark.elapsedNow().toDouble(DurationUnit.SECONDS) / duration.toDouble(DurationUnit.SECONDS)
+
+ val isActive: Boolean get() = timeMark.elapsedNow() < duration
+
+ }
+ }
+}
+
diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt
index aca78fd0a..07745f573 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt
@@ -17,35 +17,29 @@ enum class ItemAbility(
GIANTS_SWORD(30),
ICE_SPRAY_WAND(5),
ATOMSPLIT_KATANA(4, "VORPAL_KATANA", "VOIDEDGE_KATANA"),
-
-
- // TODO replace old logic
-
- HEAL_1("Small Heal", 7, "Wand of Healing"),
- HEAL_2("Medium Heal", 7, "Wand of Mending"),
- HEAL_3("Big Heal", 7, "Wand of Restoration"),
- HEAL_4("Huge Heal", 7, "Wand of Atonement"),
-
- STAR_FALL("Starfall", 2, "Starlight Wand"),
- VODOO_DOLL("Acupuncture", 5, "Voodoo Doll"),
- INK_WAND("Ink Bomb", 30, "Ink Wand"),
- GOLEM_SWORD("Iron Punch", 3, "Golem Sword"),
- EMBER_ROD("Fire Blast", 30, "Ember Rod"),
+ RAGNAROCK_AXE(20),
+ WAND_OF_ATONEMENT(7, "WAND_OF_HEALING", "WAND_OF_MENDING", "WAND_OF_RESTORATION"),
+
+ GOLEM_SWORD(3),
+ END_STONE_SWORD(5),
+ SOUL_ESOWARD(20),
+ PIGMAN_SWORD(5),
+ EMBER_ROD(30),
+ STAFF_OF_THE_VOLCANO(30),
+ STARLIGHT_WAND(2),
+ VOODOO_DOLL(5),
+ WEIRD_TUBA(20),
+ FIRE_FREEZE_STAFF(10),
+ SWORD_OF_BAD_HEALTH(5),
+
+ // doesn't have a sound
ENDER_BOW("Ender Warp", 30, "Ender Bow"),
-
LIVID_DAGGER("Throw", 5, "Livid Dagger"),
- WEIRD_TUBA("Howl", 20, "Weird Tuba"),
-
- ENDSTONE_SWORD("Extreme Focus", 5, "End Stone Sword"),
- PIGMAN_SWORD("Burning Souls", 5, "Pigman Sword"),
-
- SOULWARD("Soulward", 20, "Soul Esoward"),
- ECHO("Echo", 3, "Ancestral Spade"),
-
FIRE_VEIL("Fire Veil", 5, "Fire Veil Wand"),
- //TODO add new crimson isle weapons
+ INK_WAND("Ink Bomb", 30, "Ink Wand"),
- ;
+ // doesn't have a consistent sound
+ ECHO("Echo", 3, "Ancestral Spade");
var newVariant = false
var internalNames = mutableListOf<String>()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt
index f96fce3f1..25858be8f 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt
@@ -2,10 +2,7 @@ package at.hannibal2.skyhanni.features.itemabilities.abilitycooldown
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.ItemRenderBackground.Companion.background
-import at.hannibal2.skyhanni.events.BlockClickEvent
-import at.hannibal2.skyhanni.events.LorenzActionBarEvent
-import at.hannibal2.skyhanni.events.PlaySoundEvent
-import at.hannibal2.skyhanni.events.RenderItemTipEvent
+import at.hannibal2.skyhanni.events.*
import at.hannibal2.skyhanni.utils.ItemUtils
import at.hannibal2.skyhanni.utils.ItemUtils.cleanName
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
@@ -13,6 +10,7 @@ import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.between
import net.minecraft.client.Minecraft
+import net.minecraft.item.Item
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
@@ -50,15 +48,88 @@ class ItemAbilityCooldown {
ItemAbility.ATOMSPLIT_KATANA.sound()
}
}
+ if (event.soundName == "random.click") {
+ if (event.pitch == 2.0f && event.volume == 0.55f) {
+ ItemAbility.RAGNAROCK_AXE.sound()
+ }
+ }
+ if (event.soundName == "liquid.lavapop") {
+ if (event.pitch == 0.7619048f && event.volume == 0.15f) {
+ ItemAbility.WAND_OF_ATONEMENT.sound()
+ }
+ }
+ if (event.soundName == "mob.bat.hurt") {
+ if (event.volume == 0.1f) {
+ ItemAbility.STARLIGHT_WAND.sound()
+ }
+ }
+ if (event.soundName == "mob.guardian.curse") {
+ if (event.volume == 0.2f) {
+ ItemAbility.VOODOO_DOLL.sound()
+ }
+ }
+ if (event.soundName == "random.explode") {
+ if (event.pitch == 4.047619f && event.volume == 0.2f) {
+ ItemAbility.GOLEM_SWORD.sound()
+ }
+ }
+ if (event.soundName == "mob.wolf.howl") {
+ if (event.volume == 0.5f) {
+ ItemAbility.WEIRD_TUBA.sound()
+ }
+ }
+ if (event.soundName == "mob.zombie.unfect") {
+ if (event.pitch == 2.0f && event.volume == 0.3f) {
+ ItemAbility.END_STONE_SWORD.sound()
+ }
+ }
+ if (event.soundName == "mob.wolf.panting") {
+ if (event.pitch == 1.3968254f && event.volume == 0.4f) {
+ ItemAbility.SOUL_ESOWARD.sound()
+ }
+ }
+ if (event.soundName == "mob.zombiepig.zpigangry") {
+ if (event.pitch == 2.0f && event.volume == 0.3f) {
+ ItemAbility.PIGMAN_SWORD.sound()
+ }
+ }
+ if (event.soundName == "mob.ghast.fireball") {
+ if (event.pitch == 1.0f && event.volume == 0.3f) {
+ ItemAbility.EMBER_ROD.sound()
+ }
+ }
+ if (event.soundName == "mob.guardian.elder.idle") {
+ if (event.pitch == 2.0f && event.volume == 0.2f) {
+ ItemAbility.FIRE_FREEZE_STAFF.sound()
+ }
+ }
+ if (event.soundName == "random.explode") {
+ if (event.pitch == 0.4920635f && event.volume == 0.5f) {
+ ItemAbility.STAFF_OF_THE_VOLCANO.sound()
+ }
+ }
+ if (event.soundName == "random.eat") {
+ if (event.pitch == 1.0f && event.volume == 1.0f) {
+ ItemAbility.STAFF_OF_THE_VOLCANO.sound()
+ }
+ }
}
@SubscribeEvent
- fun onItemClickSend(event: BlockClickEvent) {
- if (!LorenzUtils.inSkyBlock) return
- val heldItem = event.itemInHand ?: return
+ fun onBlockClickSend(event: BlockClickEvent) {
+ handleItemClick(event.itemInHand)
+ }
+
+ @SubscribeEvent
+ fun onItemClick(event: ItemClickEvent) {
+ handleItemClick(event.itemInHand)
+ }
- val internalName = heldItem.getInternalName()
- ItemAbility.getByInternalName(internalName)?.newClick()
+ private fun handleItemClick(itemInHand: ItemStack?) {
+ if (!LorenzUtils.inSkyBlock) return
+ itemInHand?.getInternalName()?.run {
+ ItemAbility.getByInternalName(this)?.newClick()
+ }
}
@SubscribeEvent