9
0
mirror of https://github.com/Auxilor/EcoMobs.git synced 2025-12-20 07:29:21 +00:00

feat: ModelEngine support

This commit is contained in:
DaRacci
2022-09-27 00:04:15 +10:00
parent 685f40a71b
commit 16ba41f39a
6 changed files with 31 additions and 19 deletions

View File

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

View File

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

View File

@@ -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<BossLifecycle, PlayableSound>()
for (value in BossLifecycle.values()) {
map[value] = PlayableSound(config.getSubsections("sounds.${value.name.lowercase()}").map {
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<BossDrop> = run {
val list = mutableListOf<BossDrop>()
@@ -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<UUID, LivingEcoBoss>()
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<in Mob>) }
@@ -347,6 +346,13 @@ class EcoBoss(
entityGoals.forEach { controller.addEntityGoal(it.priority, it.goal as EntityGoal<in Mob>) }
}
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 +
"}"
)
}
}

View File

@@ -48,6 +48,6 @@ class LivingEcoBoss(
}
override fun toString(): String {
return "LivingEcoBoss{boss=${boss}, uuid=${entity.uniqueId}}"
return "LivingEcoBoss{boss=$boss, uuid=${entity.uniqueId}}"
}
}

View File

@@ -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<ItemStack>,
var chance: Double,
val player: Player?
): Event() {
) : Event() {
override fun getHandlers(): HandlerList {
return HANDLERS
}

View File

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