diff --git a/build.gradle.kts b/build.gradle.kts index 03befc94..099df877 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,4 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import java.net.URI @Suppress("DSL_SCOPE_VIOLATION") plugins { @@ -54,7 +53,6 @@ dependencies { compileOnly(libs.kotlinx.coroutines) compileOnly(libs.minecraft.mccoroutine) compileOnly(libs.idofront.di) - compileOnly(libs.minecraft.plugin.modelengine) // Shaded api(project(":mobzy-pathfinding")) diff --git a/mobzy-modelengine/src/main/kotlin/com/mineinabyss/mobzy/modelengine/intializers/SetModelEngineModelSystem.kt b/mobzy-modelengine/src/main/kotlin/com/mineinabyss/mobzy/modelengine/intializers/SetModelEngineModelSystem.kt index ff9e57af..a6515968 100644 --- a/mobzy-modelengine/src/main/kotlin/com/mineinabyss/mobzy/modelengine/intializers/SetModelEngineModelSystem.kt +++ b/mobzy-modelengine/src/main/kotlin/com/mineinabyss/mobzy/modelengine/intializers/SetModelEngineModelSystem.kt @@ -9,6 +9,7 @@ import com.mineinabyss.mobzy.mobzy import com.ticxo.modelengine.api.ModelEngineAPI import kotlinx.coroutines.yield import org.bukkit.Color +import com.ticxo.modelengine.api.utils.data.io.SavedData as ModelEngineSaveData class SetModelEngineModelSystem : GearyListener() { val Pointers.bukkit by get().whenSetOnTarget() @@ -20,6 +21,10 @@ class SetModelEngineModelSystem : GearyListener() { mobzy.plugin.launch { yield() // Wait till next tick so some entity stuff gets initialized if (bukkit.isDead) return@launch + + // MEG persists models by default, this ensures any geary entities are handling models on their own + if (bukkit.persistentDataContainer.has(ModelEngineSaveData.DATA_KEY)) + bukkit.persistentDataContainer.remove(ModelEngineSaveData.DATA_KEY) val modelEntity = ModelEngineAPI.getOrCreateModeledEntity(bukkit) val blueprint = ModelEngineAPI.getBlueprint(model.modelId) ?: error("No blueprint registered for ${model.modelId}") @@ -32,7 +37,8 @@ class SetModelEngineModelSystem : GearyListener() { } modelEntity.apply { - addModel(createdModel, true) + setSaved(false) + addModel(createdModel, true).ifPresent { it.destroy() } this.base.maxStepHeight = model.stepHeight isBaseEntityVisible = !model.invisible base.bodyRotationController.rotationDuration = 20 diff --git a/settings.gradle.kts b/settings.gradle.kts index da1913cf..f50dd44b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -26,6 +26,7 @@ dependencyResolutionManagement { versionCatalogs { create("libs") { from("com.mineinabyss:catalog:$idofrontVersion") + version("modelengine", "R4.0.4") } create("myLibs").from(files("gradle/myLibs.versions.toml")) } diff --git a/src/main/kotlin/com/mineinabyss/mobzy/MobzyPlugin.kt b/src/main/kotlin/com/mineinabyss/mobzy/MobzyPlugin.kt index 935c8220..b5cd64b6 100644 --- a/src/main/kotlin/com/mineinabyss/mobzy/MobzyPlugin.kt +++ b/src/main/kotlin/com/mineinabyss/mobzy/MobzyPlugin.kt @@ -1,5 +1,6 @@ package com.mineinabyss.mobzy +import com.github.shynixn.mccoroutine.bukkit.minecraftDispatcher import com.mineinabyss.geary.autoscan.autoscan import com.mineinabyss.geary.modules.geary import com.mineinabyss.idofront.config.config @@ -24,6 +25,7 @@ import com.mineinabyss.mobzy.modelengine.ModelEngineSupport import com.mineinabyss.mobzy.pathfinding.components.PathfinderComponent import com.mineinabyss.mobzy.spawning.MobzySpawnFeature import com.mineinabyss.mobzy.spawning.WorldGuardSpawnFlags +import kotlinx.coroutines.cancel import org.bukkit.Bukkit import org.bukkit.plugin.java.JavaPlugin @@ -78,6 +80,7 @@ class MobzyPlugin : JavaPlugin() { override fun onDisable() { super.onDisable() + minecraftDispatcher.cancel() } fun createMobzyContext() {