From e7a5c23204e0670602af9ec87a72e9be9e9aa0aa Mon Sep 17 00:00:00 2001 From: Hiroku Date: Sun, 9 Jul 2023 23:48:56 +0000 Subject: [PATCH] Render refactor --- CHANGELOG.md | 2 + .../cobblemon/mod/common/api/gui/GuiUtils.kt | 4 +- .../common/client/battle/ClientBallDisplay.kt | 14 +- .../entity/EmptyPokeBallClientDelegate.kt | 6 + .../client/entity/PokemonClientDelegate.kt | 10 +- .../mod/common/client/gui/PartyOverlay.kt | 2 +- .../mod/common/client/gui/PokemonGuiUtils.kt | 16 +- .../mod/common/client/gui/battle/BattleGUI.kt | 2 +- .../common/client/gui/battle/BattleOverlay.kt | 8 +- .../subscreen/BattleSwitchPokemonSelection.kt | 3 +- .../gui/pasture/PasturePokemonScrollList.kt | 1 + .../client/gui/pc/GrabbedStorageSlot.kt | 16 +- .../mod/common/client/gui/pc/StorageSlot.kt | 5 +- .../widgets/preview/StarterRoundabout.kt | 3 +- .../summary/widgets/EvolutionSelectScreen.kt | 3 +- .../client/gui/summary/widgets/ModelWidget.kt | 10 +- .../gui/summary/widgets/PartySlotWidget.kt | 3 +- .../common/client/gui/trade/ModelWidget.kt | 3 +- .../mod/common/client/gui/trade/PartySlot.kt | 3 +- .../net/battle/BattleCaptureEndHandler.kt | 2 - .../render/layer/PokemonOnShoulderRenderer.kt | 78 ++++---- .../models/blockbench/PoseableEntityModel.kt | 3 +- .../models/blockbench/PoseableEntityState.kt | 64 ++++--- .../blockbench/animation/StatefulAnimation.kt | 2 + .../animation/StatelessAnimation.kt | 2 + .../bedrock/animation/BedrockAnimation.kt | 166 +++++++++++++----- .../animation/BedrockAnimationAdapter.kt | 41 ++++- .../animation/BedrockStatefulAnimation.kt | 16 +- .../animation/BedrockStatelessAnimation.kt | 18 +- .../pokemon/PokemonFloatingState.kt | 17 +- .../blockbench/pokemon/gen1/ElectrodeModel.kt | 2 +- .../blockbench/pokemon/gen1/VoltorbModel.kt | 2 +- .../render/models/blockbench/pose/Pose.kt | 12 +- .../render/pokeball/PokeBallRenderer.kt | 1 + .../client/render/pokemon/PokemonRenderer.kt | 2 + .../molang-1.1.3.jar} | Bin 95206 -> 95359 bytes .../molang-1.1.3.pom} | 2 +- .../bedrockk/molang/maven-metadata-local.xml | 6 +- .../cobblemon/mod/fabric/mixin/GuiMixin.java | 14 +- gradle/libs.versions.yml | 2 +- 40 files changed, 362 insertions(+), 204 deletions(-) rename deps/local/com/bedrockk/molang/{1.1.1/molang-1.1.1.jar => 1.1.3/molang-1.1.3.jar} (86%) rename deps/local/com/bedrockk/molang/{1.1.1/molang-1.1.1.pom => 1.1.3/molang-1.1.3.pom} (92%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 049bee1a44..0670de93ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -212,6 +212,8 @@ - Fixed Shedinja not being able to recover naturally. - Fixed different forms of Pokémon not being able to appear as different sizes. - Fixed the Healing Machine soft locking you from using others when removed by non-players. +- Fixed animations being sped up when using the Replay Mod. +- Fixed particle animations not running when a Pokémon is off-screen. ### Developer - Added SpawnEvent diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/api/gui/GuiUtils.kt b/common/src/main/kotlin/com/cobblemon/mod/common/api/gui/GuiUtils.kt index bbe85bcf74..6d0509cecc 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/api/gui/GuiUtils.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/api/gui/GuiUtils.kt @@ -175,7 +175,8 @@ fun drawPortraitPokemon( matrixStack: MatrixStack, scale: Float = 13F, reversed: Boolean = false, - state: PoseableEntityState? = null + state: PoseableEntityState? = null, + partialTicks: Float ) { val model = PokemonModelRepository.getPoser(species.resourceIdentifier, aspects) val texture = PokemonModelRepository.getTexture(species.resourceIdentifier, aspects, state) @@ -191,6 +192,7 @@ fun drawPortraitPokemon( } else { model.getPose(PoseType.PORTRAIT)?.let { state.setPose(it.poseName) } state.timeEnteredPose = 0F + state.updatePartialTicks(partialTicks) model.setupAnimStateful(null, state, 0F, 0F, 0F, 0F, 0F) } diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/battle/ClientBallDisplay.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/battle/ClientBallDisplay.kt index 7212d507a1..f6f556bd2e 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/battle/ClientBallDisplay.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/battle/ClientBallDisplay.kt @@ -26,6 +26,10 @@ class ClientBallDisplay(val pokeBall: PokeBall, val aspects: Set) : Poke override val stateEmitter = SettableObservable(EmptyPokeBallEntity.CaptureState.FALL) override val shakeEmitter = SimpleObservable() + override fun updatePartialTicks(partialTicks: Float) { + this.currentPartialTicks += partialTicks + } + var scale = 1F fun start() { @@ -39,14 +43,4 @@ class ClientBallDisplay(val pokeBall: PokeBall, val aspects: Set) : Poke } } } - - fun finish() { - lerp(seconds = 0.3F) { scale = 1 - it } - after(seconds = 0.3F) { - lerp(seconds = 0.3F) { scale = it } - after(seconds = 0.3F) { - - } - } - } } \ No newline at end of file diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/entity/EmptyPokeBallClientDelegate.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/entity/EmptyPokeBallClientDelegate.kt index 78857bac96..14a5d6f97f 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/entity/EmptyPokeBallClientDelegate.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/entity/EmptyPokeBallClientDelegate.kt @@ -21,7 +21,12 @@ class EmptyPokeBallClientDelegate : PokeBallPoseableState(), EntitySideDelegate< override val stateEmitter: SettableObservable = SettableObservable(NOT) override val shakeEmitter = SimpleObservable() + override fun updatePartialTicks(partialTicks: Float) { + this.currentPartialTicks = partialTicks + } + override fun initialize(entity: EmptyPokeBallEntity) { + age = entity.age initSubscriptions() entity.captureState.subscribe { stateEmitter.set(CaptureState.values()[it.toInt()]) @@ -32,5 +37,6 @@ class EmptyPokeBallClientDelegate : PokeBallPoseableState(), EntitySideDelegate< override fun tick(entity: EmptyPokeBallEntity) { super.tick(entity) updateLocatorPosition(entity.pos) + incrementAge(entity) } } \ No newline at end of file diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/entity/PokemonClientDelegate.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/entity/PokemonClientDelegate.kt index 9e92c2b89d..29f1081a11 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/entity/PokemonClientDelegate.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/entity/PokemonClientDelegate.kt @@ -32,9 +32,11 @@ class PokemonClientDelegate : PoseableEntityState(), PokemonSideD var phaseTarget: Entity? = null var entityScaleModifier = 1F - var animTick = 0F - var previousVerticalVelocity = 0F + override fun updatePartialTicks(partialTicks: Float) { + this.currentPartialTicks = partialTicks + } + var previousVerticalVelocity = 0F var beamStartTime = System.currentTimeMillis() val secondsSinceBeamEffectStarted: Float @@ -103,6 +105,7 @@ class PokemonClientDelegate : PoseableEntityState(), PokemonSideD override fun initialize(entity: PokemonEntity) { this.entity = entity + this.age = entity.age } override fun tick(entity: PokemonEntity) { @@ -119,8 +122,9 @@ class PokemonClientDelegate : PoseableEntityState(), PokemonSideD } updateLocatorPosition(entity.pos) - previousVerticalVelocity = entity.velocity.y.toFloat() + + incrementAge(entity) } fun setPhaseTarget(targetId: Int) { diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/PartyOverlay.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/PartyOverlay.kt index d0d63cbbc6..22936f5e4f 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/PartyOverlay.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/PartyOverlay.kt @@ -160,7 +160,7 @@ class PartyOverlay : InGameHud(MinecraftClient.getInstance(), MinecraftClient.ge 0.0 ) - drawPortraitPokemon(pokemon.species, pokemon.aspects, matrices) + drawPortraitPokemon(pokemon.species, pokemon.aspects, matrices, partialTicks = partialDeltaTicks) matrices.pop() context.disableScissor() } diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/PokemonGuiUtils.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/PokemonGuiUtils.kt index 48da8b290f..3e3921c437 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/PokemonGuiUtils.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/PokemonGuiUtils.kt @@ -29,14 +29,16 @@ fun drawProfilePokemon( matrixStack: MatrixStack, rotation: Quaternionf, state: PoseableEntityState?, + partialTicks: Float, scale: Float = 20F ) = drawProfilePokemon( - renderablePokemon.species.resourceIdentifier, - renderablePokemon.aspects, - matrixStack, - rotation, - state, - scale + species = renderablePokemon.species.resourceIdentifier, + aspects = renderablePokemon.aspects, + matrixStack = matrixStack, + rotation = rotation, + state = state, + partialTicks = partialTicks, + scale = scale ) fun drawProfilePokemon( @@ -45,6 +47,7 @@ fun drawProfilePokemon( matrixStack: MatrixStack, rotation: Quaternionf, state: PoseableEntityState?, + partialTicks: Float, scale: Float = 20F ) { val model = PokemonModelRepository.getPoser(species, aspects) @@ -58,6 +61,7 @@ fun drawProfilePokemon( if (state != null) { model.getPose(PoseType.PROFILE)?.let { state.setPose(it.poseName) } state.timeEnteredPose = 0F + state.updatePartialTicks(partialTicks) model.setupAnimStateful(null, state, 0F, 0F, 0F, 0F, 0F) } else { model.setupAnimStateless(PoseType.PROFILE) diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/battle/BattleGUI.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/battle/BattleGUI.kt index d7ca83ca11..26ab169712 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/battle/BattleGUI.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/battle/BattleGUI.kt @@ -145,7 +145,7 @@ class BattleGUI : Screen(battleLang("gui.title")) { } override fun charTyped(chr: Char, modifiers: Int): Boolean { - if (chr.toString() == PartySendBinding.boundKey().localizedText.string && CobblemonClient.battleOverlay.opacity == BattleOverlay.MAX_OPACITY && PartySendBinding.canAction()) { + if (chr.toString().equals(PartySendBinding.boundKey().localizedText.string, ignoreCase = true) && CobblemonClient.battleOverlay.opacity == BattleOverlay.MAX_OPACITY && PartySendBinding.canAction()) { val battle = CobblemonClient.battle ?: return false battle.minimised = !battle.minimised PartySendBinding.actioned() diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/battle/BattleOverlay.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/battle/BattleOverlay.kt index 15d295978a..5d33fedfcd 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/battle/BattleOverlay.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/battle/BattleOverlay.kt @@ -161,6 +161,7 @@ class BattleOverlay : InGameHud(MinecraftClient.getInstance(), MinecraftClient.g context = context, x = x, y = y.toFloat(), + partialTicks = tickDelta, reversed = !left, species = battlePokemon.species, level = battlePokemon.level, @@ -182,6 +183,7 @@ class BattleOverlay : InGameHud(MinecraftClient.getInstance(), MinecraftClient.g context: DrawContext, x: Float, y: Float, + partialTicks: Float, reversed: Boolean, species: Species, level: Int, @@ -227,6 +229,7 @@ class BattleOverlay : InGameHud(MinecraftClient.getInstance(), MinecraftClient.g drawPokeBall( state = ballState, matrixStack = matrixStack, + partialTicks = partialTicks ) } else { matrixStack.push() @@ -236,7 +239,8 @@ class BattleOverlay : InGameHud(MinecraftClient.getInstance(), MinecraftClient.g matrixStack = matrixStack, scale = 18F * (ballState?.scale ?: 1F), reversed = reversed, - state = state + state = state, + partialTicks = partialTicks ) matrixStack.pop() } @@ -379,6 +383,7 @@ class BattleOverlay : InGameHud(MinecraftClient.getInstance(), MinecraftClient.g state: ClientBallDisplay, matrixStack: MatrixStack, scale: Float = 5F, + partialTicks: Float, reversed: Boolean = false ) { val model = PokeBallModelRepository.getPoser(state.pokeBall.name, state.aspects) @@ -391,6 +396,7 @@ class BattleOverlay : InGameHud(MinecraftClient.getInstance(), MinecraftClient.g model.getPose(PoseType.PORTRAIT)?.let { state.setPose(it.poseName) } state.timeEnteredPose = 0F + state.updatePartialTicks(partialTicks) model.setupAnimStateful(null, state, 0F, 0F, 0F, 0F, 0F) matrixStack.scale(scale, scale, -scale) diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/battle/subscreen/BattleSwitchPokemonSelection.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/battle/subscreen/BattleSwitchPokemonSelection.kt index 48eb58f706..aaaf93dad7 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/battle/subscreen/BattleSwitchPokemonSelection.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/battle/subscreen/BattleSwitchPokemonSelection.kt @@ -72,7 +72,8 @@ class BattleSwitchPokemonSelection( isFlatHealth = true, state = null, colour = null, - opacity = selection.opacity + opacity = selection.opacity, + partialTicks = deltaTicks ) } } diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/pasture/PasturePokemonScrollList.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/pasture/PasturePokemonScrollList.kt index 954aab41b3..6cd040deec 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/pasture/PasturePokemonScrollList.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/pasture/PasturePokemonScrollList.kt @@ -203,6 +203,7 @@ class PasturePokemonScrollList( matrixStack = matrixStack, rotation = Quaternionf().fromEulerXYZDegrees(Vector3f(13F, 35F, 0F)), state = null, + partialTicks = partialTicks, scale = 4.5F ) matrixStack.pop() diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/pc/GrabbedStorageSlot.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/pc/GrabbedStorageSlot.kt index 1d51897f6a..cc8dfe8e5d 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/pc/GrabbedStorageSlot.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/pc/GrabbedStorageSlot.kt @@ -19,18 +19,10 @@ class GrabbedStorageSlot( ) : StorageSlot(x, y, parent, {}) { override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) { - renderSlot(context, mouseX - (width / 2), mouseY - (height / 2)) + renderSlot(context = context, posX = mouseX - (width / 2), posY = mouseY - (height / 2), partialTicks = delta) } - override fun isStationary(): Boolean { - return false - } - - override fun getPokemon(): Pokemon? { - return pokemon - } - - override fun isSelected(): Boolean { - return true - } + override fun isStationary() = false + override fun getPokemon() = pokemon + override fun isSelected() = true } \ No newline at end of file diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/pc/StorageSlot.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/pc/StorageSlot.kt index 9b859f4ad0..dcde4ce753 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/pc/StorageSlot.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/pc/StorageSlot.kt @@ -49,11 +49,11 @@ open class StorageSlot( override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) { if (shouldRender()) { - renderSlot(context, x, y) + renderSlot(context, x, y, delta) } } - fun renderSlot(context: DrawContext, posX: Int, posY: Int) { + fun renderSlot(context: DrawContext, posX: Int, posY: Int, partialTicks: Float) { val pokemon = getPokemon() ?: return val matrices = context.matrices context.enableScissor( @@ -72,6 +72,7 @@ open class StorageSlot( matrixStack = matrices, rotation = Quaternionf().fromEulerXYZDegrees(Vector3f(13F, 35F, 0F)), state = null, + partialTicks = partialTicks, scale = 4.5F ) matrices.pop() diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/startselection/widgets/preview/StarterRoundabout.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/startselection/widgets/preview/StarterRoundabout.kt index 39a423b085..0411b9da67 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/startselection/widgets/preview/StarterRoundabout.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/startselection/widgets/preview/StarterRoundabout.kt @@ -70,7 +70,8 @@ class StarterRoundabout( matrixStack = matrices, rotation = Quaternionf().fromEulerXYZDegrees(rotationVector), state = null, - scale = 18F + scale = 18F, + partialTicks = delta ) context.disableScissor() diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/summary/widgets/EvolutionSelectScreen.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/summary/widgets/EvolutionSelectScreen.kt index 46e13b09fa..9171cd0345 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/summary/widgets/EvolutionSelectScreen.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/summary/widgets/EvolutionSelectScreen.kt @@ -140,7 +140,8 @@ class EvolutionSelectScreen( matrixStack = matrices, rotation = Quaternionf().fromEulerXYZDegrees(Vector3f(13F, 35F, 0F)), state = null, - scale = 6F + scale = 6F, + partialTicks = partialTicks ) matrices.pop() } diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/summary/widgets/ModelWidget.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/summary/widgets/ModelWidget.kt index 4ec36f01ac..d68b20b483 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/summary/widgets/ModelWidget.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/summary/widgets/ModelWidget.kt @@ -32,18 +32,17 @@ class ModelWidget( } var state = PokemonFloatingState() - private val minecraft = MinecraftClient.getInstance() val rotVec = Vector3f(13F, rotationY, 0F) - override fun renderButton(context: DrawContext, pMouseX: Int, pMouseY: Int, pPartialTicks: Float) { + override fun renderButton(context: DrawContext, pMouseX: Int, pMouseY: Int, partialTicks: Float) { if (!render) { return } hovered = pMouseX >= x && pMouseY >= y && pMouseX < x + width && pMouseY < y + height - renderPKM(context) + renderPKM(context, partialTicks) } - private fun renderPKM(context: DrawContext) { + private fun renderPKM(context: DrawContext, partialTicks: Float) { val matrices = context.matrices matrices.push() @@ -62,7 +61,8 @@ class ModelWidget( renderablePokemon = pokemon, matrixStack = matrices, rotation = Quaternionf().fromEulerXYZDegrees(rotVec), - state = state + state = state, + partialTicks = partialTicks ) matrices.pop() diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/summary/widgets/PartySlotWidget.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/summary/widgets/PartySlotWidget.kt index 84714c1b0d..46f0a5a962 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/summary/widgets/PartySlotWidget.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/summary/widgets/PartySlotWidget.kt @@ -159,7 +159,8 @@ class PartySlotWidget( matrixStack = matrices, rotation = Quaternionf().fromEulerXYZDegrees(Vector3f(13F, 35F, 0F)), state = null, - scale = 4.5F + scale = 4.5F, + partialTicks = delta ) matrices.pop() diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/trade/ModelWidget.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/trade/ModelWidget.kt index 867948a3b8..032817ec06 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/trade/ModelWidget.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/trade/ModelWidget.kt @@ -40,7 +40,8 @@ class ModelWidget( renderablePokemon = pokemon, matrixStack = matrices, rotation = Quaternionf().fromEulerXYZDegrees(rotVec), - state = state + state = state, + partialTicks = delta ) matrices.pop() diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/trade/PartySlot.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/trade/PartySlot.kt index 0fc816e43b..8da47c75c0 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/trade/PartySlot.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/trade/PartySlot.kt @@ -75,7 +75,8 @@ open class PartySlot( matrixStack = matrices, rotation = Quaternionf().fromEulerXYZDegrees(Vector3f(13F, 35F, 0F)), state = null, - scale = 4.5F + scale = 4.5F, + partialTicks = delta ) matrices.pop() diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/net/battle/BattleCaptureEndHandler.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/net/battle/BattleCaptureEndHandler.kt index 421b01e9ca..976f0f4db2 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/net/battle/BattleCaptureEndHandler.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/net/battle/BattleCaptureEndHandler.kt @@ -21,8 +21,6 @@ object BattleCaptureEndHandler : ClientNetworkPacketHandler(renderLayerParent: FeatureRend private val playerCache = hashMapOf() override fun render( - pMatrixStack: MatrixStack, - pBuffer: VertexConsumerProvider, - pPackedLight: Int, - pLivingEntity: T, - pLimbSwing: Float, - pLimbSwingAmount: Float, - pPartialTicks: Float, - pAgeInTicks: Float, - pNetHeadYaw: Float, - pHeadPitch: Float + matrixStack: MatrixStack, + buffer: VertexConsumerProvider, + packedLight: Int, + livingEntity: T, + limbSwing: Float, + limbSwingAmount: Float, + partialTicks: Float, + ageInTicks: Float, + netHeadYaw: Float, + headPitch: Float ) { - this.render(pMatrixStack, pBuffer, pPackedLight, pLivingEntity, pLimbSwing, pLimbSwingAmount, pNetHeadYaw, pHeadPitch, true) - this.render(pMatrixStack, pBuffer, pPackedLight, pLivingEntity, pLimbSwing, pLimbSwingAmount, pNetHeadYaw, pHeadPitch, false) + this.render(matrixStack, buffer, packedLight, livingEntity, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, true) + this.render(matrixStack, buffer, packedLight, livingEntity, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, false) } private fun render( - pMatrixStack: MatrixStack, - pBuffer: VertexConsumerProvider, - pPackedLight: Int, - pLivingEntity: T, - pLimbSwing: Float, - pLimbSwingAmount: Float, - pNetHeadYaw: Float, - pHeadPitch: Float, + matrixStack: MatrixStack, + buffer: VertexConsumerProvider, + packedLight: Int, + livingEntity: T, + limbSwing: Float, + limbSwingAmount: Float, + partialTicks: Float, + ageInTicks: Float, + netHeadYaw: Float, + headPitch: Float, pLeftShoulder: Boolean ) { - val compoundTag = if (pLeftShoulder) pLivingEntity.shoulderEntityLeft else pLivingEntity.shoulderEntityRight + val compoundTag = if (pLeftShoulder) livingEntity.shoulderEntityLeft else livingEntity.shoulderEntityRight if (compoundTag.isPokemonEntity()) { - pMatrixStack.push() + matrixStack.push() val uuid = compoundTag.getCompound(DataKeys.POKEMON).getUuid(DataKeys.POKEMON_UUID) - val cache = this.playerCache.getOrPut(pLivingEntity.uuid) { ShoulderCache() } + val cache = this.playerCache.getOrPut(livingEntity.uuid) { ShoulderCache() } val pokemon: Pokemon if (pLeftShoulder && cache.lastKnownLeft?.uuid != uuid) { pokemon = Pokemon().also { it.isClient = true }.loadFromNBT(compoundTag.getCompound(DataKeys.POKEMON)) @@ -76,17 +78,17 @@ class PokemonOnShoulderRenderer(renderLayerParent: FeatureRend val scale = pokemon.form.baseScale * pokemon.scaleModifier val width = pokemon.form.hitbox.width val offset = width / 2 - 0.7 - pMatrixStack.translate( + matrixStack.translate( if (pLeftShoulder) -offset else offset, - (if (pLivingEntity.isSneaking) -1.3 else -1.5) * scale, + (if (livingEntity.isSneaking) -1.3 else -1.5) * scale, 0.0 ) - pMatrixStack.scale(scale, scale, scale) + matrixStack.scale(scale, scale, scale) val model = PokemonModelRepository.getPoser(pokemon.species.resourceIdentifier, pokemon.aspects) val state = PokemonFloatingState() - state.animationSeconds = pLivingEntity.age.toFloat() / 20F - val vertexConsumer = pBuffer.getBuffer(model.getLayer(PokemonModelRepository.getTexture(pokemon.species.resourceIdentifier, pokemon.aspects, state))) - val i = LivingEntityRenderer.getOverlay(pLivingEntity, 0.0f) + state.updatePartialTicks(livingEntity.age.toFloat() * 20 + partialTicks) + val vertexConsumer = buffer.getBuffer(model.getLayer(PokemonModelRepository.getTexture(pokemon.species.resourceIdentifier, pokemon.aspects, state))) + val i = LivingEntityRenderer.getOverlay(livingEntity, 0.0f) val pose = model.poses.values .firstOrNull { (if (pLeftShoulder) PoseType.SHOULDER_LEFT else PoseType.SHOULDER_RIGHT) in it.poseTypes } @@ -96,17 +98,17 @@ class PokemonOnShoulderRenderer(renderLayerParent: FeatureRend model.setupAnimStateful( entity = null, state = state, - headYaw = pNetHeadYaw, - headPitch = pHeadPitch, - limbSwing = pLimbSwing, - limbSwingAmount = pLimbSwingAmount, - ageInTicks = pLivingEntity.age.toFloat() + headYaw = netHeadYaw, + headPitch = headPitch, + limbSwing = limbSwing, + limbSwingAmount = limbSwingAmount, + ageInTicks = livingEntity.age.toFloat() ) - model.render(pMatrixStack, vertexConsumer, pPackedLight, i, 1.0f, 1.0f, 1.0f, 1.0f) - model.withLayerContext(pBuffer, state, PokemonModelRepository.getLayers(pokemon.species.resourceIdentifier, pokemon.aspects)) { - model.render(pMatrixStack, vertexConsumer, pPackedLight, OverlayTexture.DEFAULT_UV, 1F, 1F, 1F, 1F) + model.render(matrixStack, vertexConsumer, packedLight, i, 1.0f, 1.0f, 1.0f, 1.0f) + model.withLayerContext(buffer, state, PokemonModelRepository.getLayers(pokemon.species.resourceIdentifier, pokemon.aspects)) { + model.render(matrixStack, vertexConsumer, packedLight, OverlayTexture.DEFAULT_UV, 1F, 1F, 1F, 1F) } - pMatrixStack.pop(); + matrixStack.pop(); } } diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/PoseableEntityModel.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/PoseableEntityModel.kt index 8c38b0bb90..f792c636ee 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/PoseableEntityModel.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/PoseableEntityModel.kt @@ -256,11 +256,10 @@ abstract class PoseableEntityModel( alpha * a ) - val animationSeconds = currentState?.animationSeconds ?: 0F val provider = bufferProvider if (provider != null) { for (layer in currentLayers) { - val texture = layer.texture?.invoke(animationSeconds) ?: continue + val texture = layer.texture?.invoke(currentState?.animationSeconds ?: 0F) ?: continue val renderLayer = getLayer(texture, layer.emissive, layer.translucent) val consumer = provider.getBuffer(renderLayer) stack.push() diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/PoseableEntityState.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/PoseableEntityState.kt index 7329553464..5f70e1590f 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/PoseableEntityState.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/PoseableEntityState.kt @@ -19,7 +19,6 @@ import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose import com.cobblemon.mod.common.client.render.models.blockbench.quirk.ModelQuirk import com.cobblemon.mod.common.client.render.models.blockbench.quirk.QuirkData import java.util.concurrent.ConcurrentLinkedQueue -import net.minecraft.client.MinecraftClient import net.minecraft.entity.Entity import net.minecraft.util.math.Vec3d @@ -37,17 +36,36 @@ abstract class PoseableEntityState { val statefulAnimations: MutableList> = mutableListOf() val quirks = mutableMapOf, QuirkData>() val additives: MutableList> = mutableListOf() - var timeEnteredPose = 0F - var previousAnimationSeconds = 0F - var animationSeconds = 0F - var deltaSeconds = 0F - var timeLastRendered = System.currentTimeMillis() - var wasPaused = false val poseParticles = mutableListOf() val runtime = MoLangRuntime().also { it.environment.structs["query"] = it.environment.structs["variable"] } + val allStatefulAnimations: List> get() = statefulAnimations + quirks.flatMap { it.value.animations } + + protected var age = 0 + protected var currentPartialTicks = 0F + + fun getPartialTicks() = currentPartialTicks + open fun updateAge(age: Int) { + this.age = age + } + + open fun incrementAge(entity: T) { + val previousAge = age + updateAge(age + 1) + runEffects(entity, previousAge, age) + } + + abstract fun updatePartialTicks(partialTicks: Float) + open fun reset() { + updateAge(0) + } + + val animationSeconds: Float get() = (age + getPartialTicks()) / 20F + + var timeEnteredPose = 0F + val locatorStates = mutableMapOf() val renderQueue = ConcurrentLinkedQueue<() -> Unit>() @@ -56,26 +74,6 @@ abstract class PoseableEntityState { fun isNotPosedIn(vararg poses: Pose) = poses.none { it.poseName == currentPose } fun preRender() { - val now = System.currentTimeMillis() - var deltaMillis = now - timeLastRendered - - if (wasPaused) { - deltaMillis = 0L - } - - if (MinecraftClient.getInstance().isPaused) { - if (!wasPaused) { - wasPaused = true - } - } else if (wasPaused) { - wasPaused = false - } - - timeLastRendered = now - deltaSeconds = deltaMillis / 1000F - previousAnimationSeconds = animationSeconds - animationSeconds += deltaSeconds - while (renderQueue.peek() != null) { val action = renderQueue.poll() action() @@ -97,7 +95,6 @@ abstract class PoseableEntityState { val poseImpl = model.getPose(pose) ?: return poseParticles.removeIf { it !in poseImpl.idleAnimations.filterIsInstance>().flatMap { it.particleKeyFrames } } poseImpl.onTransitionedInto(this) - timeEnteredPose = animationSeconds } } @@ -113,4 +110,15 @@ abstract class PoseableEntityState { fun updateLocatorPosition(position: Vec3d) { locatorStates.values.toList().forEach { it.updatePosition(position) } } + + fun runEffects(entity: T, previousAge: Int, newAge: Int) { + val previousSeconds = previousAge / 20F + val currentSeconds = newAge / 20F + + currentModel?.let { model -> + val pose = currentPose?.let(model::getPose) + allStatefulAnimations.forEach { it.applyEffects(entity, this, previousSeconds, currentSeconds) } + pose?.getApplicableIdleAnimations(entity, this)?.forEach { it.applyEffects(entity, this, previousSeconds, currentSeconds) } + } + } } \ No newline at end of file diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/animation/StatefulAnimation.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/animation/StatefulAnimation.kt index 27d639c21a..1f1f3925d7 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/animation/StatefulAnimation.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/animation/StatefulAnimation.kt @@ -41,4 +41,6 @@ interface StatefulAnimation { headYaw: Float, headPitch: Float ): Boolean + + fun applyEffects(entity: T, state: PoseableEntityState, previousSeconds: Float, newSeconds: Float) {} } \ No newline at end of file diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/animation/StatelessAnimation.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/animation/StatelessAnimation.kt index 290965d31b..5dd10c459d 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/animation/StatelessAnimation.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/animation/StatelessAnimation.kt @@ -28,4 +28,6 @@ abstract class StatelessAnimation(val frame: F) { fun apply(entity: T?, model: PoseableEntityModel, state: PoseableEntityState?, limbSwing: Float, limbSwingAmount: Float, ageInTicks: Float, headYaw: Float, headPitch: Float) { setAngles(entity, model, state, limbSwing, limbSwingAmount, ageInTicks, headYaw, headPitch) } + + open fun applyEffects(entity: T, state: PoseableEntityState, previousSeconds: Float, newSeconds: Float) {} } \ No newline at end of file diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/bedrock/animation/BedrockAnimation.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/bedrock/animation/BedrockAnimation.kt index 093f09afc1..25a712eb56 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/bedrock/animation/BedrockAnimation.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/bedrock/animation/BedrockAnimation.kt @@ -10,9 +10,12 @@ package com.cobblemon.mod.common.client.render.models.blockbench.bedrock.animati import com.bedrockk.molang.Expression import com.bedrockk.molang.runtime.MoLangRuntime +import com.bedrockk.molang.runtime.MoParams import com.bedrockk.molang.runtime.MoScope +import com.bedrockk.molang.runtime.struct.QueryStruct import com.bedrockk.molang.runtime.value.DoubleValue import com.cobblemon.mod.common.api.snowstorm.BedrockParticleEffect +import com.cobblemon.mod.common.api.text.text import com.cobblemon.mod.common.client.particle.ParticleStorm import com.cobblemon.mod.common.client.render.models.blockbench.PoseableEntityModel import com.cobblemon.mod.common.client.render.models.blockbench.PoseableEntityState @@ -21,8 +24,12 @@ import com.cobblemon.mod.common.util.math.geometry.toRadians import com.cobblemon.mod.common.util.resolveDouble import java.util.SortedMap import net.minecraft.client.MinecraftClient +import net.minecraft.client.sound.PositionedSoundInstance import net.minecraft.client.world.ClientWorld import net.minecraft.entity.Entity +import net.minecraft.registry.RegistryKeys +import net.minecraft.sound.SoundCategory +import net.minecraft.util.Identifier import net.minecraft.util.crash.CrashException import net.minecraft.util.crash.CrashReport import net.minecraft.util.math.Vec3d @@ -32,70 +39,133 @@ data class BedrockAnimationGroup( val animations: Map ) -data class BedrockParticleKeyframe( - val seconds: Float, +abstract class BedrockEffectKeyframe(val seconds: Float) { + abstract fun run(entity: T, state: PoseableEntityState) +} + +class BedrockParticleKeyframe( + seconds: Float, val effect: BedrockParticleEffect, val locator: String, val scripts: List -) +) : BedrockEffectKeyframe(seconds) { + override fun run(entity: T, state: PoseableEntityState) { + val world = entity.world as ClientWorld + val matrixWrapper = state.locatorStates[locator] ?: state.locatorStates["root"]!! + val effect = effect + + if (this in state.poseParticles) { + return + } + + val storm = ParticleStorm( + effect = effect, + matrixWrapper = matrixWrapper, + world = world, + sourceVelocity = { entity.velocity }, + sourceAlive = { !entity.isRemoved && this in state.poseParticles }, + sourceVisible = { !entity.isInvisible } + ) + + state.poseParticles.add(this) + storm.runtime.execute(this.scripts) + storm.spawn() + } +} + +class BedrockSoundKeyframe( + seconds: Float, + val sound: Identifier +): BedrockEffectKeyframe(seconds) { + override fun run(entity: T, state: PoseableEntityState) { + val registry = entity.world.registryManager.get(RegistryKeys.SOUND_EVENT) + val soundEvent = registry.get(sound) + if (soundEvent != null) { + MinecraftClient.getInstance().soundManager.play( + PositionedSoundInstance( + soundEvent, + SoundCategory.NEUTRAL, + 1F, + 1F, + entity.world.random, + entity.x, + entity.y, + entity.z + ) + ) + } + } +} + +class BedrockInstructionKeyframe( + seconds: Float, + val expressions: List +): BedrockEffectKeyframe(seconds) { + override fun run(entity: T, state: PoseableEntityState) { + expressions.forEach { expression -> BedrockAnimation.runInstruction(entity, state, expression) } + } +} data class BedrockAnimation( val shouldLoop: Boolean, val animationLength: Double, - val particleEffects: List, + val effects: List, val boneTimelines: Map ) { companion object { + val functionMappings = mutableMapOf>() val sharedRuntime = MoLangRuntime().also { it.environment.structs["query"] = it.environment.structs["variable"] + it.environment.structs["script"] = QueryStruct(functionMappings) + } + + var context: InstructionContext? = null + + inline fun registerInstruction(name: String, crossinline function: (entity: T, state: PoseableEntityState, params: MoParams) -> Any) { + functionMappings[name] = java.util.function.Function { args -> + val ctx = context ?: return@Function Unit + if (ctx.entity is T) { + val ret = function(ctx.entity, ctx.state as PoseableEntityState, args) + if (ret is Unit) { + return@Function 0.0 + } else { + return@Function ret + } + } + Unit + } + } + + class InstructionContext(val entity: Entity, val state: PoseableEntityState<*>) + + fun runInstruction(entity: T, state: PoseableEntityState, expression: Expression) { + val ctx = InstructionContext(entity, state) + context = ctx + expression.evaluate(MoScope(), sharedRuntime.environment) + context = null + } + + init { + registerInstruction("say") { entity, _, params -> + MinecraftClient.getInstance().player?.sendMessage(params.getString(0).text()) + Unit + } } } - fun run(model: PoseableEntityModel<*>, entity: Entity?, state: PoseableEntityState<*>?, previousSecondsPassed: Double, secondsPassed: Double): Boolean { - var animationSeconds = secondsPassed + fun run(model: PoseableEntityModel<*>, state: PoseableEntityState<*>?, animationSeconds: Float): Boolean { + var animationSeconds = animationSeconds if (shouldLoop) { - animationSeconds %= animationLength + animationSeconds %= animationLength.toFloat() } else if (animationSeconds > animationLength && animationLength > 0) { return false } - if (entity != null && state != null) { - val particleEffectsToPlay = mutableListOf() - if (previousSecondsPassed > animationSeconds) { - particleEffectsToPlay.addAll(particleEffects.filter { it.seconds >= previousSecondsPassed || it.seconds <= animationSeconds }) - } else { - particleEffectsToPlay.addAll(particleEffects.filter { it.seconds in previousSecondsPassed..animationSeconds }) - } - - for (particleEffect in particleEffectsToPlay) { - val world = entity.world as ClientWorld - val matrixWrapper = state.locatorStates[particleEffect.locator] ?: state.locatorStates["root"]!! - val effect = particleEffect.effect - - if (particleEffect in state.poseParticles) { - continue - } - - val storm = ParticleStorm( - effect = effect, - matrixWrapper = matrixWrapper, - world = world, - sourceVelocity = { entity.velocity }, - sourceAlive = { !entity.isRemoved && particleEffect in state.poseParticles }, - sourceVisible = { !entity.isInvisible } - ) - - state.poseParticles.add(particleEffect) - storm.runtime.execute(particleEffect.scripts) - storm.spawn() - } - } - boneTimelines.forEach { (boneName, timeline) -> val part = model.relevantPartsByName[boneName] if (part != null) { if (!timeline.position.isEmpty()) { - val position = timeline.position.resolve(animationSeconds, state?.runtime ?: sharedRuntime).multiply(model.getChangeFactor(part.modelPart).toDouble()) + val position = timeline.position.resolve(animationSeconds.toDouble(), state?.runtime ?: sharedRuntime).multiply(model.getChangeFactor(part.modelPart).toDouble()) part.modelPart.apply { pivotX += position.x.toFloat() pivotY += position.y.toFloat() @@ -105,7 +175,7 @@ data class BedrockAnimation( if (!timeline.rotation.isEmpty()) { try { - val rotation = timeline.rotation.resolve(animationSeconds, state?.runtime ?: sharedRuntime).multiply(model.getChangeFactor(part.modelPart).toDouble()) + val rotation = timeline.rotation.resolve(animationSeconds.toDouble(), state?.runtime ?: sharedRuntime).multiply(model.getChangeFactor(part.modelPart).toDouble()) part.modelPart.apply { pitch += rotation.x.toFloat().toRadians() yaw += rotation.y.toFloat().toRadians() @@ -125,7 +195,7 @@ data class BedrockAnimation( } if (!timeline.scale.isEmpty()) { - var scale = timeline.scale.resolve(animationSeconds, state?.runtime ?: sharedRuntime) + var scale = timeline.scale.resolve(animationSeconds.toDouble(), state?.runtime ?: sharedRuntime) val deviation = scale.multiply(-1.0).add(1.0, 1.0, 1.0).multiply(model.getChangeFactor(part.modelPart).toDouble()) scale = deviation.subtract(1.0, 1.0, 1.0).multiply(-1.0) val mp = part.modelPart @@ -137,6 +207,17 @@ data class BedrockAnimation( } return true } + + fun applyEffects(entity: T, state: PoseableEntityState, previousSeconds: Float, newSeconds: Float) { + val effectCondition: (effectKeyframe: BedrockEffectKeyframe) -> Boolean = + if (previousSeconds > newSeconds) { + { it.seconds >= previousSeconds || it.seconds <= newSeconds } + } else { + { it.seconds in previousSeconds..newSeconds } + } + + effects.filter(effectCondition).forEach { it.run(entity, state) } + } } interface BedrockBoneValue { @@ -164,7 +245,6 @@ class MolangBoneValue( override fun isEmpty() = false override fun resolve(time: Double, runtime: MoLangRuntime): Vec3d { val environment = runtime.environment - val scope = MoScope() environment.setSimpleVariable("anim_time", DoubleValue(time)) environment.setSimpleVariable("camera_rotation_x", DoubleValue(MinecraftClient.getInstance().gameRenderer.camera.rotation.x.toDouble())) environment.setSimpleVariable("camera_rotation_y", DoubleValue(MinecraftClient.getInstance().gameRenderer.camera.rotation.y.toDouble())) diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/bedrock/animation/BedrockAnimationAdapter.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/bedrock/animation/BedrockAnimationAdapter.kt index 4b21fb4310..20afeda8c6 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/bedrock/animation/BedrockAnimationAdapter.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/bedrock/animation/BedrockAnimationAdapter.kt @@ -11,6 +11,7 @@ package com.cobblemon.mod.common.client.render.models.blockbench.bedrock.animati import com.bedrockk.molang.MoLang import com.cobblemon.mod.common.Cobblemon.LOGGER import com.cobblemon.mod.common.client.particle.BedrockParticleEffectRepository +import com.cobblemon.mod.common.util.asExpression import com.cobblemon.mod.common.util.asIdentifierDefaultingNamespace import com.google.gson.JsonArray import com.google.gson.JsonDeserializationContext @@ -32,7 +33,7 @@ object BedrockAnimationAdapter : JsonDeserializer { val animationLength = json["animation_length"]?.asDouble ?: -1.0 val shouldLoop = animationLength > 0 && json["loop"]?.asBoolean == true val boneTimelines = mutableMapOf() - val particleEffects = mutableListOf() + val effects = mutableListOf() json["bones"]?.asJsonObject?.entrySet()?.forEach { (boneName, timeline) -> boneTimelines[boneName] = deserializeBoneTimeline(timeline.asJsonObject) } @@ -53,14 +54,46 @@ object BedrockAnimationAdapter : JsonDeserializer { } if (effectJson is JsonObject) { - particleEffects.add(resolveEffect(effectJson)) + effects.add(resolveEffect(effectJson)) } else if (effectJson is JsonArray) { for (effectJsonElement in effectJson) { - particleEffects.add(resolveEffect(effectJsonElement as JsonObject)) + effects.add(resolveEffect(effectJsonElement as JsonObject)) } } } - return BedrockAnimation(shouldLoop, animationLength, particleEffects, boneTimelines) + json["sound_effects"]?.asJsonObject?.entrySet()?.forEach { (frame, effectJson) -> + fun resolveEffect(jsonObject: JsonObject): BedrockSoundKeyframe { + val effectId = jsonObject.get("effect").asString.asIdentifierDefaultingNamespace() + val seconds = frame.toFloat() + return BedrockSoundKeyframe( + seconds = seconds, + sound = effectId, + ) + } + + if (effectJson is JsonObject) { + effects.add(resolveEffect(effectJson)) + } else if (effectJson is JsonArray) { + for (effectJsonElement in effectJson) { + effects.add(resolveEffect(effectJsonElement as JsonObject)) + } + } + } + + json["timeline"]?.asJsonObject?.entrySet()?.forEach { (frame, effectJson) -> + effects.add( + BedrockInstructionKeyframe( + seconds = frame.toFloat(), + expressions = if (effectJson is JsonArray) { + effectJson.asJsonArray.map { it.asString.let { if (it.endsWith(";")) it.substring(0, it.length - 1) else it }.asExpression() } + } else { + listOf(effectJson.asString.asExpression()) + } + ) + ) + } + + return BedrockAnimation(shouldLoop, animationLength, effects, boneTimelines) } else { throw IllegalStateException("animation json could not be parsed") diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/bedrock/animation/BedrockStatefulAnimation.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/bedrock/animation/BedrockStatefulAnimation.kt index e9e6a6d760..0054a8f5db 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/bedrock/animation/BedrockStatefulAnimation.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/bedrock/animation/BedrockStatefulAnimation.kt @@ -31,7 +31,7 @@ open class BedrockStatefulAnimation( return this } - var secondsPassed = 0F + var startedSeconds = -1F var isTransformAnimation = false private var afterAction: (T, PoseableEntityState) -> Unit = { _, _ -> } @@ -57,12 +57,20 @@ open class BedrockStatefulAnimation( headYaw: Float, headPitch: Float ): Boolean { - val previousSeconds = secondsPassed - secondsPassed += state.deltaSeconds - return animation.run(model, entity, state, previousSeconds.toDouble(), secondsPassed.toDouble()).also { + if (startedSeconds == -1F) { + startedSeconds = state.animationSeconds + } + + return animation.run(model, state, state.animationSeconds - startedSeconds).also { if (!it && entity != null) { afterAction(entity, state) } } } + + override fun applyEffects(entity: T, state: PoseableEntityState, previousSeconds: Float, newSeconds: Float) { + val previousSecondsOffset = previousSeconds - startedSeconds + val currentSecondsOffset = newSeconds - startedSeconds + animation.applyEffects(entity, state, previousSecondsOffset, currentSecondsOffset) + } } \ No newline at end of file diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/bedrock/animation/BedrockStatelessAnimation.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/bedrock/animation/BedrockStatelessAnimation.kt index d66f5c0242..ac0c9c7052 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/bedrock/animation/BedrockStatelessAnimation.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/bedrock/animation/BedrockStatelessAnimation.kt @@ -12,6 +12,7 @@ import com.cobblemon.mod.common.client.render.models.blockbench.PoseableEntityMo import com.cobblemon.mod.common.client.render.models.blockbench.PoseableEntityState import com.cobblemon.mod.common.client.render.models.blockbench.animation.StatelessAnimation import com.cobblemon.mod.common.client.render.models.blockbench.frame.ModelFrame +import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen1.PikachuModel import net.minecraft.entity.Entity /** @@ -26,18 +27,13 @@ import net.minecraft.entity.Entity */ class BedrockStatelessAnimation(frame: ModelFrame, val animation: BedrockAnimation) : StatelessAnimation(frame) { override val targetFrame: Class = ModelFrame::class.java - val particleKeyFrames = animation.particleEffects - - var speed = 1F - - fun setSpeed(speed: Float): BedrockStatelessAnimation { - this.speed = speed - return this - } + val particleKeyFrames = animation.effects.filterIsInstance() override fun setAngles(entity: T?, model: PoseableEntityModel, state: PoseableEntityState?, limbSwing: Float, limbSwingAmount: Float, ageInTicks: Float, headYaw: Float, headPitch: Float) { - val prev = if (state == null) 0F else (state.previousAnimationSeconds - state.timeEnteredPose) - val cur = if (state == null) 0F else (state.animationSeconds - state.timeEnteredPose) - animation.run(model, entity, state, prev * speed.toDouble(), cur * speed.toDouble()) + animation.run(model, state, state?.animationSeconds ?: 0F) + } + + override fun applyEffects(entity: T, state: PoseableEntityState, previousSeconds: Float, newSeconds: Float) { + animation.applyEffects(entity, state, (previousSeconds % animation.animationLength).toFloat(), (newSeconds % animation.animationLength).toFloat()) } } \ No newline at end of file diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/pokemon/PokemonFloatingState.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/pokemon/PokemonFloatingState.kt index 80b467b83f..33b41e21ff 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/pokemon/PokemonFloatingState.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/pokemon/PokemonFloatingState.kt @@ -12,11 +12,20 @@ import com.cobblemon.mod.common.client.render.models.blockbench.PoseableEntitySt import com.cobblemon.mod.common.entity.pokemon.PokemonEntity /** - * A [PoseableEntityState] that exists even without an entity or other concrete state. This is - * for when a Pokémon needs to be continuously animated and there isn't an entity to attach state - * to. + * A [PoseableEntityState] that exists even without an entity or age-based state. This is + * for when a Pokémon needs to be continuously animated from GUIs and there isn't an entity + * to attach state to. It has no age, and updating the partial ticks will increment rather + * than replace. + * + * What to look out for: Don't run updatePartialTicks multiple times in a single frame. For + * other [PoseableEntityState] this is fine as it just replaces what was there before, but + * since this is incremental it would actually mess up the animation speeds. * * @author Hiroku * @since May 1st, 2022 */ -class PokemonFloatingState : PoseableEntityState() \ No newline at end of file +class PokemonFloatingState : PoseableEntityState() { + override fun updatePartialTicks(partialTicks: Float) { + this.currentPartialTicks += partialTicks + } +} \ No newline at end of file diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/pokemon/gen1/ElectrodeModel.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/pokemon/gen1/ElectrodeModel.kt index 5b1fd65414..70d5d6a8e5 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/pokemon/gen1/ElectrodeModel.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/pokemon/gen1/ElectrodeModel.kt @@ -45,7 +45,7 @@ class ElectrodeModel(root: ModelPart) : PokemonPoseableModel() { poseTypes = MOVING_POSES, transformTicks = 0, quirks = arrayOf(blink), - onTransitionedInto = { it?.animationSeconds = 0F }, + onTransitionedInto = { it?.reset() }, idleAnimations = arrayOf( bedrock("electrode", "ground_walk") ) diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/pokemon/gen1/VoltorbModel.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/pokemon/gen1/VoltorbModel.kt index 5430c8a7ef..ef56cc5daf 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/pokemon/gen1/VoltorbModel.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/pokemon/gen1/VoltorbModel.kt @@ -43,7 +43,7 @@ class VoltorbModel(root: ModelPart) : PokemonPoseableModel() { walk = registerPose( poseName = "walk", poseTypes = MOVING_POSES, - onTransitionedInto = { it?.animationSeconds = 0F }, + onTransitionedInto = { it?.reset() }, transformTicks = 0, idleAnimations = arrayOf( bedrock("voltorb", "ground_walk") diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/pose/Pose.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/pose/Pose.kt index 1ccb6016c9..d85fcab92f 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/pose/Pose.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/models/blockbench/pose/Pose.kt @@ -37,11 +37,13 @@ class Pose( } fun idleStateful(entity: T?, model: PoseableEntityModel, state: PoseableEntityState, limbSwing: Float, limbSwingAmount: Float, ageInTicks: Float, headYaw: Float, headPitch: Float) { - idleAnimations.forEach { idleAnimation -> - val allStatefuls = state.statefulAnimations + state.quirks.flatMap { it.value.animations } - if (allStatefuls.none { it.preventsIdle(entity, state, idleAnimation) }) { - idleAnimation.apply(entity, model, state, limbSwing, limbSwingAmount, ageInTicks, headYaw, headPitch) - } + getApplicableIdleAnimations(entity, state).forEach { idleAnimation -> + idleAnimation.apply(entity, model, state, limbSwing, limbSwingAmount, ageInTicks, headYaw, headPitch) } } + + fun getApplicableIdleAnimations(entity: T?, state: PoseableEntityState): List> { + val allStatefulAnimations = state.allStatefulAnimations + return idleAnimations.filter { idle -> allStatefulAnimations.none { it.preventsIdle(entity, state, idle) } } + } } \ No newline at end of file diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/pokeball/PokeBallRenderer.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/pokeball/PokeBallRenderer.kt index cdecdfc126..6c1031b3fe 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/pokeball/PokeBallRenderer.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/pokeball/PokeBallRenderer.kt @@ -36,6 +36,7 @@ class PokeBallRenderer(context: EntityRendererFactory.Context) : EntityRenderer< val vertexConsumer = ItemRenderer.getDirectItemGlintConsumer(buffer, model.getLayer(getTexture(entity)), false, false) val state = entity.delegate as EmptyPokeBallClientDelegate + state.updatePartialTicks(partialTicks) model.setLayerContext(buffer, state, PokemonModelRepository.getLayers(entity.pokeBall.name, entity.aspects.get())) model.setAngles(entity, 0f, 0f, entity.age + partialTicks, 0F, 0F) model.render(poseStack, vertexConsumer, packedLight, OverlayTexture.DEFAULT_UV, 1.0f, 1.0f, 1.0f, 1.0f) diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/pokemon/PokemonRenderer.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/pokemon/PokemonRenderer.kt index 41bbbd817b..82c596b505 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/pokemon/PokemonRenderer.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/pokemon/PokemonRenderer.kt @@ -106,6 +106,8 @@ class PokemonRenderer( renderBeam(poseMatrix, partialTicks, entity, phaseTarget, lightColour, buffer) } + clientDelegate.updatePartialTicks(partialTicks) + modelNow.setLayerContext(buffer, clientDelegate, PokemonModelRepository.getLayers(entity.pokemon.species.resourceIdentifier, entity.aspects.get())) super.render(entity, entityYaw, partialTicks, poseMatrix, buffer, packedLight) diff --git a/deps/local/com/bedrockk/molang/1.1.1/molang-1.1.1.jar b/deps/local/com/bedrockk/molang/1.1.3/molang-1.1.3.jar similarity index 86% rename from deps/local/com/bedrockk/molang/1.1.1/molang-1.1.1.jar rename to deps/local/com/bedrockk/molang/1.1.3/molang-1.1.3.jar index 0b6e42f5bb1e62c28a7895a4d4146c485988a7a5..1f3ce223ba75876f2d1eb1bdcf2aa1f152f1a8d1 100644 GIT binary patch delta 8302 zcmZ8mbwE_x*PWreq+4K+?rxA6y1TneLVBd75s;w-C6ttIP&!3gx?38N6671epYOeo zf6l&Zt+V&O=ia-|=FH|6;_WsfrkWx=0vZ5-f&%!NvHc3O3;u4H;DjHqYpO;8qRZSH zgtD_*cS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S&|-|PVq#2umkLib^c4scYH$bTUeSegSIWi1NCN%|1N1jGP* zSe_Gn2XA$h!V$nmyb`<1Njn0Zh=SsGPJ|;Mju;|&=d9j1q|yLvL>j&bDJS?G8vl3^ fPJlGx-qSz1LnnCQA0U4`C1-#M#Z(b~$PxYzOiYn} diff --git a/deps/local/com/bedrockk/molang/1.1.1/molang-1.1.1.pom b/deps/local/com/bedrockk/molang/1.1.3/molang-1.1.3.pom similarity index 92% rename from deps/local/com/bedrockk/molang/1.1.1/molang-1.1.1.pom rename to deps/local/com/bedrockk/molang/1.1.3/molang-1.1.3.pom index b5134600f4..390c439568 100644 --- a/deps/local/com/bedrockk/molang/1.1.1/molang-1.1.1.pom +++ b/deps/local/com/bedrockk/molang/1.1.3/molang-1.1.3.pom @@ -4,5 +4,5 @@ 4.0.0 local.com.bedrockk molang - 1.1.1 + 1.1.3 diff --git a/deps/local/com/bedrockk/molang/maven-metadata-local.xml b/deps/local/com/bedrockk/molang/maven-metadata-local.xml index 6fde8741f0..cbea0d612e 100644 --- a/deps/local/com/bedrockk/molang/maven-metadata-local.xml +++ b/deps/local/com/bedrockk/molang/maven-metadata-local.xml @@ -3,10 +3,10 @@ local.com.bedrockk molang - 1.1.1 + 1.1.3 - 1.1.1 + 1.1.3 - 20221939127979 + 20221939127989 diff --git a/fabric/src/main/java/com/cobblemon/mod/fabric/mixin/GuiMixin.java b/fabric/src/main/java/com/cobblemon/mod/fabric/mixin/GuiMixin.java index eb6e8238c8..811551ea96 100644 --- a/fabric/src/main/java/com/cobblemon/mod/fabric/mixin/GuiMixin.java +++ b/fabric/src/main/java/com/cobblemon/mod/fabric/mixin/GuiMixin.java @@ -25,22 +25,20 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; */ @Mixin(InGameHud.class) public class GuiMixin { + private Long lastTimeMillis = null; @Inject( method = "render", at = @At( value = "INVOKE", - target = "Lnet/minecraft/client/MinecraftClient;getProfiler()Lnet/minecraft/util/profiler/Profiler;", + target = "Lnet/minecraft/client/gui/hud/ChatHud;render(Lnet/minecraft/client/gui/DrawContext;III)V", shift = At.Shift.BEFORE, ordinal = 0 - ), - slice = @Slice( - from = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/gui/hud/InGameHud;renderScoreboardSidebar(Lnet/minecraft/client/gui/DrawContext;Lnet/minecraft/scoreboard/ScoreboardObjective;)V" - ) ) ) private void beforeChatHook(DrawContext context, float f, CallbackInfo ci) { - CobblemonClient.INSTANCE.beforeChatRender(context, f); + if (lastTimeMillis != null) { + CobblemonClient.INSTANCE.beforeChatRender(context, (System.currentTimeMillis() - lastTimeMillis) / 1000F * 20); + } + lastTimeMillis = System.currentTimeMillis(); } } diff --git a/gradle/libs.versions.yml b/gradle/libs.versions.yml index f9319869a4..2e1903cf8b 100644 --- a/gradle/libs.versions.yml +++ b/gradle/libs.versions.yml @@ -23,7 +23,7 @@ versions: # common graal: 22.3.0 - molang: 1.1.1 + molang: 1.1.3 # test junit: 5.9.0