add default animation walk if not set

This commit is contained in:
mani1232
2022-09-27 11:50:18 +02:00
parent f1b5bac9cd
commit db3120f1de
4 changed files with 9 additions and 5 deletions

View File

@@ -54,7 +54,7 @@ class EcoPetsPlugin : LibReforgePlugin() {
return listOf(
IntegrationLoader("ModelEngine") {
PetEntity.registerPetEntity("modelengine") { pet, id ->
ModelEnginePetEntity(pet, id, pet.entityAnimation)
ModelEnginePetEntity(pet, id)
}
}
)

View File

@@ -114,7 +114,7 @@ class Pet(
val entityTexture = config.getString("entity-texture")
val entityAnimation = config.getString("default-animation")
var entityAnimation = config.getStringOrNull("default-animation")
private val levelXpRequirements = listOf(0) + config.getInts("level-xp-requirements")

View File

@@ -9,18 +9,18 @@ import org.bukkit.entity.ArmorStand
class ModelEnginePetEntity(
pet: Pet,
private val modelID: String,
private val animationString: String,
) : 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(animationString);
val animationProperty = animationHandler.getAnimation(entityAnimation);
if (animationProperty != null) {
animationHandler.playAnimation(animationProperty, true)
} else { EcoPetsPlugin.instance.logger.warning("$animationString not found in model $modelID") }
} else { EcoPetsPlugin.instance.logger.warning("$entityAnimation not found in model $modelID") }
val modelled = ModelEngineAPI.createModeledEntity(stand)
modelled.addModel(model, true)

View File

@@ -27,6 +27,10 @@ abstract class PetEntity(
return SkullPetEntity(pet)
}
if (pet.entityAnimation == null){
pet.entityAnimation = "walk";
}
val id = texture.split(":")[0]
val parse = registrations[id] ?: return SkullPetEntity(pet)
return parse(pet, texture.removePrefix("$id:"))