diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/Pet.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/Pet.kt index 45edae6..db12756 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/Pet.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/Pet.kt @@ -114,6 +114,8 @@ class Pet( val entityTexture = config.getString("entity-texture") + val entityAnimation = config.getString("default-animation") + private val levelXpRequirements = listOf(0) + config.getInts("level-xp-requirements") val maxLevel = levelXpRequirements.size diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/entity/ModelEnginePetEntity.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/entity/ModelEnginePetEntity.kt index 133074c..5e39d5b 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/entity/ModelEnginePetEntity.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/entity/ModelEnginePetEntity.kt @@ -1,6 +1,7 @@ package com.willfp.ecopets.pets.entity import com.ticxo.modelengine.api.ModelEngineAPI +import com.willfp.ecopets.EcoPetsPlugin import com.willfp.ecopets.pets.Pet import org.bukkit.Location import org.bukkit.entity.ArmorStand @@ -11,8 +12,24 @@ class ModelEnginePetEntity( ) : PetEntity(pet) { override fun spawn(location: Location): ArmorStand { val stand = emptyArmorStandAt(location, pet) + val entityAnimation = pet.entityAnimation val model = ModelEngineAPI.createActiveModel(modelID) + val animationHandler = model.animationHandler + val animationProperty = animationHandler.getAnimation(entityAnimation) + + if (animationProperty != null) { + animationHandler.playAnimation(animationProperty, true) + } else { + EcoPetsPlugin.instance.logger.warning("$entityAnimation not found in model $modelID, im use walk animation") + val animationPropertyWalk = animationHandler.getAnimation("walk") + if (animationPropertyWalk != null) { + animationHandler.playAnimation(animationPropertyWalk, true) + } else { + EcoPetsPlugin.instance.logger.warning("walk animation not found in $modelID, you have any animation!?") + } + } + val modelled = ModelEngineAPI.createModeledEntity(stand) modelled.addModel(model, true)