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

Made Triple P Battery support #98

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package net.oxyopia.vice.features.itemabilities
import net.minecraft.util.ClickType
import net.oxyopia.vice.data.Debugger
import net.oxyopia.vice.data.Set
import net.oxyopia.vice.features.itemabilities.ItemAbilityCooldown.hasCharged
import net.oxyopia.vice.utils.ItemUtils.getEquippedSets
import net.oxyopia.vice.utils.TimeUtils.timeDelta
import net.oxyopia.vice.utils.Utils
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.seconds

/**
* Inspired from SkyHanni's similar feature, partially adapted
Expand Down Expand Up @@ -110,6 +112,8 @@ enum class ItemAbility(
diff /= 2
}

if (this == BROKEN_FLASHLIGHT && hasCharged) diff = this.cooldown.toInt().seconds

return maxOf(cooldown - (diff.inWholeMilliseconds / 1000.0f), 0f)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ object ItemAbilityCooldown {
}
}

var hasCharged = false

@SubscribeEvent
fun onSound(event: SoundEvent) {

Expand Down Expand Up @@ -317,6 +319,15 @@ object ItemAbilityCooldown {
ability.drawStatus(event.x, event.y + 9, event.context)
}

@SubscribeEvent
fun onBattery(event: ChatEvent) {
if(event.string.startsWith("+1 Triple P Battery")) {
hasCharged = true
} else {
hasCharged = false
}
}

private fun ItemAbility.drawStatus(x: Int, y: Int, context: DrawContext, centered: Boolean = false, defaultColor: Color = Color.white) {
if (!Vice.config.SHOW_ITEMCD_TEXT && Vice.config.ITEMCD_DISPLAY_TYPE != DisplayType.TEXT_ONLY) return
if (!Vice.config.ITEM_COOLDOWN_DISPLAY || !displayCooldown) return
Expand Down