aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/dulkirfabric/features/CooldownDisplays.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/com/dulkirfabric/features/CooldownDisplays.kt')
-rw-r--r--src/main/kotlin/com/dulkirfabric/features/CooldownDisplays.kt13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/features/CooldownDisplays.kt b/src/main/kotlin/com/dulkirfabric/features/CooldownDisplays.kt
index 86a3863..2188bf4 100644
--- a/src/main/kotlin/com/dulkirfabric/features/CooldownDisplays.kt
+++ b/src/main/kotlin/com/dulkirfabric/features/CooldownDisplays.kt
@@ -1,5 +1,6 @@
package com.dulkirfabric.features
+import com.dulkirfabric.config.DulkirConfig
import com.dulkirfabric.events.PlaySoundEvent
import com.dulkirfabric.events.WorldLoadEvent
import com.dulkirfabric.util.SoundInfo
@@ -7,31 +8,32 @@ import com.dulkirfabric.util.TrackedCooldown
import meteordevelopment.orbit.EventHandler
import net.minecraft.item.ItemStack
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable
+import kotlin.math.round
object CooldownDisplays {
private val trackedCooldowns: Map<SoundInfo, TrackedCooldown> = mapOf(
Pair(
- SoundInfo("mob.zombie.remedy", 1f, .5f),
+ SoundInfo("entity.zombie_villager.cure", 1f, .5f),
TrackedCooldown("(REAPER_CHESTPLATE)|(REAPER_LEGGINGS)|(REAPER_BOOTS)".toRegex(), 25000, 0)
),
Pair(
- SoundInfo("mob.zombie.remedy", 0.6984127f, 1f),
+ SoundInfo("entity.zombie_villager.cure", 0.6984127f, 1f),
TrackedCooldown("(HYPERION|ASTRAEA|SCYLLA|VALKYRIE)".toRegex(), 5000, 0)
)
)
fun shouldDisplay(stack: ItemStack, cir: CallbackInfoReturnable<Boolean>) {
val cooldown = fetchCooldownItem(stack) ?: return
- cir.returnValue = true
- // cir.returnValue = System.currentTimeMillis() - cooldown.lastUsage < cooldown.cooldownDuration
+ cir.returnValue = System.currentTimeMillis() - cooldown.lastUsage < cooldown.cooldownDuration
}
fun calcDurability(stack: ItemStack, cir: CallbackInfoReturnable<Int>) {
val cooldown = fetchCooldownItem(stack) ?: return
- cir.returnValue = 300
+ cir.returnValue = round(13f * (System.currentTimeMillis() - cooldown.lastUsage) / cooldown.cooldownDuration).toInt()
}
@EventHandler
fun onSound(event: PlaySoundEvent) {
+ if (!DulkirConfig.configOptions.duraCooldown) return
val path = event.sound.id.path
val pitch = event.sound.pitch
val volume = event.sound.volume
@@ -43,6 +45,7 @@ object CooldownDisplays {
@EventHandler
fun onWorldLoad(event: WorldLoadEvent) {
+ if (!DulkirConfig.configOptions.duraCooldown) return
trackedCooldowns.forEach {
it.value.lastUsage = 0
}