aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-06-15 13:10:12 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-06-15 13:10:12 +0200
commit6b3e7ef0c4b56c36f62b48a4b93ae3186623e4cb (patch)
treec3ae29c7352185ab0e8c56461572c64a5143633c /src
parent8a91b0a9ea3b545f9433b5aa190891beabc3dad5 (diff)
downloadskyhanni-6b3e7ef0c4b56c36f62b48a4b93ae3186623e4cb.tar.gz
skyhanni-6b3e7ef0c4b56c36f62b48a4b93ae3186623e4cb.tar.bz2
skyhanni-6b3e7ef0c4b56c36f62b48a4b93ae3186623e4cb.zip
Added creeper veil ability cooldown
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt28
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt32
2 files changed, 39 insertions, 21 deletions
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 07745f573..69f5742b7 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
@@ -1,14 +1,16 @@
package at.hannibal2.skyhanni.features.itemabilities.abilitycooldown
+import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
enum class ItemAbility(
val abilityName: String,
- val cooldownInSeconds: Long,
+ private val cooldownInSeconds: Int,
vararg val itemNames: String,
- var lastClick: Long = 0L,
- var lastNewClick: Long = 0L,
- val actionBarDetection: Boolean = true,
+ var lastActivation: Long = 0L,
+ var specialColor: LorenzColor? = null,
+ var lastItemClick: Long = 0L,
+ val actionBarDetection: Boolean = true
) {
//TODO add into repo
@@ -31,6 +33,7 @@ enum class ItemAbility(
WEIRD_TUBA(20),
FIRE_FREEZE_STAFF(10),
SWORD_OF_BAD_HEALTH(5),
+ WITHER_CLOAK(10),
// doesn't have a sound
ENDER_BOW("Ender Warp", 30, "Ender Bow"),
@@ -44,22 +47,23 @@ enum class ItemAbility(
var newVariant = false
var internalNames = mutableListOf<String>()
- constructor(cooldownInSeconds: Int, vararg alternateInternalNames: String) : this("no name", cooldownInSeconds.toLong(), actionBarDetection = false) {
+ constructor(cooldownInSeconds: Int, vararg alternateInternalNames: String) : this("no name", cooldownInSeconds, actionBarDetection = false) {
newVariant = true
internalNames.addAll(alternateInternalNames)
internalNames.add(name)
}
- fun oldClick() {
- lastClick = System.currentTimeMillis()
+ fun activate(color: LorenzColor? = null, offset: Long = 0L) {
+ specialColor = color
+ lastActivation = System.currentTimeMillis() + offset
}
- fun isOnCooldown(): Boolean = lastClick + getCooldown() > System.currentTimeMillis()
+ fun isOnCooldown(): Boolean = lastActivation + getCooldown() > System.currentTimeMillis()
- fun getCooldown(): Long = cooldownInSeconds * 1000
+ fun getCooldown(): Long = 1000L * cooldownInSeconds
fun getDurationText(): String {
- var duration: Long = lastClick + getCooldown() - System.currentTimeMillis()
+ var duration: Long = lastActivation + getCooldown() - System.currentTimeMillis()
return if (duration < 1600) {
duration /= 100
var d = duration.toDouble()
@@ -72,9 +76,9 @@ enum class ItemAbility(
}
}
- fun newClick() {
+ fun setItemClick() {
// println("newClick $this")
- lastNewClick = System.currentTimeMillis()
+ lastItemClick = System.currentTimeMillis()
}
companion object {
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 25858be8f..9ae351da2 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
@@ -10,7 +10,6 @@ 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
@@ -128,7 +127,7 @@ class ItemAbilityCooldown {
private fun handleItemClick(itemInHand: ItemStack?) {
if (!LorenzUtils.inSkyBlock) return
itemInHand?.getInternalName()?.run {
- ItemAbility.getByInternalName(this)?.newClick()
+ ItemAbility.getByInternalName(this)?.setItemClick()
}
}
@@ -160,7 +159,7 @@ class ItemAbilityCooldown {
private fun click(ability: ItemAbility) {
if (ability.actionBarDetection) {
- ability.oldClick()
+ ability.activate()
}
}
@@ -181,10 +180,11 @@ class ItemAbilityCooldown {
if (ability != null) {
if (ability.isOnCooldown()) {
- val duration: Long = ability.lastClick + ability.getCooldown() - System.currentTimeMillis()
- val color = if (duration < 600) LorenzColor.RED else LorenzColor.YELLOW
+ val duration: Long = ability.lastActivation + ability.getCooldown() - System.currentTimeMillis()
+ val color = ability.specialColor ?: if (duration < 600) LorenzColor.RED else LorenzColor.YELLOW
items[stack] = ItemText(color, ability.getDurationText(), true)
} else {
+ ability.specialColor = null
items[stack] = ItemText(LorenzColor.GREEN, "R", false)
}
}
@@ -215,6 +215,22 @@ class ItemAbilityCooldown {
}
}
+ @SubscribeEvent
+ fun onChatMessage(event: LorenzChatEvent) {
+ val message = event.message
+ if (message == "§dCreeper Veil §r§aActivated!") {
+ ItemAbility.WITHER_CLOAK.activate(LorenzColor.LIGHT_PURPLE)
+ }
+ if (message == "§dCreeper Veil §r§cDe-activated! §r§8(Expired)" ||
+ message == "§cNot enough mana! §r§dCreeper Veil §r§cDe-activated!"
+ ) {
+ ItemAbility.WITHER_CLOAK.activate()
+ }
+ if (message == "§dCreeper Veil §r§cDe-activated!") {
+ ItemAbility.WITHER_CLOAK.activate(null, -5000L)
+ }
+ }
+
private fun hasAbility(stack: ItemStack): ItemAbility? {
val itemName: String = stack.cleanName()
val internalName = stack.getInternalName()
@@ -236,11 +252,9 @@ class ItemAbilityCooldown {
}
private fun ItemAbility.sound() {
- val lastNewClick = lastNewClick
- val ping = System.currentTimeMillis() - lastNewClick
-// println("$this click ($ping)")
+ val ping = System.currentTimeMillis() - lastItemClick
if (ping < 400) {
- oldClick()
+ activate()
}
}