diff options
| author | Linnea Gräf <nea@nea.moe> | 2025-09-06 01:30:45 +0200 |
|---|---|---|
| committer | Linnea Gräf <nea@nea.moe> | 2025-09-06 01:30:45 +0200 |
| commit | 005ef14949aacfc7a7af7a08bb67282f663b38ec (patch) | |
| tree | e7365cefb36d7defa7cc9381adcef2f62503a5bb | |
| parent | ff358c56d926396d7dbab7a83e29a9f150a23a07 (diff) | |
| download | Firmament-005ef14949aacfc7a7af7a08bb67282f663b38ec.tar.gz Firmament-005ef14949aacfc7a7af7a08bb67282f663b38ec.tar.bz2 Firmament-005ef14949aacfc7a7af7a08bb67282f663b38ec.zip | |
feat: Allow showing pickaxe ability timer on shovels
Fixes https://github.com/nea89o/Firmament/issues/248
| -rw-r--r-- | src/main/kotlin/features/mining/PickaxeAbility.kt | 43 | ||||
| -rw-r--r-- | src/main/kotlin/util/skyblock/ItemType.kt | 6 | ||||
| -rw-r--r-- | translations/en_us.json | 5 |
3 files changed, 44 insertions, 10 deletions
diff --git a/src/main/kotlin/features/mining/PickaxeAbility.kt b/src/main/kotlin/features/mining/PickaxeAbility.kt index df683de..de50217 100644 --- a/src/main/kotlin/features/mining/PickaxeAbility.kt +++ b/src/main/kotlin/features/mining/PickaxeAbility.kt @@ -47,10 +47,25 @@ object PickaxeAbility : FirmamentFeature { override val identifier: String get() = "pickaxe-info" + enum class ShowOnTools(val label: String, val items: Set<ItemType>) : StringIdentifiable { + ALL("all", ItemType.DRILL, ItemType.PICKAXE, ItemType.SHOVEL, ItemType.AXE), + PICKAXES_AND_DRILLS("pick-and-drill", ItemType.PICKAXE, ItemType.DRILL), + DRILLS("drills", ItemType.DRILL), + ; + + override fun asString(): String? { + return label + } + + constructor(label: String, vararg items: ItemType) : this(label, items.toSet()) + + fun matches(type: ItemType) = items.contains(type) + } object TConfig : ManagedConfig(identifier, Category.MINING) { val cooldownEnabled by toggle("ability-cooldown") { false } val disableInDungeons by toggle("disable-in-dungeons") { true } + val showOnTools by choice("show-on-tools") { ShowOnTools.PICKAXES_AND_DRILLS } val cooldownScale by integer("ability-scale", 16, 64) { 16 } val cooldownReadyToast by toggle("ability-cooldown-toast") { false } val drillFuelBar by toggle("fuel-bar") { true } @@ -114,9 +129,12 @@ object PickaxeAbility : FirmamentFeature { BlockPickaxeAbility.ONLY_DESTRUCTIVE -> ability.any { it.name in destructiveAbilities } } if (shouldBlock) { - MC.sendChat(tr("firmament.pickaxe.blocked", - "Firmament blocked a pickaxe ability from being used on a private island.") - .red() // TODO: .clickCommand("firm confignavigate ${TConfig.identifier} block-on-dynamic") + MC.sendChat( + tr( + "firmament.pickaxe.blocked", + "Firmament blocked a pickaxe ability from being used on a private island." + ) + .red() // TODO: .clickCommand("firm confignavigate ${TConfig.identifier} block-on-dynamic") ) event.cancel() } @@ -179,7 +197,12 @@ object PickaxeAbility : FirmamentFeature { if (!TConfig.cooldownReadyToast) return val mc: MinecraftClient = MinecraftClient.getInstance() mc.toastManager.add( - SystemToast.create(mc, SystemToast.Type.NARRATOR_TOGGLE, tr("firmament.pickaxe.ability-ready","Pickaxe Cooldown"), tr("firmament.pickaxe.ability-ready.desc", "Pickaxe ability is ready!")) + SystemToast.create( + mc, + SystemToast.Type.NARRATOR_TOGGLE, + tr("firmament.pickaxe.ability-ready", "Pickaxe Cooldown"), + tr("firmament.pickaxe.ability-ready.desc", "Pickaxe ability is ready!") + ) ) } } @@ -225,11 +248,15 @@ object PickaxeAbility : FirmamentFeature { if (!TConfig.cooldownEnabled) return if (TConfig.disableInDungeons && DungeonUtil.isInDungeonIsland) return if (!event.isRenderingCursor) return - var ability = getCooldownFromLore(MC.player?.getStackInHand(Hand.MAIN_HAND) ?: return) ?: return - defaultAbilityDurations[ability.name] = ability.cooldown + val stack = MC.player?.getStackInHand(Hand.MAIN_HAND) ?: return + if (!TConfig.showOnTools.matches(ItemType.fromItemStack(stack) ?: ItemType.NIL)) + return + var ability = getCooldownFromLore(stack)?.also { ability -> + defaultAbilityDurations[ability.name] = ability.cooldown + } val ao = abilityOverride - if (ao != ability.name && ao != null) { - ability = PickaxeAbilityData(ao, defaultAbilityDurations[ao] ?: 120.seconds) + if (ability == null || (ao != ability.name && ao != null)) { + ability = PickaxeAbilityData(ao ?: return, defaultAbilityDurations[ao] ?: 120.seconds) } event.context.matrices.pushMatrix() event.context.matrices.translate(MC.window.scaledWidth / 2F, MC.window.scaledHeight / 2F) diff --git a/src/main/kotlin/util/skyblock/ItemType.kt b/src/main/kotlin/util/skyblock/ItemType.kt index 7a776b5..9045646 100644 --- a/src/main/kotlin/util/skyblock/ItemType.kt +++ b/src/main/kotlin/util/skyblock/ItemType.kt @@ -6,8 +6,7 @@ import moe.nea.firmament.util.mc.loreAccordingToNbt import moe.nea.firmament.util.petData -@JvmInline -value class ItemType private constructor(val name: String) { +data class ItemType private constructor(val name: String) { companion object { fun ofName(name: String): ItemType { return ItemType(name) @@ -41,6 +40,7 @@ value class ItemType private constructor(val name: String) { val SWORD = ofName("SWORD") val DRILL = ofName("DRILL") val PICKAXE = ofName("PICKAXE") + val AXE = ofName("AXE") val GAUNTLET = ofName("GAUNTLET") val LONGSWORD = ofName("LONG SWORD") val EQUIPMENT = ofName("EQUIPMENT") @@ -57,6 +57,8 @@ value class ItemType private constructor(val name: String) { val LEGGINGS = ofName("LEGGINGS") val HELMET = ofName("HELMET") val BOOTS = ofName("BOOTS") + val SHOVEL = ofName("SHOVEL") + val NIL = ofName("__NIL") /** diff --git a/translations/en_us.json b/translations/en_us.json index 56baae9..3b83857 100644 --- a/translations/en_us.json +++ b/translations/en_us.json @@ -271,6 +271,11 @@ "firmament.config.pickaxe-info.disable-in-dungeons.description": "Disables the cooldown around your cross-hair while in Dungeons.", "firmament.config.pickaxe-info.fuel-bar": "Drill Fuel Durability Bar", "firmament.config.pickaxe-info.fuel-bar.description": "Replace the item durability bar of your drills with one that shows the remaining fuel.", + "firmament.config.pickaxe-info.show-on-tools": "Show on Tools", + "firmament.config.pickaxe-info.show-on-tools.choice.all": "All Tools", + "firmament.config.pickaxe-info.show-on-tools.choice.drills": "Drills", + "firmament.config.pickaxe-info.show-on-tools.choice.pickaxes_and_drills": "Drills & Pickaxes", + "firmament.config.pickaxe-info.show-on-tools.description": "Show pickaxe ability cooldowns only on some tools. Notabene: Not all tools have support for pickaxe abilities so you might need to swap to your drill to activate the abilities.", "firmament.config.power-user": "Power Users", "firmament.config.power-user.copy-item-id": "Copy SkyBlock Id", "firmament.config.power-user.copy-item-id.description": "Press this button to copy the NEU repo SkyBlock id. This is not the raw id, but instead contains some extra transformations for things like runes, pets and enchant books.", |
