Add profile translation and scale properties specific to the Pokédex and summary

This commit is contained in:
lion
2026-06-16 13:44:41 +00:00
committed by Polymeta
parent 420cbd2c99
commit 8ec85e7d2f
23 changed files with 190 additions and 68 deletions
+2 -1
View File
@@ -362,7 +362,8 @@
- Separated all the functions of MoLangFunctions.kt into their own files.
- Spawn buckets and their base weights are now provided by the spawner, with different base weights for world, fishing, snack, and habitat spawn buckets.
- Removed "SpawnBucket" class in favour of just storing maps of bucket names to weights.
- Fixed nicknames not being applied to Pokémon spawned from `spawn_pool_world` files
- Fixed nicknames not being applied to Pokémon spawned from `spawn_pool_world` files.
- Added support for `profilePokedexScale`, `profilePokedexTranslation`, `profileSummaryScale`, and `profileSummaryTranslation` in poser files for finer control over profile displays.
### Molang & Datapacks
- Added `moveset_builders` datapack folder for different styles of movesets.
@@ -27,10 +27,18 @@ import net.minecraft.client.renderer.RenderType
import net.minecraft.client.renderer.texture.OverlayTexture
import net.minecraft.resources.ResourceLocation
import net.minecraft.util.Mth
import net.minecraft.world.phys.Vec3
import org.joml.Quaternionf
import org.joml.Vector3f
import kotlin.math.atan
enum class ProfileTransformType {
PROFILE,
NONE,
POKEDEX,
SUMMARY,
}
fun drawProfilePokemon(
renderablePokemon: RenderablePokemon,
matrixStack: PoseStack,
@@ -39,7 +47,7 @@ fun drawProfilePokemon(
state: PosableState,
partialTicks: Float,
scale: Float = 20F,
applyProfileTransform: Boolean = true,
profileTransformType: ProfileTransformType = ProfileTransformType.PROFILE,
applyBaseScale: Boolean = false,
r: Float = 1F,
g: Float = 1F,
@@ -56,7 +64,7 @@ fun drawProfilePokemon(
state = state.also { it.currentAspects = renderablePokemon.aspects },
partialTicks = partialTicks,
scale = scale,
applyProfileTransform = applyProfileTransform,
profileTransformType = profileTransformType,
applyBaseScale = applyBaseScale,
r = r,
g = g,
@@ -75,7 +83,7 @@ fun drawProfilePokemon(
state: PosableState,
partialTicks: Float,
scale: Float = 20F,
applyProfileTransform: Boolean = true,
profileTransformType: ProfileTransformType = ProfileTransformType.PROFILE,
applyBaseScale: Boolean = false,
doQuirks: Boolean = false,
r: Float = 1F,
@@ -114,18 +122,38 @@ fun drawProfilePokemon(
state.setPoseToFirstSuitable(poseType)
state.updatePartialTicks(partialTicks)
if (applyProfileTransform) {
matrixStack.translate(
model.profileTranslation.x,
model.profileTranslation.y + 1.5 * model.profileScale,
model.profileTranslation.z - 4.0
)
matrixStack.scale(model.profileScale, model.profileScale, 1 / model.profileScale)} else {
if (profileTransformType == ProfileTransformType.NONE) {
matrixStack.translate(0F, 0F, -4.0F)
if (applyBaseScale) {
matrixStack.scale(baseScale, baseScale, 1 / baseScale)
}
} else {
var profileScale: Float
var profileTranslation: Vec3
when (profileTransformType) {
ProfileTransformType.POKEDEX -> {
profileScale = model.profilePokedexScale ?: model.profileScale
profileTranslation = model.profilePokedexTranslation ?: model.profileTranslation
}
ProfileTransformType.SUMMARY -> {
profileScale = model.profileSummaryScale ?: model.profileScale
profileTranslation = model.profileSummaryTranslation ?: model.profileTranslation
}
else -> {
profileScale = model.profileScale
profileTranslation = model.profileTranslation
}
}
matrixStack.translate(
profileTranslation.x,
profileTranslation.y + 1.5 * profileScale,
profileTranslation.z - 4.0
)
matrixStack.scale(profileScale, profileScale, 1 / profileScale)
}
matrixStack.mulPose(rotation)
model.applyAnimations(null, state, 0F, 0F, 0F, headYaw, headPitch)
@@ -0,0 +1,97 @@
/*
* Copyright (C) 2023 Cobblemon Contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package com.cobblemon.mod.common.client.gui
import com.cobblemon.mod.common.Cobblemon
import com.cobblemon.mod.common.client.render.models.blockbench.FloatingState
import com.cobblemon.mod.common.client.render.models.blockbench.repository.VaryingModelRepository
import com.mojang.blaze3d.platform.InputConstants
import net.minecraft.client.Minecraft
import net.minecraft.network.chat.Component
import net.minecraft.resources.ResourceLocation
import net.minecraft.world.phys.Vec3
fun handleProfileDebugKeys(keyCode: Int, poserResourceLocation: ResourceLocation, state: FloatingState) {
if (!Cobblemon.config.enableDebugKeys) {
return
}
val model = VaryingModelRepository.getPoser(poserResourceLocation, state)
val delta = when (keyCode) {
InputConstants.KEY_UP -> Vec3(0.0, -0.01, 0.0)
InputConstants.KEY_DOWN -> Vec3(0.0, 0.01, 0.0)
InputConstants.KEY_LEFT -> Vec3(-0.01, 0.0, 0.0)
InputConstants.KEY_RIGHT -> Vec3(0.01, 0.0, 0.0)
else -> null
}
if (delta != null) {
model.profileTranslation = model.profileTranslation.add(delta)
model.profileSummaryTranslation = model.profileSummaryTranslation?.add(delta)
model.profilePokedexTranslation = model.profilePokedexTranslation?.add(delta)
}
val scaleDelta = when (keyCode) {
InputConstants.KEY_EQUALS -> 0.01F
InputConstants.KEY_MINUS -> -0.01F
else -> null
}
if (scaleDelta != null) {
model.profileScale += scaleDelta
model.profileSummaryScale = model.profileSummaryScale?.plus(scaleDelta)
model.profilePokedexScale = model.profilePokedexScale?.plus(scaleDelta)
}
}
fun logProfileTranslations(poserResourceLocation: ResourceLocation, state: FloatingState) {
if (!Cobblemon.config.enableDebugKeys) {
return
}
val model = VaryingModelRepository.getPoser(poserResourceLocation, state)
val player = Minecraft.getInstance().player
fun Double.f2() = "%.2f".format(this)
fun Float.f2() = "%.2f".format(this)
fun sendTranslation(name: String, translation: Vec3) {
player?.sendSystemMessage(Component.literal("$name Translation: (${translation.x.f2()}, ${translation.y.f2()}, ${translation.z.f2()})"))
}
fun sendScale(name: String, scale: Float) {
player?.sendSystemMessage(Component.literal("$name Scale: ${scale.f2()}"))
}
fun logTranslation(name: String, translation: Vec3) {
Cobblemon.LOGGER.info("override var ${name.replaceFirstChar(Char::lowercase)}Translation = Vec3(${translation.x.f2()}, ${translation.y.f2()}, ${translation.z.f2()})")
}
fun logScale(name: String, scale: Float) {
Cobblemon.LOGGER.info("override var ${name.replaceFirstChar(Char::lowercase)}Scale = ${scale.f2()}F")
}
sendTranslation("Profile", model.profileTranslation)
sendScale("Profile", model.profileScale)
model.profileSummaryTranslation?.let { sendTranslation("Summary Profile", it) }
model.profileSummaryScale?.let { sendScale("Summary Profile", it) }
model.profilePokedexTranslation?.let { sendTranslation("Pokedex Profile", it) }
model.profilePokedexScale?.let { sendScale("Pokedex Profile", it) }
logTranslation("Profile", model.profileTranslation)
logScale("Profile", model.profileScale)
model.profileSummaryTranslation?.let { logTranslation("ProfileSummary", it) }
model.profileSummaryScale?.let { logScale("ProfileSummary", it) }
model.profilePokedexTranslation?.let { logTranslation("ProfilePokedex", it) }
model.profilePokedexScale?.let { logScale("ProfilePokedex", it) }
}
@@ -32,6 +32,8 @@ import com.cobblemon.mod.common.client.ClientMoLangFunctions.setupClient
import com.cobblemon.mod.common.client.CobblemonClient
import com.cobblemon.mod.common.client.CobblemonResources
import com.cobblemon.mod.common.client.gui.CobblemonRenderable
import com.cobblemon.mod.common.client.gui.handleProfileDebugKeys
import com.cobblemon.mod.common.client.gui.logProfileTranslations
import com.cobblemon.mod.common.client.gui.pokedex.PokedexGUIConstants.BASE_HEIGHT
import com.cobblemon.mod.common.client.gui.pokedex.PokedexGUIConstants.BASE_WIDTH
import com.cobblemon.mod.common.client.gui.pokedex.PokedexGUIConstants.HALF_OVERLAY_WIDTH
@@ -427,6 +429,11 @@ class PokedexGUI private constructor(
override fun onClose() {
if (blockPos != null) AdjustBlockEntityViewerCountPacket(blockPos, false).sendToServer()
playSound(CobblemonSounds.POKEDEX_CLOSE)
selectedEntry?.speciesId?.let { speciesId ->
logProfileTranslations(speciesId, pokemonInfoWidget.state)
}
super.onClose()
}
@@ -757,6 +764,12 @@ class PokedexGUI private constructor(
return true
}
if (!searchWidget.isFocused) {
selectedEntry?.speciesId?.let { speciesId ->
handleProfileDebugKeys(keyCode, speciesId, pokemonInfoWidget.state)
}
}
return super.keyPressed(keyCode, scanCode, modifiers)
}
@@ -22,6 +22,7 @@ import com.cobblemon.mod.common.api.types.ElementalType
import com.cobblemon.mod.common.client.ClientMoLangFunctions.setupClient
import com.cobblemon.mod.common.client.CobblemonClient
import com.cobblemon.mod.common.client.CobblemonResources
import com.cobblemon.mod.common.client.gui.ProfileTransformType
import com.cobblemon.mod.common.client.gui.TypeIcon
import com.cobblemon.mod.common.client.gui.drawProfilePokemon
import com.cobblemon.mod.common.client.gui.pokedex.PokedexGUIConstants.HALF_OVERLAY_HEIGHT
@@ -386,7 +387,8 @@ class PokemonInfoWidget(val pX: Int, val pY: Int, val updateForm: (PokedexForm)
partialTicks = delta,
rotation = Quaternionf().fromEulerXYZDegrees(rotationVector),
state = state,
blockLight = 15
blockLight = 15,
profileTransformType = ProfileTransformType.POKEDEX,
)
matrices.popPose()
@@ -11,6 +11,7 @@ package com.cobblemon.mod.common.client.gui.pokedex.widgets
import com.cobblemon.mod.common.api.gui.blitk
import com.cobblemon.mod.common.api.text.bold
import com.cobblemon.mod.common.client.CobblemonResources
import com.cobblemon.mod.common.client.gui.ProfileTransformType
import com.cobblemon.mod.common.client.gui.drawProfilePokemon
import com.cobblemon.mod.common.client.gui.pokedex.PokedexGUIConstants.HALF_OVERLAY_WIDTH
import com.cobblemon.mod.common.client.gui.pokedex.PokedexGUIConstants.POKEMON_DESCRIPTION_HEIGHT
@@ -90,7 +91,7 @@ class SizeWidget(val pX: Int, val pY: Int) : SoundlessWidget(
rotation = Quaternionf().fromEulerXYZDegrees(Vector3f(0F, 0F, 0F)),
state = FloatingState(),
scale = modelScale,
applyProfileTransform = false,
profileTransformType = ProfileTransformType.NONE,
applyBaseScale = true,
r = 0F,
g = 0F,
@@ -8,7 +8,6 @@
package com.cobblemon.mod.common.client.gui.summary
import com.cobblemon.mod.common.Cobblemon
import com.cobblemon.mod.common.CobblemonItems
import com.cobblemon.mod.common.CobblemonNetwork.sendToServer
import com.cobblemon.mod.common.CobblemonSounds
@@ -21,14 +20,8 @@ import com.cobblemon.mod.common.api.text.bold
import com.cobblemon.mod.common.api.text.text
import com.cobblemon.mod.common.client.CobblemonClient
import com.cobblemon.mod.common.client.CobblemonResources
import com.cobblemon.mod.common.client.gui.CobblemonRenderable
import com.cobblemon.mod.common.client.gui.ExitButton
import com.cobblemon.mod.common.client.gui.TypeIcon
import com.cobblemon.mod.common.client.gui.summary.widgets.EvolutionSelectScreen
import com.cobblemon.mod.common.client.gui.summary.widgets.MarkingsWidget
import com.cobblemon.mod.common.client.gui.summary.widgets.ModelWidget
import com.cobblemon.mod.common.client.gui.summary.widgets.NicknameEntryWidget
import com.cobblemon.mod.common.client.gui.summary.widgets.PartyWidget
import com.cobblemon.mod.common.client.gui.*
import com.cobblemon.mod.common.client.gui.summary.widgets.*
import com.cobblemon.mod.common.client.gui.summary.widgets.screens.SummaryTab
import com.cobblemon.mod.common.client.gui.summary.widgets.screens.info.InfoWidget
import com.cobblemon.mod.common.client.gui.summary.widgets.screens.marks.MarksWidget
@@ -37,7 +30,6 @@ import com.cobblemon.mod.common.client.gui.summary.widgets.screens.moves.MovesWi
import com.cobblemon.mod.common.client.gui.summary.widgets.screens.stats.StatWidget
import com.cobblemon.mod.common.client.keybind.keybinds.SummaryBinding
import com.cobblemon.mod.common.client.render.drawScaledText
import com.cobblemon.mod.common.client.render.models.blockbench.repository.VaryingModelRepository
import com.cobblemon.mod.common.net.messages.server.pokemon.update.SetItemHiddenPacket
import com.cobblemon.mod.common.net.messages.server.storage.party.MovePartyPokemonPacket
import com.cobblemon.mod.common.net.messages.server.storage.party.SwapPartyPokemonPacket
@@ -715,27 +707,9 @@ class Summary private constructor(party: Collection<Pokemon?>, private val edita
) {
this.focused = null
}
if (Cobblemon.config.enableDebugKeys) {
val model = VaryingModelRepository.getPoser(selectedPokemon.species.resourceIdentifier, modelWidget.state)
if (keyCode == InputConstants.KEY_UP) {
model.profileTranslation = model.profileTranslation.add(0.0, -0.01, 0.0)
}
if (keyCode == InputConstants.KEY_DOWN) {
model.profileTranslation = model.profileTranslation.add(0.0, 0.01, 0.0)
}
if (keyCode == InputConstants.KEY_LEFT) {
model.profileTranslation = model.profileTranslation.add(-0.01, 0.0, 0.0)
}
if (keyCode == InputConstants.KEY_RIGHT) {
model.profileTranslation = model.profileTranslation.add(0.01, 0.0, 0.0)
}
if (keyCode == InputConstants.KEY_EQUALS) {
model.profileScale += 0.01F
}
if (keyCode == InputConstants.KEY_MINUS) {
model.profileScale -= 0.01F
}
}
handleProfileDebugKeys(keyCode, selectedPokemon.species.resourceIdentifier, modelWidget.state)
return super.keyPressed(keyCode, scanCode, modifiers)
}
@@ -744,13 +718,8 @@ class Summary private constructor(party: Collection<Pokemon?>, private val edita
}
override fun onClose() {
if (Cobblemon.config.enableDebugKeys) {
val model = VaryingModelRepository.getPoser(selectedPokemon.species.resourceIdentifier, modelWidget.state)
Minecraft.getInstance().player?.sendSystemMessage(Component.literal("Profile Translation: ${model.profileTranslation}"))
Minecraft.getInstance().player?.sendSystemMessage(Component.literal("Profile Scale: ${model.profileScale}"))
Cobblemon.LOGGER.info("override var profileTranslation = Vec3d(${model.profileTranslation.x}, ${model.profileTranslation.y}, ${model.profileTranslation.z})")
Cobblemon.LOGGER.info("override var profileScale = ${model.profileScale}F")
}
logProfileTranslations(selectedPokemon.species.resourceIdentifier, modelWidget.state)
super.onClose()
}
}
@@ -11,6 +11,7 @@ package com.cobblemon.mod.common.client.gui.summary.widgets
import com.bedrockk.molang.runtime.value.DoubleValue
import com.cobblemon.mod.common.Cobblemon
import com.cobblemon.mod.common.api.tags.CobblemonItemTags
import com.cobblemon.mod.common.client.gui.ProfileTransformType
import com.cobblemon.mod.common.client.gui.drawProfilePokemon
import com.cobblemon.mod.common.client.gui.calculateHeadYawAndPitch
import com.cobblemon.mod.common.client.render.models.blockbench.FloatingState
@@ -116,7 +117,8 @@ class ModelWidget(
partialTicks = partialTicks,
headYaw = currentYawAndPitch.first,
headPitch = currentYawAndPitch.second,
blockLight = blockLight
blockLight = blockLight,
profileTransformType = ProfileTransformType.SUMMARY,
)
heldItemRenderer.renderOnModel(
@@ -134,6 +134,11 @@ open class PosableModel(@Transient override val rootPart: Bone) : ModelFrame {
*/
open var profileTranslation = Vec3(0.0, 0.0, 0.0)
open var profilePokedexScale: Float? = null
open var profilePokedexTranslation: Vec3? = null
open var profileSummaryScale: Float? = null
open var profileSummaryTranslation: Vec3? = null
var red = 1F
var green = 1F
var blue = 1F
@@ -2,7 +2,8 @@
"portraitScale": 1.03,
"portraitTranslation": [-0.31, 0.12, 0],
"profileScale": 0.47,
"profileTranslation": [0, 0.98, 0.0],
"profileTranslation": [0.07, 0.98, 0.0],
"profilePokedexTranslation": [0, 0.98, 0],
"rootBone": "venusaur",
"firstPersonCameraOffset": {
"seat_1": [0, 0.25, 0]
@@ -1,8 +1,8 @@
{
"portraitScale": 1.89,
"portraitTranslation": [-0.13, 0.91, 0],
"profileScale": 0.63,
"profileTranslation": [0, 0.81, 0],
"profileScale": 0.77,
"profileTranslation": [0, 0.65, 0],
"rootBone": "charmeleon",
"animations": {
"cry": "q.bedrock_stateful('charmeleon', 'cry')"
@@ -2,7 +2,7 @@
"portraitScale": 2.1,
"portraitTranslation": [-1.11, 2.43, 0],
"profileScale": 0.54,
"profileTranslation": [0, 0.96, -10],
"profileTranslation": [0, 0.92, -10],
"rootBone": "charizard",
"firstPersonCameraOffset": {
"seat_1": [0, 0.45, 0]
@@ -1,8 +1,8 @@
{
"portraitScale": 1.89,
"portraitTranslation": [-0.8, 1.36, 0.0],
"profileScale": 0.59,
"profileTranslation": [0, 0.84, 0.0],
"profileScale": 0.57,
"profileTranslation": [0, 0.81, 0.0],
"rootBone": "nidoking",
"animations": {
"cry": "q.bedrock_stateful('nidoking', 'cry')",
@@ -2,7 +2,7 @@
"portraitScale": 1.8,
"portraitTranslation": [-0.35, -0.8, 0],
"profileScale": 0.8,
"profileTranslation": [0, 0.45, 0.0],
"profileTranslation": [0, 0.52, 0.0],
"rootBone": "parasect",
"firstPersonCameraOffset": {
"seat_1": [0, 0.45, 0]
@@ -1,6 +1,6 @@
{
"portraitScale": 1.96,
"portraitTranslation": [ -0.48, 1.61, 0],
"portraitTranslation": [ -0.3, 1.86, 0],
"profileScale": 0.53,
"profileTranslation": [0, 0.92, 0],
"rootBone": "mr_rime",
@@ -2,7 +2,7 @@
"portraitScale": 1.73,
"portraitTranslation": [-0.45, -1.17, 0],
"profileScale": 0.7,
"profileTranslation": [-0.06, 0.59, 0],
"profileTranslation": [0, 0.59, 0],
"rootBone": "dunsparce",
"animations": {
"cry": "q.bedrock_stateful('dunsparce', 'cry')",
@@ -2,7 +2,7 @@
"portraitScale": 1.73,
"portraitTranslation": [-0.09, 0.26, 0],
"profileScale": 0.60,
"profileTranslation": [0.16, 0.90, 0],
"profileTranslation": [0, 0.90, 0],
"rootBone": "beautifly",
"poses": {
"battle-standing": {
@@ -2,7 +2,7 @@
"portraitScale": 1.65,
"portraitTranslation": [-0.10, 0.16, 0],
"profileScale": 0.63,
"profileTranslation": [0.13, 0.64, 0],
"profileTranslation": [0, 0.64, 0],
"rootBone": "dustox",
"poses": {
"battle-standing": {
@@ -2,7 +2,9 @@
"portraitScale": 1.63,
"portraitTranslation": [-1.76, 1.25, 0],
"profileScale": 0.53,
"profileTranslation": [-0.09, 0.92, 0],
"profileTranslation": [0.49, 0.96, 0],
"profilePokedexTranslation": [0, 0.96, 0],
"profileSummaryTranslation": [-0.30, 0.87, 0],
"rootBone": "drapion",
"animations": {
"cry": "q.bedrock_stateful('drapion', 'cry')"
@@ -2,7 +2,7 @@
"portraitScale": 1.98,
"portraitTranslation": [-0.96, 1.39, 0],
"profileScale": 0.59,
"profileTranslation": [0.13, 0.82, 0],
"profileTranslation": [0, 0.84, 0],
"rootBone": "pyroar_female",
"animations": {
"cry": "q.bedrock_stateful('pyroar_female', 'cry')"
@@ -2,7 +2,7 @@
"portraitScale": 1.89,
"portraitTranslation": [-1.12, 1.78, 0],
"profileScale": 0.51,
"profileTranslation": [0.12, 0.94, 0],
"profileTranslation": [0, 0.97, 0],
"rootBone": "pyroar_male",
"animations": {
"cry": "q.bedrock_stateful('pyroar_male', 'cry')"
@@ -2,7 +2,8 @@
"portraitScale": 1.1,
"portraitTranslation": [-1.2, -0.009, 0],
"profileScale": 0.5,
"profileTranslation": [-0.18, 0.96, 0],
"profileTranslation": [0, 0.96, 0],
"profileSummaryTranslation": [-0.20, 0.87, 0],
"rootBone": "dudunsparce",
"firstPersonCameraOffset": {
"seat_1": [0, 0.45, 0],
@@ -2,7 +2,7 @@
"portraitScale": 1.1,
"portraitTranslation": [-0.8, -0.009, 0],
"profileScale": 0.5,
"profileTranslation": [-0.18, 0.96, 0],
"profileTranslation": [0, 0.96, 0],
"rootBone": "dudunsparce",
"firstPersonCameraOffset": {
"seat_1": [0, 0.45, 0],