From 4dbc8afdf47769024c60762cf7e186d7694f0888 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Sat, 19 Mar 2022 16:42:59 +0000 Subject: [PATCH 1/5] Updated libreforge --- build.gradle | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 33b8c68..77fd618 100644 --- a/build.gradle +++ b/build.gradle @@ -62,7 +62,7 @@ allprojects { dependencies { compileOnly 'com.willfp:eco:6.24.0' - implementation 'com.willfp:libreforge:3.26.0' + implementation 'com.willfp:libreforge:3.27.0' compileOnly 'org.jetbrains:annotations:23.0.0' diff --git a/gradle.properties b/gradle.properties index 1aa569c..3fc2d31 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version = 8.12.0 +version = 8.13.0 plugin-name = EcoBosses \ No newline at end of file From 322a6bb41bd99f7139d383a7c6660c0e3c26292c Mon Sep 17 00:00:00 2001 From: Auxilor Date: Mon, 21 Mar 2022 12:24:06 +0000 Subject: [PATCH 2/5] Updated libreforge --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 77fd618..c3abdd9 100644 --- a/build.gradle +++ b/build.gradle @@ -62,7 +62,7 @@ allprojects { dependencies { compileOnly 'com.willfp:eco:6.24.0' - implementation 'com.willfp:libreforge:3.27.0' + implementation 'com.willfp:libreforge:3.27.1' compileOnly 'org.jetbrains:annotations:23.0.0' From 9f05a6504a15852e7e7b122475b488fddbd6828e Mon Sep 17 00:00:00 2001 From: Auxilor Date: Mon, 21 Mar 2022 12:39:09 +0000 Subject: [PATCH 3/5] Added support for custom entity AI --- build.gradle | 2 +- .../willfp/ecobosses/bosses/ConfiguredGoal.kt | 8 +++++ .../com/willfp/ecobosses/bosses/EcoBoss.kt | 35 ++++++++++++++++++- .../src/main/resources/ecobosses.yml | 4 +++ 4 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 eco-core/core-plugin/src/main/kotlin/com/willfp/ecobosses/bosses/ConfiguredGoal.kt diff --git a/build.gradle b/build.gradle index c3abdd9..d612d4d 100644 --- a/build.gradle +++ b/build.gradle @@ -61,7 +61,7 @@ allprojects { } dependencies { - compileOnly 'com.willfp:eco:6.24.0' + compileOnly 'com.willfp:eco:6.29.0' implementation 'com.willfp:libreforge:3.27.1' compileOnly 'org.jetbrains:annotations:23.0.0' diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobosses/bosses/ConfiguredGoal.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobosses/bosses/ConfiguredGoal.kt new file mode 100644 index 0000000..e98713b --- /dev/null +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobosses/bosses/ConfiguredGoal.kt @@ -0,0 +1,8 @@ +package com.willfp.ecobosses.bosses + +import com.willfp.eco.core.entities.ai.Goal + +data class ConfiguredGoal>( + val priority: Int, + val goal: T +) 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 d22e70b..1936ce6 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 @@ -5,12 +5,18 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.entities.CustomEntity import com.willfp.eco.core.entities.Entities import com.willfp.eco.core.entities.TestableEntity +import com.willfp.eco.core.entities.ai.EntityController +import com.willfp.eco.core.entities.ai.EntityGoal +import com.willfp.eco.core.entities.ai.EntityGoals +import com.willfp.eco.core.entities.ai.TargetGoal +import com.willfp.eco.core.entities.ai.TargetGoals import com.willfp.eco.core.items.CustomItem import com.willfp.eco.core.items.Items import com.willfp.eco.core.items.builder.ItemStackBuilder import com.willfp.eco.core.recipe.Recipes import com.willfp.eco.core.recipe.parts.EmptyTestableItem import com.willfp.eco.core.recipe.recipes.CraftingRecipe +import com.willfp.eco.util.NamespacedKeyUtils import com.willfp.eco.util.toComponent import com.willfp.ecobosses.events.BossKillEvent import com.willfp.ecobosses.lifecycle.BossLifecycle @@ -37,6 +43,7 @@ import org.bukkit.Bukkit import org.bukkit.Location import org.bukkit.Material import org.bukkit.entity.LivingEntity +import org.bukkit.entity.Mob import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack import org.bukkit.persistence.PersistentDataType @@ -172,6 +179,22 @@ class EcoBoss( locations } + val hasCustomAI = config.getBool("customai.enabled") + + val targetGoals = config.getSubsections("customai.target-goals").mapNotNull { + val key = NamespacedKeyUtils.fromStringOrNull(it.getString("key")) ?: return@mapNotNull null + val deserializer = TargetGoals.getByKey(key) ?: return@mapNotNull null + val goal = deserializer.deserialize(config.getSubsection("args")) ?: return@mapNotNull null + ConfiguredGoal(config.getInt("priority"), goal) + } + + val entityGoals = config.getSubsections("customai.ai-goals").mapNotNull { + val key = NamespacedKeyUtils.fromStringOrNull(it.getString("key")) ?: return@mapNotNull null + val deserializer = EntityGoals.getByKey(key) ?: return@mapNotNull null + val goal = deserializer.deserialize(config.getSubsection("args")) ?: return@mapNotNull null + ConfiguredGoal(config.getInt("priority"), goal) + } + val spawnConditions = config.getSubsections("spawn.conditions").mapNotNull { Conditions.compile(it, "$id Spawn Conditions") } @@ -305,7 +328,7 @@ class EcoBoss( } fun spawn(location: Location): LivingEcoBoss { - val mob = mob.spawn(location) as LivingEntity + val mob = mob.spawn(location) as Mob mob.isPersistent = true mob.isCustomNameVisible = true mob.removeWhenFarAway = false @@ -315,6 +338,16 @@ class EcoBoss( this.id ) + if (hasCustomAI) { + val controller = EntityController.getFor(mob) + .clearAllGoals() + + @Suppress("UNCHECKED_CAST") // What could go wrong? + targetGoals.forEach { controller.addTargetGoal(it.priority, it.goal as TargetGoal) } + @Suppress("UNCHECKED_CAST") + entityGoals.forEach { controller.addEntityGoal(it.priority, it.goal as EntityGoal) } + } + val boss = LivingEcoBoss( plugin, mob.uniqueId, diff --git a/eco-core/core-plugin/src/main/resources/ecobosses.yml b/eco-core/core-plugin/src/main/resources/ecobosses.yml index 41dd6b0..b9bcfc9 100644 --- a/eco-core/core-plugin/src/main/resources/ecobosses.yml +++ b/eco-core/core-plugin/src/main/resources/ecobosses.yml @@ -26,6 +26,10 @@ bosses: # 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 + customai: # Custom mob AI using the entity goal system. + enabled: false # If custom AI should be enabled, this will override the vanilla mob behaviour. + target-goals: [ ] # How the boss decides who to attack, if the target mode isn't being used. + ai-goals: [ ] # How the boss should behave. effects: # Effects are done from the player's perspective: to treat the player as the victim, use the self_as_victim option in args - id: run_chain args: From d8e5fb9cd0637eaad9a90c517c699f2fed28b1ca Mon Sep 17 00:00:00 2001 From: Auxilor Date: Mon, 21 Mar 2022 12:40:12 +0000 Subject: [PATCH 4/5] Updated to 8.14.0 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 3fc2d31..6edff17 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version = 8.13.0 +version = 8.14.0 plugin-name = EcoBosses \ No newline at end of file From 276ba4616ae9b702c7b6c272d7268d64cefccdf0 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Fri, 25 Mar 2022 09:31:29 +0000 Subject: [PATCH 5/5] Updated libreforge --- build.gradle | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index d612d4d..0f549bc 100644 --- a/build.gradle +++ b/build.gradle @@ -62,7 +62,7 @@ allprojects { dependencies { compileOnly 'com.willfp:eco:6.29.0' - implementation 'com.willfp:libreforge:3.27.1' + implementation 'com.willfp:libreforge:3.28.0' compileOnly 'org.jetbrains:annotations:23.0.0' diff --git a/gradle.properties b/gradle.properties index 6edff17..9174caf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version = 8.14.0 +version = 8.15.0 plugin-name = EcoBosses \ No newline at end of file