forked from mirrors/cobblemon
Added quirks to Json posers
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
- Added an interface that appears when interacting with your Pokémon while sneaking. The interface allows for interactive options such as shouldering and exchanging held items.
|
||||
- Added a new item for representing Pokémon within native UI menus.
|
||||
- Added support for Pokémon species data appending making it so datapack developers no longer need to overwrite files.
|
||||
- Added support for custom Pokémon to implement 'quirks' such as blinks.
|
||||
- Added an implementation of every [catch rate](https://bulbapedia.bulbagarden.net/wiki/Catch_rate) from generation 1 to 9, these can be used by changing the ``captureCalculator`` config value:
|
||||
- ``generation_1`` Sets the calculator to the generation 1 implementation.
|
||||
- ``generation_2`` Sets the calculator to the generation 2 implementation.
|
||||
|
||||
+16
-2
@@ -297,12 +297,26 @@ abstract class PoseableEntityModel<T : Entity>(
|
||||
secondsBetweenOccurrences: Pair<Float, Float> = 8F to 30F,
|
||||
loopTimes: IntRange = 1..1,
|
||||
condition: (state: PoseableEntityState<T>) -> Boolean = { true },
|
||||
animation: () -> StatefulAnimation<T, *>
|
||||
animation: (state: PoseableEntityState<T>) -> StatefulAnimation<T, *>
|
||||
) = SimpleQuirk(
|
||||
name = name,
|
||||
secondsBetweenOccurrences = secondsBetweenOccurrences,
|
||||
loopTimes = loopTimes,
|
||||
condition = condition,
|
||||
animations = { listOf(animation()) }
|
||||
animations = { listOf(animation(it)) }
|
||||
)
|
||||
|
||||
fun quirkMultiple(
|
||||
name: String,
|
||||
secondsBetweenOccurrences: Pair<Float, Float> = 8F to 30F,
|
||||
loopTimes: IntRange = 1..1,
|
||||
condition: (state: PoseableEntityState<T>) -> Boolean = { true },
|
||||
animations: (state: PoseableEntityState<T>) -> List<StatefulAnimation<T, *>>
|
||||
) = SimpleQuirk(
|
||||
name = name,
|
||||
secondsBetweenOccurrences = secondsBetweenOccurrences,
|
||||
loopTimes = loopTimes,
|
||||
condition = condition,
|
||||
animations = { animations(it) }
|
||||
)
|
||||
}
|
||||
|
||||
+28
-1
@@ -13,6 +13,7 @@ import com.cobblemon.mod.common.client.render.models.blockbench.animation.Statef
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.HeadedFrame
|
||||
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.SimpleQuirk
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.withPosition
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
@@ -82,6 +83,8 @@ class JsonPokemonPoseableModel(override val rootPart: ModelPart) : PokemonPoseab
|
||||
override val profileTranslation
|
||||
get() = _profileTranslation ?: Vec3d(0.0, 0.0, 0.0)
|
||||
|
||||
|
||||
|
||||
val faint: StatefulAnimation<PokemonEntity, ModelFrame>? = null
|
||||
|
||||
override fun getFaintAnimation(pokemonEntity: PokemonEntity, state: PoseableEntityState<PokemonEntity>) = faint
|
||||
@@ -155,6 +158,30 @@ class JsonPokemonPoseableModel(override val rootPart: ModelPart) : PokemonPoseab
|
||||
return@mapNotNull null
|
||||
}.toTypedArray()
|
||||
|
||||
val quirks = (obj.get("quirks")?.asJsonArray ?: JsonArray()).map { json ->
|
||||
json as JsonObject
|
||||
val name = json.get("name").asString
|
||||
val animations: (state: PoseableEntityState<PokemonEntity>) -> List<StatefulAnimation<PokemonEntity, *>> = { _ ->
|
||||
(json.get("animations")?.asJsonArray ?: JsonArray()).map { animJson ->
|
||||
val split =
|
||||
animJson.asString.replace("bedrock(", "").replace(")", "").split(",").map(String::trim)
|
||||
return@map model.bedrockStateful(animationGroup = split[0], animation = split[1]).setPreventsIdle(false)
|
||||
}
|
||||
}
|
||||
|
||||
val loopTimes = json.get("loopTimes")?.asInt ?: 1
|
||||
val minSeconds = json.get("minSecondsBetweenOccurrences")?.asFloat ?: 8F
|
||||
val maxSeconds = json.get("maxSecondsBetweenOccurrences")?.asFloat ?: 30F
|
||||
|
||||
model.quirkMultiple(
|
||||
name = name,
|
||||
secondsBetweenOccurrences = minSeconds to maxSeconds,
|
||||
condition = { true },
|
||||
loopTimes = 1..loopTimes,
|
||||
animations = animations
|
||||
)
|
||||
}
|
||||
|
||||
return Pose(
|
||||
poseName = poseName,
|
||||
poseTypes = poseTypes.toSet(),
|
||||
@@ -162,7 +189,7 @@ class JsonPokemonPoseableModel(override val rootPart: ModelPart) : PokemonPoseab
|
||||
transformTicks = transformTicks,
|
||||
idleAnimations = idleAnimations,
|
||||
transformedParts = transformedParts,
|
||||
quirks = arrayOf()
|
||||
quirks = quirks.toTypedArray()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ import net.minecraft.entity.Entity
|
||||
class SimpleQuirk<T : Entity>(
|
||||
name: String,
|
||||
private val secondsBetweenOccurrences: Pair<Float, Float>,
|
||||
val condition: (state: PoseableEntityState<T>) -> Boolean ,
|
||||
val condition: (state: PoseableEntityState<T>) -> Boolean = { true },
|
||||
val loopTimes: IntRange = 1..1,
|
||||
val animations: (state: PoseableEntityState<T>) -> Iterable<StatefulAnimation<T, *>>
|
||||
) : ModelQuirk<T, SimpleQuirkData<T>>(name) {
|
||||
|
||||
Reference in New Issue
Block a user