add default animation walk if not set
This commit is contained in:
@@ -54,7 +54,7 @@ class EcoPetsPlugin : LibReforgePlugin() {
|
||||
return listOf(
|
||||
IntegrationLoader("ModelEngine") {
|
||||
PetEntity.registerPetEntity("modelengine") { pet, id ->
|
||||
ModelEnginePetEntity(pet, id, pet.entityAnimation)
|
||||
ModelEnginePetEntity(pet, id)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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:"))
|
||||
|
||||
Reference in New Issue
Block a user