From 16ba41f39a650d73bb16bf4ae2a2b8824ff7218a Mon Sep 17 00:00:00 2001 From: DaRacci Date: Tue, 27 Sep 2022 00:04:15 +1000 Subject: [PATCH] feat: ModelEngine support --- build.gradle.kts | 3 ++ eco-core/core-plugin/build.gradle.kts | 4 +- .../com/willfp/ecobosses/bosses/EcoBoss.kt | 37 +++++++++++-------- .../willfp/ecobosses/bosses/LivingEcoBoss.kt | 2 +- .../ecobosses/events/BossTryDropItemEvent.kt | 3 +- .../src/main/resources/bosses/_example.yml | 1 + 6 files changed, 31 insertions(+), 19 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index e350f2a..ec7aa0a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -49,6 +49,7 @@ allprojects { maven("https://maven.sk89q.com/repo/") maven("https://github.com/factions-site/repo/raw/public/") maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") + maven("https://mvn.lumine.io/repository/maven-public/") { metadataSources.mavenPom() } } dependencies { @@ -58,6 +59,8 @@ allprojects { implementation("com.willfp:libreforge:3.104.0") implementation("org.joml:joml:1.10.4") + + compileOnly("com.ticxo.modelengine:api:R3.0.0") } java { diff --git a/eco-core/core-plugin/build.gradle.kts b/eco-core/core-plugin/build.gradle.kts index e6e233f..865fa03 100644 --- a/eco-core/core-plugin/build.gradle.kts +++ b/eco-core/core-plugin/build.gradle.kts @@ -3,6 +3,8 @@ version = rootProject.version dependencies { compileOnly("org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT") - compileOnly("com.github.lokka30:LevelledMobs:3.1.4") compileOnly("net.kyori:adventure-api:4.9.3") + + // Integrations + compileOnly("com.github.lokka30:LevelledMobs:3.1.4") } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobosses/bosses/EcoBoss.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobosses/bosses/EcoBoss.kt index 356b22b..3d289e9 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobosses/bosses/EcoBoss.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobosses/bosses/EcoBoss.kt @@ -1,5 +1,6 @@ package com.willfp.ecobosses.bosses +import com.ticxo.modelengine.api.ModelEngineAPI import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.entities.CustomEntity @@ -168,11 +169,7 @@ class EcoBoss( val x = config.getDouble("x") val y = config.getDouble("y") val z = config.getDouble("z") - locations.add( - Location( - world, x, y, z - ) - ) + locations.add(Location(world, x, y, z)) } locations @@ -206,9 +203,11 @@ class EcoBoss( val map = mutableMapOf() for (value in BossLifecycle.values()) { - map[value] = PlayableSound(config.getSubsections("sounds.${value.name.lowercase()}").map { - ConfiguredSound.fromConfig(it) - }) + map[value] = PlayableSound( + config.getSubsections("sounds.${value.name.lowercase()}").map { + ConfiguredSound.fromConfig(it) + } + ) } map @@ -279,7 +278,6 @@ class EcoBoss( config.getInt("rewards.xp.maximum") ) - private val drops: Iterable = run { val list = mutableListOf() @@ -300,6 +298,8 @@ class EcoBoss( private val mob: TestableEntity = Entities.lookup(config.getString("mob")) + private val modelEngineID: String = config.getString("modelEngineID") + private val currentlyAlive = mutableMapOf() override val conditions = config.getSubsections("conditions").mapNotNull { @@ -338,8 +338,7 @@ class EcoBoss( ) if (hasCustomAI) { - val controller = EntityController.getFor(mob) - .clearAllGoals() + val controller = EntityController.getFor(mob).clearAllGoals() @Suppress("UNCHECKED_CAST") // What could go wrong? targetGoals.forEach { controller.addTargetGoal(it.priority, it.goal as TargetGoal) } @@ -347,6 +346,13 @@ class EcoBoss( entityGoals.forEach { controller.addEntityGoal(it.priority, it.goal as EntityGoal) } } + if (modelEngineID.isNotBlank() && Bukkit.getPluginManager().isPluginEnabled("modelEngine")) { + val model = ModelEngineAPI.createActiveModel(modelEngineID) + val modelled = ModelEngineAPI.createModeledEntity(mob) + modelled.addModel(model, true) + modelled.isBaseEntityVisible = false + } + val boss = LivingEcoBoss( plugin, mob, @@ -437,7 +443,6 @@ class EcoBoss( ) } - override fun equals(other: Any?): Boolean { if (other !is EcoBoss) { return false @@ -451,8 +456,10 @@ class EcoBoss( } override fun toString(): String { - return ("EcoBoss{" - + id - + "}") + return ( + "EcoBoss{" + + id + + "}" + ) } } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobosses/bosses/LivingEcoBoss.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobosses/bosses/LivingEcoBoss.kt index aab4793..e85637f 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobosses/bosses/LivingEcoBoss.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobosses/bosses/LivingEcoBoss.kt @@ -48,6 +48,6 @@ class LivingEcoBoss( } override fun toString(): String { - return "LivingEcoBoss{boss=${boss}, uuid=${entity.uniqueId}}" + return "LivingEcoBoss{boss=$boss, uuid=${entity.uniqueId}}" } } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobosses/events/BossTryDropItemEvent.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobosses/events/BossTryDropItemEvent.kt index 611b4f6..33887ba 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobosses/events/BossTryDropItemEvent.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobosses/events/BossTryDropItemEvent.kt @@ -1,7 +1,6 @@ package com.willfp.ecobosses.events import com.willfp.ecobosses.bosses.EcoBoss -import com.willfp.ecobosses.bosses.LivingEcoBoss import org.bukkit.Location import org.bukkit.entity.Player import org.bukkit.event.Event @@ -14,7 +13,7 @@ class BossTryDropItemEvent( var items: MutableCollection, var chance: Double, val player: Player? -): Event() { +) : Event() { override fun getHandlers(): HandlerList { return HANDLERS } diff --git a/eco-core/core-plugin/src/main/resources/bosses/_example.yml b/eco-core/core-plugin/src/main/resources/bosses/_example.yml index f757527..64a9ce1 100644 --- a/eco-core/core-plugin/src/main/resources/bosses/_example.yml +++ b/eco-core/core-plugin/src/main/resources/bosses/_example.yml @@ -7,6 +7,7 @@ # A base mob and modifiers # View an explanation for this system here: https://plugins.auxilor.io/all-plugins/the-entity-lookup-system mob: iron_golem attack-damage:90 movement-speed:1.5 follow-range:16 health:1200 +modelEngineID: "" # Supported placeholders: %health%, %time% (formats as minutes:seconds, eg 1:56) displayName: "&8Steel Golem &7| &c%health%♥ &7| &e%time%" influence: 40 # The distance at which effects will be applied to players