Merge pull request #30

Custom default animation feature
This commit is contained in:
Will FP
2022-09-28 14:33:39 +01:00
committed by GitHub
2 changed files with 19 additions and 0 deletions

View File

@@ -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

View File

@@ -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)