mirror of
https://gitlab.com/cable-mc/cobblemon.git
synced 2026-10-27 04:26:27 -04:00
Implemented Levelup Sounds
This commit is contained in:
@@ -103,6 +103,11 @@ object CobblemonSounds : PlatformRegistry<Registry<SoundEvent>, ResourceKey<Regi
|
||||
@JvmField
|
||||
val EVOLUTION = this.create("evolution.full")
|
||||
|
||||
@JvmField
|
||||
val LEVELUP_START = this.create("gui.levelup_start")
|
||||
@JvmField
|
||||
val LEVELUP = this.create("gui.levelup")
|
||||
|
||||
@JvmField
|
||||
val PVN_BATTLE = this.create("battle.pvn.default")
|
||||
@JvmField
|
||||
|
||||
@@ -67,12 +67,29 @@ class PartyOverlay : Gui(Minecraft.getInstance()) {
|
||||
private val inanimatePortraitDrawer = InanimatePortraitDrawer()
|
||||
private val selectedAnimatedPortraitDrawer = SelectedAnimatedPortraitDrawer()
|
||||
private val fullyAnimatedPortraitDrawer = FullyAnimatedPortraitDrawer()
|
||||
}
|
||||
|
||||
private val screenExemptions: List<Class<out Screen>> = listOf(
|
||||
ChatScreen::class.java,
|
||||
BattleGUI::class.java
|
||||
)
|
||||
private val screenExemptions: List<Class<out Screen>> = listOf(
|
||||
ChatScreen::class.java,
|
||||
BattleGUI::class.java
|
||||
)
|
||||
|
||||
fun canRender(): Boolean {
|
||||
val minecraft = Minecraft.getInstance()
|
||||
// Hiding if a Screen is open and not exempt
|
||||
if (minecraft.screen != null) {
|
||||
if (!screenExemptions.contains(minecraft.screen?.javaClass as Class<out Screen>))
|
||||
return false
|
||||
}
|
||||
if (minecraft.options.hideGui || minecraft.debugOverlay.showDebugScreen()) {
|
||||
return false
|
||||
}
|
||||
// Hiding if toggled via Keybind
|
||||
if (HidePartyBinding.shouldHide) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
val starterToast = CobblemonToast(
|
||||
Mth.createInsecureUUID(),
|
||||
@@ -94,23 +111,11 @@ class PartyOverlay : Gui(Minecraft.getInstance()) {
|
||||
}
|
||||
|
||||
override fun render(context: GuiGraphics, tickCounter: DeltaTracker) {
|
||||
if (!canRender()) return
|
||||
|
||||
val partialDeltaTicks = tickCounter.realtimeDeltaTicks
|
||||
|
||||
val minecraft = Minecraft.getInstance()
|
||||
|
||||
// Hiding if a Screen is open and not exempt
|
||||
if (minecraft.screen != null) {
|
||||
if (!screenExemptions.contains(minecraft.screen?.javaClass as Class<out Screen>))
|
||||
return
|
||||
}
|
||||
if (minecraft.options.hideGui || minecraft.debugOverlay.showDebugScreen()) {
|
||||
return
|
||||
}
|
||||
// Hiding if toggled via Keybind
|
||||
if (HidePartyBinding.shouldHide) {
|
||||
return
|
||||
}
|
||||
|
||||
val panelX = 0
|
||||
val party = CobblemonClient.storage.party
|
||||
val matrices = context.pose()
|
||||
|
||||
@@ -8,6 +8,11 @@
|
||||
|
||||
package com.cobblemon.mod.common.client.gui
|
||||
|
||||
import com.cobblemon.mod.common.CobblemonSounds
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.resources.sounds.SimpleSoundInstance
|
||||
import net.minecraft.client.resources.sounds.SoundInstance
|
||||
import net.minecraft.sounds.SoundEvent
|
||||
import java.util.*
|
||||
|
||||
object PartyOverlayDataControl {
|
||||
@@ -28,6 +33,9 @@ object PartyOverlayDataControl {
|
||||
|
||||
private val overlayData = mutableMapOf<UUID, OverlayData>()
|
||||
|
||||
private var barFillupSound: SoundInstance? = null
|
||||
private var levelUpJingleSound: SoundInstance? = null
|
||||
|
||||
fun pokemonGainedExp(pokemonUuid : UUID, oldLevel: Int?, expGained: Int, countOfMovesLearned: Int, countOfEvosUnlocked: Int = 0) {
|
||||
var time = BAR_UPDATE_NO_LEVEL_TIME
|
||||
if (countOfMovesLearned > 0 || countOfEvosUnlocked > 0) {
|
||||
@@ -55,6 +63,9 @@ object PartyOverlayDataControl {
|
||||
}
|
||||
}
|
||||
overlayData[pokemonUuid] = OverlayData(expGainedData = newData)
|
||||
|
||||
stopSound(barFillupSound)
|
||||
barFillupSound = playSound(CobblemonSounds.LEVELUP_START)
|
||||
}
|
||||
|
||||
fun pokemonGainedEvo(pokemonUuid : UUID, evoCount: Int) {
|
||||
@@ -130,6 +141,10 @@ object PartyOverlayDataControl {
|
||||
if (data.expGainedData != null) { // We update this in order and render these in order, and as such we don't tick others
|
||||
val expGainedData = data.expGainedData!!
|
||||
expGainedData.ticks += 1
|
||||
if (expGainedData.ticks == BAR_UPDATE_BEFORE_TIME && expGainedData.oldLevel != null) {
|
||||
stopSound(levelUpJingleSound)
|
||||
levelUpJingleSound = playSound(CobblemonSounds.LEVELUP)
|
||||
}
|
||||
if (expGainedData.ticks >= expGainedData.ticksMax) {
|
||||
data.expGainedData = null
|
||||
}
|
||||
@@ -158,6 +173,8 @@ object PartyOverlayDataControl {
|
||||
|
||||
fun clear() {
|
||||
overlayData.clear()
|
||||
stopSound(barFillupSound)
|
||||
stopSound(levelUpJingleSound)
|
||||
}
|
||||
|
||||
open class TickCounter(
|
||||
@@ -195,4 +212,16 @@ object PartyOverlayDataControl {
|
||||
return fadeIn + hold + fadeOut
|
||||
}
|
||||
}
|
||||
|
||||
//SOUNDS
|
||||
private fun playSound(soundEvent: SoundEvent): SoundInstance? {
|
||||
if (!PartyOverlay.canRender()) return null
|
||||
val soundInstance = SimpleSoundInstance.forUI(soundEvent, 1F)
|
||||
Minecraft.getInstance().soundManager.play(soundInstance)
|
||||
return soundInstance
|
||||
}
|
||||
|
||||
private fun stopSound(soundInstance: SoundInstance?) {
|
||||
if (soundInstance != null) Minecraft.getInstance().soundManager.stop(soundInstance)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user