mirror of
https://gitlab.com/cable-mc/cobblemon.git
synced 2026-11-19 06:38:53 -05:00
Merge branch 'main' of https://gitlab.com/cable-mc/cobblemon into implement_pokemon
This commit is contained in:
commit
84dfaa0a77
11 files changed
+212
-37
No files matched your search
+5
-3
@@ -8,6 +8,8 @@
|
||||
|
||||
package com.cobblemon.mod.common.client.render.models.blockbench.pose;
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.PoseableEntityModel;
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.repository.RenderContext;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -38,7 +40,7 @@ public interface Bone {
|
||||
/**
|
||||
* Renders a particular bone in relation to a particular entity.
|
||||
*
|
||||
* @param entity The entity this bone is being drawn for. This parameter need not be available and can be null
|
||||
* @param context The render context this bone is being drawn for.
|
||||
* @param stack The current [MatrixStack] for the renderer
|
||||
* @param buffer The vertex consumer deployed by the renderer
|
||||
* @param packedLight The light level to be applied to the bone
|
||||
@@ -50,8 +52,8 @@ public interface Bone {
|
||||
*
|
||||
* @since 1.4.0
|
||||
*/
|
||||
<T extends Entity> void render(
|
||||
@Nullable T entity,
|
||||
void render(
|
||||
RenderContext context,
|
||||
MatrixStack stack,
|
||||
VertexConsumer buffer,
|
||||
int packedLight,
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
|
||||
package com.cobblemon.mod.common.mixin;
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.PoseableEntityModel;
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Bone;
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.repository.RenderContext;
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
@@ -36,7 +38,7 @@ public abstract class ModelPartMixin implements Bone {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Entity> void render(T entity, MatrixStack stack, VertexConsumer buffer, int packedLight, int packedOverlay, float r, float g, float b, float a) {
|
||||
public void render(RenderContext context, MatrixStack stack, VertexConsumer buffer, int packedLight, int packedOverlay, float r, float g, float b, float a) {
|
||||
this.render(stack, buffer, packedLight, packedOverlay, r, g, b, a);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.cobblemon.mod.common.api.text.font
|
||||
import com.cobblemon.mod.common.client.gui.battle.BattleOverlay.Companion.PORTRAIT_DIAMETER
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.PoseableEntityState
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.repository.PokemonModelRepository
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.repository.RenderContext
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.pokemon.Species
|
||||
@@ -181,6 +182,10 @@ fun drawPortraitPokemon(
|
||||
val model = PokemonModelRepository.getPoser(species.resourceIdentifier, aspects)
|
||||
val texture = PokemonModelRepository.getTexture(species.resourceIdentifier, aspects, state)
|
||||
|
||||
val context = RenderContext()
|
||||
PokemonModelRepository.variations[species.resourceIdentifier]?.getTexture(aspects, 0f).let { it -> context.put(RenderContext.TEXTURE, it) }
|
||||
context.put(RenderContext.SCALE, species.getForm(aspects).baseScale)
|
||||
|
||||
val renderType = model.getLayer(texture)
|
||||
|
||||
RenderSystem.applyModelViewMatrix()
|
||||
@@ -215,7 +220,7 @@ fun drawPortraitPokemon(
|
||||
val packedLight = LightmapTextureManager.pack(11, 7)
|
||||
|
||||
model.withLayerContext(immediate, state, PokemonModelRepository.getLayers(species.resourceIdentifier, aspects)) {
|
||||
model.render(matrixStack, buffer, packedLight, OverlayTexture.DEFAULT_UV, 1F, 1F, 1F, 1F)
|
||||
model.render(context, matrixStack, buffer, packedLight, OverlayTexture.DEFAULT_UV, 1F, 1F, 1F, 1F)
|
||||
immediate.draw()
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,10 @@
|
||||
|
||||
package com.cobblemon.mod.common.client.gui
|
||||
|
||||
import com.cobblemon.mod.common.api.pokemon.PokemonSpecies
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.PoseableEntityState
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.repository.PokemonModelRepository
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.repository.RenderContext
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.pokemon.RenderablePokemon
|
||||
@@ -52,6 +54,10 @@ fun drawProfilePokemon(
|
||||
val model = PokemonModelRepository.getPoser(species, aspects)
|
||||
val texture = PokemonModelRepository.getTexture(species, aspects, state)
|
||||
|
||||
val context = RenderContext()
|
||||
PokemonModelRepository.variations[species]?.getTexture(aspects, 0f).let { it -> context.put(RenderContext.TEXTURE, it) }
|
||||
context.put(RenderContext.SCALE, PokemonSpecies.getByIdentifier(species)!!.getForm(aspects).baseScale)
|
||||
|
||||
val renderType = model.getLayer(texture)
|
||||
|
||||
RenderSystem.applyModelViewMatrix()
|
||||
@@ -83,7 +89,7 @@ fun drawProfilePokemon(
|
||||
val packedLight = LightmapTextureManager.pack(11, 7)
|
||||
|
||||
model.withLayerContext(bufferSource, state, PokemonModelRepository.getLayers(species, aspects)) {
|
||||
model.render(matrixStack, buffer, packedLight, OverlayTexture.DEFAULT_UV, 1F, 1F, 1F, 1F)
|
||||
model.render(context, matrixStack, buffer, packedLight, OverlayTexture.DEFAULT_UV, 1F, 1F, 1F, 1F)
|
||||
bufferSource.draw()
|
||||
}
|
||||
|
||||
|
||||
+29
-25
@@ -24,6 +24,7 @@ import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.TransformedModelPart
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.quirk.ModelQuirk
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.quirk.SimpleQuirk
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.repository.RenderContext
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.wavefunction.WaveFunction
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.entity.Poseable
|
||||
@@ -55,7 +56,7 @@ import net.minecraft.util.math.RotationAxis
|
||||
abstract class PoseableEntityModel<T : Entity>(
|
||||
renderTypeFunc: (Identifier) -> RenderLayer = RenderLayer::getEntityCutout
|
||||
) : EntityModel<T>(renderTypeFunc), ModelFrame {
|
||||
var currentEntity: T? = null
|
||||
val context: RenderContext = RenderContext()
|
||||
|
||||
/** Whether the renderer that will process this is going to do the weird -1.5 Y offset bullshit that the living entity renderer does. */
|
||||
abstract val isForLivingEntityRenderer: Boolean
|
||||
@@ -116,7 +117,7 @@ abstract class PoseableEntityModel<T : Entity>(
|
||||
currentState = null
|
||||
}
|
||||
|
||||
open fun getOverlayTexture(entity: T?): Int? {
|
||||
open fun getOverlayTexture(entity: Entity?): Int? {
|
||||
return if (entity is LivingEntity) {
|
||||
OverlayTexture.packUv(
|
||||
OverlayTexture.getU(0F),
|
||||
@@ -271,12 +272,26 @@ abstract class PoseableEntityModel<T : Entity>(
|
||||
b: Float,
|
||||
a: Float
|
||||
) {
|
||||
renderModel(
|
||||
currentEntity,
|
||||
render(context, stack, buffer, packedLight, packedOverlay, r, g, b, a)
|
||||
}
|
||||
|
||||
fun render(
|
||||
context: RenderContext,
|
||||
stack: MatrixStack,
|
||||
buffer: VertexConsumer,
|
||||
packedLight: Int,
|
||||
packedOverlay: Int,
|
||||
r: Float,
|
||||
g: Float,
|
||||
b: Float,
|
||||
a: Float
|
||||
) {
|
||||
rootPart.render(
|
||||
context,
|
||||
stack,
|
||||
buffer,
|
||||
packedLight,
|
||||
getOverlayTexture(currentEntity) ?: packedOverlay,
|
||||
getOverlayTexture(context.request(RenderContext.ENTITY)) ?: packedOverlay,
|
||||
red * r,
|
||||
green * g,
|
||||
blue * b,
|
||||
@@ -290,12 +305,12 @@ abstract class PoseableEntityModel<T : Entity>(
|
||||
val renderLayer = getLayer(texture, layer.emissive, layer.translucent)
|
||||
val consumer = provider.getBuffer(renderLayer)
|
||||
stack.push()
|
||||
renderModel(
|
||||
currentEntity,
|
||||
rootPart.render(
|
||||
context,
|
||||
stack,
|
||||
consumer,
|
||||
packedLight,
|
||||
getOverlayTexture(currentEntity) ?: packedOverlay,
|
||||
getOverlayTexture(context.request(RenderContext.ENTITY)) ?: packedOverlay,
|
||||
layer.tint.x,
|
||||
layer.tint.y,
|
||||
layer.tint.z,
|
||||
@@ -306,20 +321,6 @@ abstract class PoseableEntityModel<T : Entity>(
|
||||
}
|
||||
}
|
||||
|
||||
fun renderModel(
|
||||
currentEntity: T?,
|
||||
stack: MatrixStack,
|
||||
buffer: VertexConsumer,
|
||||
packedLight: Int,
|
||||
packedOverlay: Int,
|
||||
r: Float,
|
||||
g: Float,
|
||||
b: Float,
|
||||
a: Float
|
||||
) {
|
||||
rootPart.render(currentEntity, stack, buffer, packedLight, packedOverlay, r, g, b, a)
|
||||
}
|
||||
|
||||
fun makeLayer(texture: Identifier, emissive: Boolean, translucent: Boolean): RenderLayer {
|
||||
val multiPhaseParameters: RenderLayer.MultiPhaseParameters = RenderLayer.MultiPhaseParameters.builder()
|
||||
.program(
|
||||
@@ -396,7 +397,6 @@ abstract class PoseableEntityModel<T : Entity>(
|
||||
headPitch: Float = 0F,
|
||||
ageInTicks: Float = 0F
|
||||
) {
|
||||
currentEntity = null
|
||||
setDefault()
|
||||
val pose = poseTypes.firstNotNullOfOrNull { getPose(it) } ?: poses.values.first()
|
||||
pose.transformedParts.forEach { it.apply() }
|
||||
@@ -412,7 +412,8 @@ abstract class PoseableEntityModel<T : Entity>(
|
||||
headYaw: Float,
|
||||
headPitch: Float
|
||||
) {
|
||||
currentEntity = entity
|
||||
context.put(RenderContext.ENTITY, entity)
|
||||
setupEntityTypeContext(entity)
|
||||
state.currentModel = this
|
||||
setDefault()
|
||||
state.preRender()
|
||||
@@ -469,6 +470,9 @@ abstract class PoseableEntityModel<T : Entity>(
|
||||
updateLocators(state)
|
||||
}
|
||||
|
||||
//This is used to set additional entity type specific context
|
||||
open fun setupEntityTypeContext(entity: T?) {}
|
||||
|
||||
override fun setAngles(
|
||||
entity: T,
|
||||
limbSwing: Float,
|
||||
@@ -510,7 +514,7 @@ abstract class PoseableEntityModel<T : Entity>(
|
||||
* found and used from other client-side systems.
|
||||
*/
|
||||
fun updateLocators(state: PoseableEntityState<T>) {
|
||||
val entity = currentEntity ?: return
|
||||
val entity = context.request(RenderContext.ENTITY) ?: return
|
||||
val matrixStack = MatrixStack()
|
||||
// We could improve this to be generalized for other entities
|
||||
if (entity is PokemonEntity) {
|
||||
|
||||
+2
-1
@@ -18,6 +18,7 @@ import com.cobblemon.mod.common.client.render.models.blockbench.frame.ModelFrame
|
||||
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 com.cobblemon.mod.common.client.render.models.blockbench.repository.RenderContext
|
||||
import java.util.concurrent.ConcurrentLinkedQueue
|
||||
import net.minecraft.entity.Entity
|
||||
import net.minecraft.util.math.Vec3d
|
||||
@@ -96,7 +97,7 @@ abstract class PoseableEntityState<T : Entity> {
|
||||
val poseImpl = model.getPose(pose) ?: return
|
||||
poseParticles.removeIf { particle -> poseImpl.idleAnimations.filterIsInstance<BedrockStatelessAnimation<*>>().flatMap { it.particleKeyFrames }.none(particle::isSameAs) }
|
||||
poseImpl.onTransitionedInto(this)
|
||||
val entity = getEntity()
|
||||
val entity = model.context.request(RenderContext.ENTITY) as T?
|
||||
if (entity != null) {
|
||||
poseImpl.idleAnimations
|
||||
.filterIsInstance<BedrockStatelessAnimation<*>>()
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@ 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
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.repository.RenderContext
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.util.asIdentifierDefaultingNamespace
|
||||
import com.cobblemon.mod.common.util.getString
|
||||
@@ -221,7 +222,7 @@ data class BedrockAnimation(
|
||||
roll += rotation.z.toFloat().toRadians()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
val exception = IllegalStateException("Bad animation for species: ${((model.currentEntity)!! as PokemonEntity).pokemon.species.name}", e)
|
||||
val exception = IllegalStateException("Bad animation for species: ${((model.context.request(RenderContext.ENTITY))!! as PokemonEntity).pokemon.species.name}", e)
|
||||
val crash = CrashReport("Cobblemon encountered an unexpected crash", exception)
|
||||
val section = crash.addElement("Animation Details")
|
||||
state?.let {
|
||||
|
||||
+13
-2
@@ -16,9 +16,13 @@ import com.cobblemon.mod.common.client.render.models.blockbench.animation.Statel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.ModelFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.TransformedModelPart
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.repository.PokemonModelRepository
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.repository.RenderContext
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import net.minecraft.client.render.OverlayTexture
|
||||
import net.minecraft.entity.Entity
|
||||
import net.minecraft.entity.LivingEntity
|
||||
import net.minecraft.util.math.Vec3d
|
||||
|
||||
/**
|
||||
@@ -72,8 +76,8 @@ abstract class PokemonPoseableModel : PoseableEntityModel<PokemonEntity>() {
|
||||
state: PoseableEntityState<PokemonEntity>
|
||||
): StatefulAnimation<PokemonEntity, ModelFrame>? = null
|
||||
|
||||
override fun getOverlayTexture(entity: PokemonEntity?): Int {
|
||||
return if (entity != null) {
|
||||
override fun getOverlayTexture(entity: Entity?): Int {
|
||||
return if (entity is PokemonEntity) {
|
||||
OverlayTexture.packUv(
|
||||
OverlayTexture.getU(0F),
|
||||
OverlayTexture.getV(entity.hurtTime > 0)
|
||||
@@ -89,6 +93,13 @@ abstract class PokemonPoseableModel : PoseableEntityModel<PokemonEntity>() {
|
||||
// pokemonEntity: PokemonEntity,
|
||||
// state: PoseableEntityState<PokemonEntity>
|
||||
// ): StatefulAnimation<PokemonEntity, ModelFrame>? = null
|
||||
|
||||
override fun setupEntityTypeContext (entity: PokemonEntity?) {
|
||||
entity?.let {
|
||||
context.put(RenderContext.SCALE, it.pokemon.form.baseScale)
|
||||
PokemonModelRepository.variations[it.pokemon.species.resourceIdentifier]?.getTexture(it.pokemon.aspects, 0f).let { texture -> context.put(RenderContext.TEXTURE, texture) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typealias PokemonPose = Pose<PokemonEntity, ModelFrame>
|
||||
|
||||
+4
-1
@@ -21,6 +21,7 @@ import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen8.*
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen9.*
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Bone
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.pokemon.Species
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
|
||||
object PokemonModelRepository : VaryingModelRepository<PokemonEntity, PokemonPoseableModel>() {
|
||||
@@ -593,4 +594,6 @@ object PokemonModelRepository : VaryingModelRepository<PokemonEntity, PokemonPos
|
||||
JsonPokemonPoseableModel.gson.fromJson(json, JsonPokemonPoseableModel::class.java)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* 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.render.models.blockbench.repository
|
||||
|
||||
import com.cobblemon.mod.common.util.asResource
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import net.minecraft.entity.Entity
|
||||
import net.minecraft.util.Identifier
|
||||
|
||||
|
||||
/**
|
||||
* The RenderContext class manages a context for rendering operations by associating data values with specific keys.
|
||||
*
|
||||
* @author Waterpicker
|
||||
* @since 1.4.0
|
||||
*/
|
||||
class RenderContext {
|
||||
// A map to store data values associated with keys
|
||||
private val context: MutableMap<Key<*>, Any?> = mutableMapOf()
|
||||
|
||||
/**
|
||||
* Retrieves a value from the context associated with the provided key.
|
||||
*
|
||||
* @param key The key associated with the desired value.
|
||||
* @return The value associated with the key, or null if not found.
|
||||
*
|
||||
* @since 1.4.0
|
||||
*/
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T : Any> request(key: Key<T>): T? = context[key] as T?
|
||||
|
||||
/**
|
||||
* Retrieves a value from the context associated with the provided key, assuming the value exists.
|
||||
*
|
||||
* @param key The key associated with the desired value.
|
||||
* @return The value associated with the key.
|
||||
* @throws NullPointerException If the value is not present in the context.
|
||||
*
|
||||
* @since 1.4.0
|
||||
*/
|
||||
fun <T : Any> requires(key: Key<T>): T = request(key) ?: throw NullPointerException("Required value not found in context for key: $key")
|
||||
|
||||
/**
|
||||
* Stores a value in the context associated with the provided key.
|
||||
*
|
||||
* @param key The key associated with the value.
|
||||
* @param value The value to be stored in the context.
|
||||
*
|
||||
* @since 1.4.0
|
||||
*/
|
||||
fun <T : Any> put(key: Key<T>, value: T?) {
|
||||
context[key] = value
|
||||
}
|
||||
|
||||
fun pop() = context.clear();
|
||||
|
||||
/**
|
||||
* Represents a key used for accessing values in the context.
|
||||
*
|
||||
* @param key The identifier associated with the key.
|
||||
* @param token The TypeToken representing the value's type.
|
||||
*
|
||||
* @since 1.4.0
|
||||
*/
|
||||
data class Key<T : Any>(val key: Identifier, val token: TypeToken<T>)
|
||||
|
||||
/**
|
||||
* Represents different rendering states or modes.
|
||||
*
|
||||
* @since 1.4.0
|
||||
*/
|
||||
enum class RenderState(
|
||||
/**
|
||||
* Indicates whether the mode is GUI-based.
|
||||
*/
|
||||
val isGuiBased: Boolean
|
||||
) {
|
||||
//World rendering mode.
|
||||
WORLD(false),
|
||||
|
||||
//Portrait rendering mode (GUI-based).
|
||||
PORTRAIT(true),
|
||||
|
||||
//Profile rendering mode (GUI-based).
|
||||
PROFILE(true)
|
||||
}
|
||||
|
||||
// Predefined keys for common data types
|
||||
companion object {
|
||||
/**
|
||||
* Key to access the currently rendered entity.
|
||||
*/
|
||||
val ENTITY: Key<Entity> = key("entity".asResource(), Entity::class.java)
|
||||
|
||||
/**
|
||||
* Key to access the identifier of the texture being rendered.
|
||||
*/
|
||||
val TEXTURE: Key<Identifier> = key("texture".asResource(), Identifier::class.java)
|
||||
|
||||
/**
|
||||
* Key to access the base scaling factor of the current species.
|
||||
*/
|
||||
val SCALE: Key<Float> = key("scale".asResource(), Float::class.java)
|
||||
|
||||
/**
|
||||
* Key to access the rendering state, indicating the active rendering mode.
|
||||
*/
|
||||
val RENDER_STATE: Key<RenderState> = key("state".asResource(), RenderState::class.java)
|
||||
|
||||
/**
|
||||
* Creates a new Key instance with the provided identifier and TypeToken.
|
||||
*
|
||||
* @param id The identifier associated with the key.
|
||||
* @param token The TypeToken representing the value's type.
|
||||
* @return A new Key instance.
|
||||
*
|
||||
* @since 1.4.0
|
||||
*/
|
||||
fun <T : Any> key(id: Identifier, token: TypeToken<T>): Key<T> = Key(id, token)
|
||||
|
||||
/**
|
||||
* Creates a new Key instance with the provided identifier and class type.
|
||||
*
|
||||
* @param id The identifier associated with the key.
|
||||
* @param clazz The class type representing the value's type.
|
||||
* @return A new Key instance.
|
||||
*
|
||||
* @since 1.4.0
|
||||
*/
|
||||
fun <T : Any> key(id: Identifier, clazz: Class<T>): Key<T> = key(id, TypeToken.get(clazz))
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -13,6 +13,7 @@ import com.cobblemon.mod.common.api.reactive.SettableObservable
|
||||
import com.cobblemon.mod.common.api.scheduling.after
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.PoseableEntityState
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokeball.PokeBallModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.repository.RenderContext
|
||||
import com.cobblemon.mod.common.entity.pokeball.EmptyPokeBallEntity
|
||||
import kotlin.random.Random
|
||||
|
||||
@@ -30,7 +31,7 @@ abstract class PokeBallPoseableState : PoseableEntityState<EmptyPokeBallEntity>(
|
||||
after(seconds = 0.2F) {
|
||||
if (model is PokeBallModel && stateEmitter.get() == EmptyPokeBallEntity.CaptureState.HIT) {
|
||||
doLater latest@{
|
||||
val entity = model.currentEntity ?: return@latest
|
||||
val entity = model.context.request(RenderContext.ENTITY) as EmptyPokeBallEntity? ?: return@latest
|
||||
model.moveToPose(entity, this, model.open)
|
||||
after(seconds = 1.75F) {
|
||||
state.statefulAnimations.clear()
|
||||
|
||||
Reference in new issue
Block a user