Custom default animation feature
This commit is contained in:
@@ -54,7 +54,7 @@ class EcoPetsPlugin : LibReforgePlugin() {
|
||||
return listOf(
|
||||
IntegrationLoader("ModelEngine") {
|
||||
PetEntity.registerPetEntity("modelengine") { pet, id ->
|
||||
ModelEnginePetEntity(pet, id)
|
||||
ModelEnginePetEntity(pet, id, pet.entityAnimation)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -7,12 +7,18 @@ import org.bukkit.entity.ArmorStand
|
||||
|
||||
class ModelEnginePetEntity(
|
||||
pet: Pet,
|
||||
private val modelID: String
|
||||
private val modelID: String,
|
||||
private val animationString: String,
|
||||
) : PetEntity(pet) {
|
||||
override fun spawn(location: Location): ArmorStand {
|
||||
val stand = emptyArmorStandAt(location, pet)
|
||||
|
||||
val model = ModelEngineAPI.createActiveModel(modelID)
|
||||
val animationHandler = model.animationHandler;
|
||||
val modelAnimation = animationHandler.getAnimation(animationString);
|
||||
|
||||
if (modelAnimation != null) animationHandler.playAnimation(modelAnimation, true);
|
||||
|
||||
val modelled = ModelEngineAPI.createModeledEntity(stand)
|
||||
modelled.addModel(model, true)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user