diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRandomStroll.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRandomStroll.java new file mode 100644 index 00000000..16f5b0cd --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRandomStroll.java @@ -0,0 +1,18 @@ +package com.willfp.eco.core.entities.ai.goals.entity; + +import com.willfp.eco.core.entities.ai.goals.EntityGoal; + +/** + * Move around randomly. + * + * @param speed The speed at which to move around. + * @param interval The amount of ticks to wait (on average) between strolling around. + * @param canDespawn If the entity can despawn. + */ +public record EntityGoalRandomStroll( + double speed, + int interval, + boolean canDespawn +) implements EntityGoal { + +} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRandomSwimming.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRandomSwimming.java new file mode 100644 index 00000000..400644d4 --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRandomSwimming.java @@ -0,0 +1,16 @@ +package com.willfp.eco.core.entities.ai.goals.entity; + +import com.willfp.eco.core.entities.ai.goals.EntityGoal; + +/** + * Swim around randomly. + * + * @param speed The speed at which to move around. + * @param interval The amount of ticks to wait (on average) between strolling around. + */ +public record EntityGoalRandomSwimming( + double speed, + int interval +) implements EntityGoal { + +} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRangedAttack.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRangedAttack.java new file mode 100644 index 00000000..db20c95f --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRangedAttack.java @@ -0,0 +1,22 @@ +package com.willfp.eco.core.entities.ai.goals.entity; + +import com.willfp.eco.core.entities.ai.goals.EntityGoal; + +/** + * Ranged attack. + *
+ * Only supports mobs that have ranged attacks. + * + * @param mobSpeed The mob speed. + * @param minInterval The minimum interval between attacks (in ticks). + * @param maxInterval The maximum interval between attacks (in ticks). + * @param maxRange The max range at which to attack. + */ +public record EntityGoalRangedAttack( + double mobSpeed, + int minInterval, + int maxInterval, + double maxRange +) implements EntityGoal { + +} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRangedBowAttack.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRangedBowAttack.java new file mode 100644 index 00000000..5f6f1a84 --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRangedBowAttack.java @@ -0,0 +1,20 @@ +package com.willfp.eco.core.entities.ai.goals.entity; + +import com.willfp.eco.core.entities.ai.goals.EntityGoal; + +/** + * Ranged attack. + *
+ * Only supports monsters that have bow attacks. + * + * @param speed The speed. + * @param attackInterval The interval between attacks (in ticks). + * @param range The max range at which to attack. + */ +public record EntityGoalRangedBowAttack( + double speed, + int attackInterval, + double range +) implements EntityGoal { + +} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRangedCrossbowAttack.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRangedCrossbowAttack.java new file mode 100644 index 00000000..143f4d79 --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRangedCrossbowAttack.java @@ -0,0 +1,18 @@ +package com.willfp.eco.core.entities.ai.goals.entity; + +import com.willfp.eco.core.entities.ai.goals.EntityGoal; + +/** + * Ranged attack. + *
+ * Only supports monsters that have crossbow attacks.
+ *
+ * @param speed The speed.
+ * @param range The max range at which to attack.
+ */
+public record EntityGoalRangedCrossbowAttack(
+ double speed,
+ double range
+) implements EntityGoal {
+
+}
diff --git a/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_17_R1/ai/EcoControlledEntity.kt b/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_17_R1/ai/EcoControlledEntity.kt
index ee4d51cb..4b87ea11 100644
--- a/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_17_R1/ai/EcoControlledEntity.kt
+++ b/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_17_R1/ai/EcoControlledEntity.kt
@@ -13,7 +13,10 @@ class EcoControlledEntity(
val craft = handle as? CraftEntity ?: return this
val nms = craft.handle as? net.minecraft.world.entity.PathfinderMob ?: return this
- nms.goalSelector.addGoal(priority, goal.getImplementation().generateNMSGoal(goal, nms))
+ nms.goalSelector.addGoal(
+ priority,
+ goal.getImplementation().generateNMSGoal(goal, nms) ?: return this
+ )
return this
}
@@ -22,7 +25,9 @@ class EcoControlledEntity(
val craft = handle as? CraftEntity ?: return this
val nms = craft.handle as? net.minecraft.world.entity.PathfinderMob ?: return this
- nms.targetSelector.addGoal(priority, goal.getImplementation().generateNMSGoal(goal, nms))
+ nms.targetSelector.addGoal(
+ priority, goal.getImplementation().generateNMSGoal(goal, nms) ?: return this
+ )
return this
}
diff --git a/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_17_R1/ai/EntityGoals.kt b/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_17_R1/ai/EntityGoals.kt
index d1c76482..f0692c7a 100644
--- a/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_17_R1/ai/EntityGoals.kt
+++ b/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_17_R1/ai/EntityGoals.kt
@@ -21,6 +21,11 @@ import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalOcelotAttack
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalOpenDoors
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalPanic
import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalRandomLookAround
+import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalRandomStroll
+import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalRandomSwimming
+import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalRangedAttack
+import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalRangedBowAttack
+import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalRangedCrossbowAttack
import net.minecraft.world.entity.PathfinderMob
import net.minecraft.world.entity.ai.goal.AvoidEntityGoal
import net.minecraft.world.entity.ai.goal.BreakDoorGoal
@@ -43,6 +48,12 @@ import net.minecraft.world.entity.ai.goal.OcelotAttackGoal
import net.minecraft.world.entity.ai.goal.OpenDoorGoal
import net.minecraft.world.entity.ai.goal.PanicGoal
import net.minecraft.world.entity.ai.goal.RandomLookAroundGoal
+import net.minecraft.world.entity.ai.goal.RandomStrollGoal
+import net.minecraft.world.entity.ai.goal.RandomSwimmingGoal
+import net.minecraft.world.entity.ai.goal.RangedAttackGoal
+import net.minecraft.world.entity.ai.goal.RangedBowAttackGoal
+import net.minecraft.world.entity.ai.goal.RangedCrossbowAttackGoal
+import net.minecraft.world.entity.monster.RangedAttackMob
import net.minecraft.world.entity.player.Player
fun