diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/CustomGoal.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/CustomGoal.java similarity index 83% rename from eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/CustomGoal.java rename to eco-api/src/main/java/com/willfp/eco/core/entities/ai/CustomGoal.java index c6b7e295..b995fcbe 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/CustomGoal.java +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/CustomGoal.java @@ -1,4 +1,4 @@ -package com.willfp.eco.core.entities.ai.goals; +package com.willfp.eco.core.entities.ai; import org.bukkit.entity.Mob; import org.jetbrains.annotations.NotNull; @@ -7,8 +7,10 @@ import org.jetbrains.annotations.NotNull; * Base interface for all custom goals. *

* Can be used both for entity goals and target goals. + * + * @param The type of mob that this goal can be applied to. */ -public interface CustomGoal extends EntityGoal, TargetGoal { +public interface CustomGoal extends EntityGoal, TargetGoal { /** * Initialize the goal with a mob. *

@@ -16,7 +18,7 @@ public interface CustomGoal extends EntityGoal, TargetGoal { * * @param mob The mob. */ - void initialize(@NotNull Mob mob); + void initialize(@NotNull T mob); /** * Get if the goal can be used. diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/EntityController.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/EntityController.java index 544388f2..28c1db2b 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/EntityController.java +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/EntityController.java @@ -1,8 +1,6 @@ package com.willfp.eco.core.entities.ai; import com.willfp.eco.core.Eco; -import com.willfp.eco.core.entities.ai.goals.EntityGoal; -import com.willfp.eco.core.entities.ai.goals.TargetGoal; import org.bukkit.entity.Mob; import org.jetbrains.annotations.NotNull; @@ -22,7 +20,7 @@ public interface EntityController { * @return The entity controller. */ EntityController addTargetGoal(int priority, - @NotNull TargetGoal goal); + @NotNull TargetGoal goal); /** * Remove all target goals from the entity. @@ -41,7 +39,7 @@ public interface EntityController { * @param goal The goal. * @return The entity controller. */ - EntityController removeTargetGoal(@NotNull TargetGoal goal); + EntityController removeTargetGoal(@NotNull TargetGoal goal); /** * Add an entity goal to the entity. @@ -53,7 +51,7 @@ public interface EntityController { * @return The entity controller. */ EntityController addEntityGoal(int priority, - @NotNull EntityGoal goal); + @NotNull EntityGoal goal); /** * Remove an entity goal from the entity. @@ -63,7 +61,7 @@ public interface EntityController { * @param goal The goal. * @return The entity controller. */ - EntityController removeEntityGoal(@NotNull EntityGoal goal); + EntityController removeEntityGoal(@NotNull EntityGoal goal); /** * Remove all entity goals from the entity. diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/EntityGoal.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/EntityGoal.java new file mode 100644 index 00000000..9d3b1cc9 --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/EntityGoal.java @@ -0,0 +1,12 @@ +package com.willfp.eco.core.entities.ai; + +import org.bukkit.entity.Mob; + +/** + * A goal for entity AI. + * + * @param The type of mob that the goal can be applied to. + */ +public interface EntityGoal { + +} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/TargetGoal.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/TargetGoal.java new file mode 100644 index 00000000..bd0bff4c --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/TargetGoal.java @@ -0,0 +1,12 @@ +package com.willfp.eco.core.entities.ai; + +import org.bukkit.entity.Mob; + +/** + * A goal for entity target AI. + * + * @param The type of mob that the goal can be applied to. + */ +public interface TargetGoal { + +} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalAvoidEntity.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalAvoidEntity.java similarity index 80% rename from eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalAvoidEntity.java rename to eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalAvoidEntity.java index 098d1508..b852699d 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalAvoidEntity.java +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalAvoidEntity.java @@ -1,7 +1,8 @@ -package com.willfp.eco.core.entities.ai.goals.entity; +package com.willfp.eco.core.entities.ai.entity; -import com.willfp.eco.core.entities.ai.goals.EntityGoal; +import com.willfp.eco.core.entities.ai.EntityGoal; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Mob; import org.jetbrains.annotations.NotNull; import java.util.function.Predicate; @@ -21,6 +22,6 @@ public record EntityGoalAvoidEntity( double slowSpeed, double fastSpeed, @NotNull Predicate filter -) implements EntityGoal { +) implements EntityGoal { } diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalBreakDoor.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalBreakDoor.java similarity index 51% rename from eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalBreakDoor.java rename to eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalBreakDoor.java index cc4cdb82..5337b13d 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalBreakDoor.java +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalBreakDoor.java @@ -1,6 +1,7 @@ -package com.willfp.eco.core.entities.ai.goals.entity; +package com.willfp.eco.core.entities.ai.entity; -import com.willfp.eco.core.entities.ai.goals.EntityGoal; +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; /** * Break doors. @@ -9,6 +10,6 @@ import com.willfp.eco.core.entities.ai.goals.EntityGoal; */ public record EntityGoalBreakDoor( int maxProgress -) implements EntityGoal { +) implements EntityGoal { } diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalBreatheAir.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalBreatheAir.java new file mode 100644 index 00000000..1eefee6d --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalBreatheAir.java @@ -0,0 +1,12 @@ +package com.willfp.eco.core.entities.ai.entity; + +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; + +/** + * Breathe air. + */ +public record EntityGoalBreatheAir( +) implements EntityGoal { + +} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalEatBlock.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalEatBlock.java new file mode 100644 index 00000000..98905090 --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalEatBlock.java @@ -0,0 +1,12 @@ +package com.willfp.eco.core.entities.ai.entity; + +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; + +/** + * Eat block. + */ +public record EntityGoalEatBlock( +) implements EntityGoal { + +} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalFleeSun.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalFleeSun.java new file mode 100644 index 00000000..0d4aea17 --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalFleeSun.java @@ -0,0 +1,15 @@ +package com.willfp.eco.core.entities.ai.entity; + +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; + +/** + * Flee sun. + * + * @param speed The speed at which to flee. + */ +public record EntityGoalFleeSun( + double speed +) implements EntityGoal { + +} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalFloat.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalFloat.java new file mode 100644 index 00000000..4e467f2c --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalFloat.java @@ -0,0 +1,12 @@ +package com.willfp.eco.core.entities.ai.entity; + +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; + +/** + * Float in water. + */ +public record EntityGoalFloat( +) implements EntityGoal { + +} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalFollowBoats.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalFollowBoats.java new file mode 100644 index 00000000..a83ed428 --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalFollowBoats.java @@ -0,0 +1,12 @@ +package com.willfp.eco.core.entities.ai.entity; + +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; + +/** + * Follow boats. + */ +public record EntityGoalFollowBoats( +) implements EntityGoal { + +} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalFollowMobs.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalFollowMobs.java similarity index 65% rename from eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalFollowMobs.java rename to eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalFollowMobs.java index 43565c14..d1fc0e3c 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalFollowMobs.java +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalFollowMobs.java @@ -1,6 +1,7 @@ -package com.willfp.eco.core.entities.ai.goals.entity; +package com.willfp.eco.core.entities.ai.entity; -import com.willfp.eco.core.entities.ai.goals.EntityGoal; +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; /** * Follow other mobs. @@ -13,6 +14,6 @@ public record EntityGoalFollowMobs( double speed, double minDistance, double maxDistance -) implements EntityGoal { +) implements EntityGoal { } diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalInteract.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalInteract.java similarity index 73% rename from eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalInteract.java rename to eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalInteract.java index 2da8cd1f..eceffba6 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalInteract.java +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalInteract.java @@ -1,7 +1,8 @@ -package com.willfp.eco.core.entities.ai.goals.entity; +package com.willfp.eco.core.entities.ai.entity; -import com.willfp.eco.core.entities.ai.goals.EntityGoal; +import com.willfp.eco.core.entities.ai.EntityGoal; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Mob; import org.jetbrains.annotations.NotNull; /** @@ -15,6 +16,6 @@ public record EntityGoalInteract( @NotNull Class targetClass, double range, double chance -) implements EntityGoal { +) implements EntityGoal { } diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalLeapAtTarget.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalLeapAtTarget.java new file mode 100644 index 00000000..0bafbb12 --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalLeapAtTarget.java @@ -0,0 +1,15 @@ +package com.willfp.eco.core.entities.ai.entity; + +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; + +/** + * Leap at target. + * + * @param velocity The leap velocity. + */ +public record EntityGoalLeapAtTarget( + double velocity +) implements EntityGoal { + +} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalLookAtPlayer.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalLookAtPlayer.java similarity index 60% rename from eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalLookAtPlayer.java rename to eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalLookAtPlayer.java index 4c5edc7e..539a3583 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalLookAtPlayer.java +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalLookAtPlayer.java @@ -1,6 +1,7 @@ -package com.willfp.eco.core.entities.ai.goals.entity; +package com.willfp.eco.core.entities.ai.entity; -import com.willfp.eco.core.entities.ai.goals.EntityGoal; +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; /** * Look at the player. @@ -11,6 +12,6 @@ import com.willfp.eco.core.entities.ai.goals.EntityGoal; public record EntityGoalLookAtPlayer( double range, double chance -) implements EntityGoal { +) implements EntityGoal { } diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalMeleeAttack.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalMeleeAttack.java similarity index 64% rename from eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalMeleeAttack.java rename to eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalMeleeAttack.java index eaf21b45..de07030a 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalMeleeAttack.java +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalMeleeAttack.java @@ -1,6 +1,7 @@ -package com.willfp.eco.core.entities.ai.goals.entity; +package com.willfp.eco.core.entities.ai.entity; -import com.willfp.eco.core.entities.ai.goals.EntityGoal; +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; /** * Melee attack target. @@ -11,6 +12,6 @@ import com.willfp.eco.core.entities.ai.goals.EntityGoal; public record EntityGoalMeleeAttack( double speed, boolean pauseWhenMobIdle -) implements EntityGoal { +) implements EntityGoal { } diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalMoveBackToVillage.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalMoveBackToVillage.java similarity index 60% rename from eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalMoveBackToVillage.java rename to eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalMoveBackToVillage.java index 214a02ee..0728c5cd 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalMoveBackToVillage.java +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalMoveBackToVillage.java @@ -1,6 +1,7 @@ -package com.willfp.eco.core.entities.ai.goals.entity; +package com.willfp.eco.core.entities.ai.entity; -import com.willfp.eco.core.entities.ai.goals.EntityGoal; +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; /** * Move back to village. @@ -11,6 +12,6 @@ import com.willfp.eco.core.entities.ai.goals.EntityGoal; public record EntityGoalMoveBackToVillage( double speed, boolean canDespawn -) implements EntityGoal { +) implements EntityGoal { } diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalMoveThroughVillage.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalMoveThroughVillage.java similarity index 78% rename from eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalMoveThroughVillage.java rename to eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalMoveThroughVillage.java index b257588a..b89fe8e7 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalMoveThroughVillage.java +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalMoveThroughVillage.java @@ -1,6 +1,7 @@ -package com.willfp.eco.core.entities.ai.goals.entity; +package com.willfp.eco.core.entities.ai.entity; -import com.willfp.eco.core.entities.ai.goals.EntityGoal; +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; import java.util.function.BooleanSupplier; @@ -17,6 +18,6 @@ public record EntityGoalMoveThroughVillage( boolean onlyAtNight, int distance, BooleanSupplier canPassThroughDoorsGetter -) implements EntityGoal { +) implements EntityGoal { } diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalMoveTowardsRestriction.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalMoveTowardsRestriction.java similarity index 53% rename from eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalMoveTowardsRestriction.java rename to eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalMoveTowardsRestriction.java index d0b2d26c..db5e4a90 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalMoveTowardsRestriction.java +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalMoveTowardsRestriction.java @@ -1,6 +1,7 @@ -package com.willfp.eco.core.entities.ai.goals.entity; +package com.willfp.eco.core.entities.ai.entity; -import com.willfp.eco.core.entities.ai.goals.EntityGoal; +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; /** * Move towards restriction. @@ -9,6 +10,6 @@ import com.willfp.eco.core.entities.ai.goals.EntityGoal; */ public record EntityGoalMoveTowardsRestriction( double speed -) implements EntityGoal { +) implements EntityGoal { } diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalMoveTowardsTarget.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalMoveTowardsTarget.java similarity index 65% rename from eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalMoveTowardsTarget.java rename to eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalMoveTowardsTarget.java index 59ff87ad..0760814e 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalMoveTowardsTarget.java +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalMoveTowardsTarget.java @@ -1,6 +1,7 @@ -package com.willfp.eco.core.entities.ai.goals.entity; +package com.willfp.eco.core.entities.ai.entity; -import com.willfp.eco.core.entities.ai.goals.EntityGoal; +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; /** * Move towards target. @@ -11,6 +12,6 @@ import com.willfp.eco.core.entities.ai.goals.EntityGoal; public record EntityGoalMoveTowardsTarget( double speed, double maxDistance -) implements EntityGoal { +) implements EntityGoal { } diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalOcelotAttack.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalOcelotAttack.java new file mode 100644 index 00000000..5051c5ea --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalOcelotAttack.java @@ -0,0 +1,12 @@ +package com.willfp.eco.core.entities.ai.entity; + +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; + +/** + * Attack like an ocelot. + */ +public record EntityGoalOcelotAttack( +) implements EntityGoal { + +} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalOpenDoors.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalOpenDoors.java new file mode 100644 index 00000000..576cdde3 --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalOpenDoors.java @@ -0,0 +1,15 @@ +package com.willfp.eco.core.entities.ai.entity; + +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; + +/** + * Open doors. + * + * @param delayedClose If closing the door should be delayed. + */ +public record EntityGoalOpenDoors( + boolean delayedClose +) implements EntityGoal { + +} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalPanic.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalPanic.java new file mode 100644 index 00000000..b23913fb --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalPanic.java @@ -0,0 +1,15 @@ +package com.willfp.eco.core.entities.ai.entity; + +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; + +/** + * Panic. + * + * @param speed The speed at which to panic. + */ +public record EntityGoalPanic( + double speed +) implements EntityGoal { + +} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalRandomLookAround.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalRandomLookAround.java new file mode 100644 index 00000000..fb89c810 --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalRandomLookAround.java @@ -0,0 +1,12 @@ +package com.willfp.eco.core.entities.ai.entity; + +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; + +/** + * Look around randomly. + */ +public record EntityGoalRandomLookAround( +) implements EntityGoal { + +} 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/entity/EntityGoalRandomStroll.java similarity index 68% rename from eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRandomStroll.java rename to eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalRandomStroll.java index 16f5b0cd..198df49d 100644 --- 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/entity/EntityGoalRandomStroll.java @@ -1,6 +1,7 @@ -package com.willfp.eco.core.entities.ai.goals.entity; +package com.willfp.eco.core.entities.ai.entity; -import com.willfp.eco.core.entities.ai.goals.EntityGoal; +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; /** * Move around randomly. @@ -13,6 +14,6 @@ public record EntityGoalRandomStroll( double speed, int interval, boolean canDespawn -) implements EntityGoal { +) 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/entity/EntityGoalRandomSwimming.java similarity index 62% rename from eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRandomSwimming.java rename to eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalRandomSwimming.java index 400644d4..9c20cadb 100644 --- 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/entity/EntityGoalRandomSwimming.java @@ -1,6 +1,7 @@ -package com.willfp.eco.core.entities.ai.goals.entity; +package com.willfp.eco.core.entities.ai.entity; -import com.willfp.eco.core.entities.ai.goals.EntityGoal; +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; /** * Swim around randomly. @@ -11,6 +12,6 @@ import com.willfp.eco.core.entities.ai.goals.EntityGoal; public record EntityGoalRandomSwimming( double speed, int interval -) implements EntityGoal { +) 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/entity/EntityGoalRangedAttack.java similarity index 74% rename from eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRangedAttack.java rename to eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalRangedAttack.java index db20c95f..8eed4cb2 100644 --- 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/entity/EntityGoalRangedAttack.java @@ -1,6 +1,7 @@ -package com.willfp.eco.core.entities.ai.goals.entity; +package com.willfp.eco.core.entities.ai.entity; -import com.willfp.eco.core.entities.ai.goals.EntityGoal; +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; /** * Ranged attack. @@ -17,6 +18,6 @@ public record EntityGoalRangedAttack( int minInterval, int maxInterval, double maxRange -) implements EntityGoal { +) 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/entity/EntityGoalRangedBowAttack.java similarity index 68% rename from eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRangedBowAttack.java rename to eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalRangedBowAttack.java index 5f6f1a84..91f8c42f 100644 --- 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/entity/EntityGoalRangedBowAttack.java @@ -1,6 +1,7 @@ -package com.willfp.eco.core.entities.ai.goals.entity; +package com.willfp.eco.core.entities.ai.entity; -import com.willfp.eco.core.entities.ai.goals.EntityGoal; +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Monster; /** * Ranged attack. @@ -15,6 +16,6 @@ public record EntityGoalRangedBowAttack( double speed, int attackInterval, double range -) implements EntityGoal { +) 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/entity/EntityGoalRangedCrossbowAttack.java similarity index 62% rename from eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRangedCrossbowAttack.java rename to eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalRangedCrossbowAttack.java index 143f4d79..541c261d 100644 --- 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/entity/EntityGoalRangedCrossbowAttack.java @@ -1,6 +1,7 @@ -package com.willfp.eco.core.entities.ai.goals.entity; +package com.willfp.eco.core.entities.ai.entity; -import com.willfp.eco.core.entities.ai.goals.EntityGoal; +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Monster; /** * Ranged attack. @@ -13,6 +14,6 @@ import com.willfp.eco.core.entities.ai.goals.EntityGoal; public record EntityGoalRangedCrossbowAttack( double speed, double range -) implements EntityGoal { +) implements EntityGoal { } diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalRestrictSun.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalRestrictSun.java new file mode 100644 index 00000000..f02d8c22 --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalRestrictSun.java @@ -0,0 +1,12 @@ +package com.willfp.eco.core.entities.ai.entity; + +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; + +/** + * Restrict sun. + */ +public record EntityGoalRestrictSun( +) implements EntityGoal { + +} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalStrollThroughVillage.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalStrollThroughVillage.java new file mode 100644 index 00000000..b0ba5747 --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalStrollThroughVillage.java @@ -0,0 +1,15 @@ +package com.willfp.eco.core.entities.ai.entity; + +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; + +/** + * Stroll through village. + * + * @param searchRange The search range. + */ +public record EntityGoalStrollThroughVillage( + int searchRange +) implements EntityGoal { + +} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalTempt.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalTempt.java similarity index 73% rename from eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalTempt.java rename to eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalTempt.java index 5201eba2..2d61f808 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalTempt.java +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalTempt.java @@ -1,6 +1,7 @@ -package com.willfp.eco.core.entities.ai.goals.entity; +package com.willfp.eco.core.entities.ai.entity; -import com.willfp.eco.core.entities.ai.goals.EntityGoal; +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; import org.bukkit.inventory.ItemStack; import java.util.Collection; @@ -16,6 +17,6 @@ public record EntityGoalTempt( double speed, Collection items, boolean canBeScared -) implements EntityGoal { +) implements EntityGoal { } diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalTryFindWater.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalTryFindWater.java new file mode 100644 index 00000000..2d420462 --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalTryFindWater.java @@ -0,0 +1,12 @@ +package com.willfp.eco.core.entities.ai.entity; + +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; + +/** + * Try to find water. + */ +public record EntityGoalTryFindWater( +) implements EntityGoal { + +} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalUseItem.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalUseItem.java similarity index 75% rename from eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalUseItem.java rename to eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalUseItem.java index 8a3b5306..36e61fd0 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalUseItem.java +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalUseItem.java @@ -1,8 +1,9 @@ -package com.willfp.eco.core.entities.ai.goals.entity; +package com.willfp.eco.core.entities.ai.entity; -import com.willfp.eco.core.entities.ai.goals.EntityGoal; +import com.willfp.eco.core.entities.ai.EntityGoal; import org.bukkit.Sound; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Mob; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; @@ -19,6 +20,6 @@ public record EntityGoalUseItem( @NotNull ItemStack item, @NotNull Sound sound, @NotNull Predicate condition -) implements EntityGoal { +) implements EntityGoal { } diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalWaterAvoidingRandomFlying.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalWaterAvoidingRandomFlying.java new file mode 100644 index 00000000..2666a6b0 --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalWaterAvoidingRandomFlying.java @@ -0,0 +1,15 @@ +package com.willfp.eco.core.entities.ai.entity; + +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; + +/** + * Fly randomly while avoiding water. + * + * @param speed The speed. + */ +public record EntityGoalWaterAvoidingRandomFlying( + double speed +) implements EntityGoal { + +} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalWaterAvoidingRandomStroll.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalWaterAvoidingRandomStroll.java similarity index 60% rename from eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalWaterAvoidingRandomStroll.java rename to eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalWaterAvoidingRandomStroll.java index 372a47dc..3ed67339 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalWaterAvoidingRandomStroll.java +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/entity/EntityGoalWaterAvoidingRandomStroll.java @@ -1,6 +1,7 @@ -package com.willfp.eco.core.entities.ai.goals.entity; +package com.willfp.eco.core.entities.ai.entity; -import com.willfp.eco.core.entities.ai.goals.EntityGoal; +import com.willfp.eco.core.entities.ai.EntityGoal; +import org.bukkit.entity.Mob; /** * Stroll randomly while avoiding water. @@ -11,6 +12,6 @@ import com.willfp.eco.core.entities.ai.goals.EntityGoal; public record EntityGoalWaterAvoidingRandomStroll( double speed, double chance -) implements EntityGoal { +) implements EntityGoal { } diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/EntityGoal.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/EntityGoal.java deleted file mode 100644 index 95d538f0..00000000 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/EntityGoal.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.willfp.eco.core.entities.ai.goals; - -/** - * A goal for entity AI. - */ -public interface EntityGoal { - -} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/TargetGoal.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/TargetGoal.java deleted file mode 100644 index 88f91bf0..00000000 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/TargetGoal.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.willfp.eco.core.entities.ai.goals; - -/** - * A goal for entity AI. - */ -public interface TargetGoal { - -} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalBreatheAir.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalBreatheAir.java deleted file mode 100644 index 9c4898ba..00000000 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalBreatheAir.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.willfp.eco.core.entities.ai.goals.entity; - -import com.willfp.eco.core.entities.ai.goals.EntityGoal; - -/** - * Breathe air. - */ -public record EntityGoalBreatheAir( -) implements EntityGoal { - -} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalEatBlock.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalEatBlock.java deleted file mode 100644 index 06969396..00000000 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalEatBlock.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.willfp.eco.core.entities.ai.goals.entity; - -import com.willfp.eco.core.entities.ai.goals.EntityGoal; - -/** - * Eat block. - */ -public record EntityGoalEatBlock( -) implements EntityGoal { - -} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalFleeSun.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalFleeSun.java deleted file mode 100644 index 22768836..00000000 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalFleeSun.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.willfp.eco.core.entities.ai.goals.entity; - -import com.willfp.eco.core.entities.ai.goals.EntityGoal; - -/** - * Flee sun. - * - * @param speed The speed at which to flee. - */ -public record EntityGoalFleeSun( - double speed -) implements EntityGoal { - -} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalFloat.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalFloat.java deleted file mode 100644 index 66a1ad47..00000000 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalFloat.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.willfp.eco.core.entities.ai.goals.entity; - -import com.willfp.eco.core.entities.ai.goals.EntityGoal; - -/** - * Float in water. - */ -public record EntityGoalFloat( -) implements EntityGoal { - -} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalFollowBoats.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalFollowBoats.java deleted file mode 100644 index c441538e..00000000 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalFollowBoats.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.willfp.eco.core.entities.ai.goals.entity; - -import com.willfp.eco.core.entities.ai.goals.EntityGoal; - -/** - * Follow boats. - */ -public record EntityGoalFollowBoats( -) implements EntityGoal { - -} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalLeapAtTarget.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalLeapAtTarget.java deleted file mode 100644 index 04d05718..00000000 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalLeapAtTarget.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.willfp.eco.core.entities.ai.goals.entity; - -import com.willfp.eco.core.entities.ai.goals.EntityGoal; - -/** - * Leap at target. - * - * @param velocity The leap velocity. - */ -public record EntityGoalLeapAtTarget( - double velocity -) implements EntityGoal { - -} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalOcelotAttack.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalOcelotAttack.java deleted file mode 100644 index 17682627..00000000 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalOcelotAttack.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.willfp.eco.core.entities.ai.goals.entity; - -import com.willfp.eco.core.entities.ai.goals.EntityGoal; - -/** - * Attack like an ocelot. - */ -public record EntityGoalOcelotAttack( -) implements EntityGoal { - -} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalOpenDoors.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalOpenDoors.java deleted file mode 100644 index b2b04be3..00000000 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalOpenDoors.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.willfp.eco.core.entities.ai.goals.entity; - -import com.willfp.eco.core.entities.ai.goals.EntityGoal; - -/** - * Open doors. - * - * @param delayedClose If closing the door should be delayed. - */ -public record EntityGoalOpenDoors( - boolean delayedClose -) implements EntityGoal { - -} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalPanic.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalPanic.java deleted file mode 100644 index cad56593..00000000 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalPanic.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.willfp.eco.core.entities.ai.goals.entity; - -import com.willfp.eco.core.entities.ai.goals.EntityGoal; - -/** - * Panic. - * - * @param speed The speed at which to panic. - */ -public record EntityGoalPanic( - double speed -) implements EntityGoal { - -} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRandomLookAround.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRandomLookAround.java deleted file mode 100644 index 9610c05b..00000000 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRandomLookAround.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.willfp.eco.core.entities.ai.goals.entity; - -import com.willfp.eco.core.entities.ai.goals.EntityGoal; - -/** - * Look around randomly. - */ -public record EntityGoalRandomLookAround( -) implements EntityGoal { - -} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRestrictSun.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRestrictSun.java deleted file mode 100644 index 0b725f6d..00000000 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRestrictSun.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.willfp.eco.core.entities.ai.goals.entity; - -import com.willfp.eco.core.entities.ai.goals.EntityGoal; - -/** - * Restrict sun. - */ -public record EntityGoalRestrictSun( -) implements EntityGoal { - -} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalStrollThroughVillage.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalStrollThroughVillage.java deleted file mode 100644 index f0f7ef5f..00000000 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalStrollThroughVillage.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.willfp.eco.core.entities.ai.goals.entity; - -import com.willfp.eco.core.entities.ai.goals.EntityGoal; - -/** - * Stroll through village. - * - * @param searchRange The search range. - */ -public record EntityGoalStrollThroughVillage( - int searchRange -) implements EntityGoal { - -} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalTryFindWater.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalTryFindWater.java deleted file mode 100644 index 432e1ec5..00000000 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalTryFindWater.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.willfp.eco.core.entities.ai.goals.entity; - -import com.willfp.eco.core.entities.ai.goals.EntityGoal; - -/** - * Try to find water. - */ -public record EntityGoalTryFindWater( -) implements EntityGoal { - -} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalWaterAvoidingRandomFlying.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalWaterAvoidingRandomFlying.java deleted file mode 100644 index d2bedc40..00000000 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalWaterAvoidingRandomFlying.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.willfp.eco.core.entities.ai.goals.entity; - -import com.willfp.eco.core.entities.ai.goals.EntityGoal; - -/** - * Fly randomly while avoiding water. - * - * @param speed The speed. - */ -public record EntityGoalWaterAvoidingRandomFlying( - double speed -) implements EntityGoal { - -} diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/target/TargetGoalHurtBy.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/target/TargetGoalHurtBy.java similarity index 66% rename from eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/target/TargetGoalHurtBy.java rename to eco-api/src/main/java/com/willfp/eco/core/entities/ai/target/TargetGoalHurtBy.java index 83a27489..830dec03 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/target/TargetGoalHurtBy.java +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/target/TargetGoalHurtBy.java @@ -1,7 +1,8 @@ -package com.willfp.eco.core.entities.ai.goals.target; +package com.willfp.eco.core.entities.ai.target; -import com.willfp.eco.core.entities.ai.goals.TargetGoal; +import com.willfp.eco.core.entities.ai.TargetGoal; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Mob; import org.jetbrains.annotations.NotNull; /** @@ -12,6 +13,6 @@ import org.jetbrains.annotations.NotNull; @SuppressWarnings({"varargs", "unchecked"}) public record TargetGoalHurtBy( @NotNull Class... blacklist -) implements TargetGoal { +) implements TargetGoal { } diff --git a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/target/TargetGoalNearestAttackable.java b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/target/TargetGoalNearestAttackable.java similarity index 70% rename from eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/target/TargetGoalNearestAttackable.java rename to eco-api/src/main/java/com/willfp/eco/core/entities/ai/target/TargetGoalNearestAttackable.java index a36baa51..a1f827a7 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/target/TargetGoalNearestAttackable.java +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/target/TargetGoalNearestAttackable.java @@ -1,7 +1,8 @@ -package com.willfp.eco.core.entities.ai.goals.target; +package com.willfp.eco.core.entities.ai.target; -import com.willfp.eco.core.entities.ai.goals.TargetGoal; +import com.willfp.eco.core.entities.ai.TargetGoal; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Mob; import org.jetbrains.annotations.NotNull; /** @@ -13,6 +14,6 @@ import org.jetbrains.annotations.NotNull; public record TargetGoalNearestAttackable( @NotNull Class targetClass, boolean checkVisibility -) implements TargetGoal { +) implements TargetGoal { } diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/NMSCommons.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/NMSCommons.kt index c60072a7..65045cb8 100644 --- a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/NMSCommons.kt +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/NMSCommons.kt @@ -1,6 +1,6 @@ package com.willfp.eco.internal.spigot.proxy.common -import com.willfp.eco.core.entities.ai.goals.EntityGoal +import com.willfp.eco.core.entities.ai.EntityGoal import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.LivingEntity diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/CustomGoals.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/CustomGoals.kt index e64138e2..739efd04 100644 --- a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/CustomGoals.kt +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/CustomGoals.kt @@ -1,21 +1,22 @@ package com.willfp.eco.internal.spigot.proxy.common.ai -import com.willfp.eco.core.entities.ai.goals.CustomGoal +import com.willfp.eco.core.entities.ai.CustomGoal import net.minecraft.world.entity.PathfinderMob import net.minecraft.world.entity.ai.goal.Goal -object CustomGoalFactory : EntityGoalFactory, TargetGoalFactory { - override fun create(apiGoal: CustomGoal, entity: PathfinderMob): Goal { +object CustomGoalFactory : EntityGoalFactory>, TargetGoalFactory> { + override fun create(apiGoal: CustomGoal<*>, entity: PathfinderMob): Goal { return NMSCustomGoal(apiGoal, entity) } } -private class NMSCustomGoal( - private val customEntityGoal: CustomGoal, +private class NMSCustomGoal( + private val customEntityGoal: CustomGoal, entity: PathfinderMob ) : Goal() { init { - customEntityGoal.initialize(entity.bukkitMob) + @Suppress("UNCHECKED_CAST") + customEntityGoal.initialize(entity.bukkitMob as T) } override fun canUse(): Boolean { diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/EcoEntityController.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/EcoEntityController.kt index ccadbf65..bca2caee 100644 --- a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/EcoEntityController.kt +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/EcoEntityController.kt @@ -1,8 +1,8 @@ package com.willfp.eco.internal.spigot.proxy.common.ai import com.willfp.eco.core.entities.ai.EntityController -import com.willfp.eco.core.entities.ai.goals.EntityGoal -import com.willfp.eco.core.entities.ai.goals.TargetGoal +import com.willfp.eco.core.entities.ai.EntityGoal +import com.willfp.eco.core.entities.ai.TargetGoal import com.willfp.eco.internal.spigot.proxy.common.commonsProvider import net.minecraft.world.entity.PathfinderMob import org.bukkit.entity.Mob @@ -10,7 +10,7 @@ import org.bukkit.entity.Mob class EcoEntityController( private val handle: T ) : EntityController { - override fun addEntityGoal(priority: Int, goal: EntityGoal): EntityController { + override fun addEntityGoal(priority: Int, goal: EntityGoal): EntityController { val nms = getNms() ?: return this nms.goalSelector.addGoal( @@ -21,7 +21,7 @@ class EcoEntityController( return this } - override fun removeEntityGoal(goal: EntityGoal): EntityController { + override fun removeEntityGoal(goal: EntityGoal): EntityController { val nms = getNms() ?: return this nms.goalSelector.removeGoal( goal.getGoalFactory()?.create(goal, nms) ?: return this @@ -36,7 +36,7 @@ class EcoEntityController( return this } - override fun addTargetGoal(priority: Int, goal: TargetGoal): EntityController { + override fun addTargetGoal(priority: Int, goal: TargetGoal): EntityController { val nms = getNms() ?: return this nms.targetSelector.addGoal( @@ -48,7 +48,7 @@ class EcoEntityController( return this } - override fun removeTargetGoal(goal: TargetGoal): EntityController { + override fun removeTargetGoal(goal: TargetGoal): EntityController { val nms = getNms() ?: return this nms.targetSelector.removeGoal( goal.getGoalFactory()?.create(goal, nms) ?: return this diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/EntityGoals.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/EntityGoals.kt index 2edc5db8..ce2149b1 100644 --- a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/EntityGoals.kt +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/EntityGoals.kt @@ -1,82 +1,76 @@ package com.willfp.eco.internal.spigot.proxy.common.ai -import com.willfp.eco.core.entities.ai.goals.CustomGoal -import com.willfp.eco.core.entities.ai.goals.EntityGoal -import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalAvoidEntity -import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalBreakDoor -import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalBreatheAir -import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalEatBlock -import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalFleeSun -import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalFloat -import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalFollowBoats -import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalFollowMobs -import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalInteract -import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalLeapAtTarget -import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalLookAtPlayer -import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalMeleeAttack -import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalMoveBackToVillage -import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalMoveThroughVillage -import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalMoveTowardsRestriction -import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalMoveTowardsTarget -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 com.willfp.eco.core.entities.ai.goals.entity.EntityGoalRestrictSun -import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalStrollThroughVillage -import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalTempt -import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalTryFindWater -import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalUseItem -import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalWaterAvoidingRandomFlying -import com.willfp.eco.core.entities.ai.goals.entity.EntityGoalWaterAvoidingRandomStroll +import com.willfp.eco.core.entities.ai.CustomGoal +import com.willfp.eco.core.entities.ai.EntityGoal +import com.willfp.eco.core.entities.ai.entity.EntityGoalAvoidEntity +import com.willfp.eco.core.entities.ai.entity.EntityGoalBreakDoor +import com.willfp.eco.core.entities.ai.entity.EntityGoalBreatheAir +import com.willfp.eco.core.entities.ai.entity.EntityGoalEatBlock +import com.willfp.eco.core.entities.ai.entity.EntityGoalFleeSun +import com.willfp.eco.core.entities.ai.entity.EntityGoalFloat +import com.willfp.eco.core.entities.ai.entity.EntityGoalFollowBoats +import com.willfp.eco.core.entities.ai.entity.EntityGoalFollowMobs +import com.willfp.eco.core.entities.ai.entity.EntityGoalInteract +import com.willfp.eco.core.entities.ai.entity.EntityGoalLeapAtTarget +import com.willfp.eco.core.entities.ai.entity.EntityGoalLookAtPlayer +import com.willfp.eco.core.entities.ai.entity.EntityGoalMeleeAttack +import com.willfp.eco.core.entities.ai.entity.EntityGoalMoveBackToVillage +import com.willfp.eco.core.entities.ai.entity.EntityGoalMoveThroughVillage +import com.willfp.eco.core.entities.ai.entity.EntityGoalMoveTowardsRestriction +import com.willfp.eco.core.entities.ai.entity.EntityGoalMoveTowardsTarget +import com.willfp.eco.core.entities.ai.entity.EntityGoalOcelotAttack +import com.willfp.eco.core.entities.ai.entity.EntityGoalOpenDoors +import com.willfp.eco.core.entities.ai.entity.EntityGoalPanic +import com.willfp.eco.core.entities.ai.entity.EntityGoalRandomLookAround +import com.willfp.eco.core.entities.ai.entity.EntityGoalRandomStroll +import com.willfp.eco.core.entities.ai.entity.EntityGoalRandomSwimming +import com.willfp.eco.core.entities.ai.entity.EntityGoalRangedAttack +import com.willfp.eco.core.entities.ai.entity.EntityGoalRangedBowAttack +import com.willfp.eco.core.entities.ai.entity.EntityGoalRangedCrossbowAttack +import com.willfp.eco.core.entities.ai.entity.EntityGoalRestrictSun +import com.willfp.eco.core.entities.ai.entity.EntityGoalStrollThroughVillage +import com.willfp.eco.core.entities.ai.entity.EntityGoalTempt +import com.willfp.eco.core.entities.ai.entity.EntityGoalTryFindWater +import com.willfp.eco.core.entities.ai.entity.EntityGoalUseItem +import com.willfp.eco.core.entities.ai.entity.EntityGoalWaterAvoidingRandomFlying +import com.willfp.eco.core.entities.ai.entity.EntityGoalWaterAvoidingRandomStroll +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.AvoidEntityGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.BreakDoorGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.BreatheAirGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.EatBlockGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.FleeSunGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.FloatGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.FollowBoatsGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.FollowMobsGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.InteractGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.LeapAtTargetGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.LookAtPlayerGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.MeleeAttackGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.MoveBackToVillageGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.MoveThroughVillageGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.MoveTowardsRestrictionGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.MoveTowardsTargetGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.OcelotAttackGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.OpenDoorsGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.PanicGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.RandomLookAroundGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.RandomStrollGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.RandomSwimmingGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.RangedAttackGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.RangedBowAttackGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.RangedCrossbowAttackGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.RestrictSunGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.StrollThroughVillageGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.TemptGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.TryFindWaterGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.entity.UseItemGoalFactory import com.willfp.eco.internal.spigot.proxy.common.commonsProvider -import net.minecraft.sounds.SoundEvent import net.minecraft.world.entity.PathfinderMob -import net.minecraft.world.entity.ai.goal.AvoidEntityGoal -import net.minecraft.world.entity.ai.goal.BreakDoorGoal -import net.minecraft.world.entity.ai.goal.BreathAirGoal -import net.minecraft.world.entity.ai.goal.EatBlockGoal -import net.minecraft.world.entity.ai.goal.FleeSunGoal -import net.minecraft.world.entity.ai.goal.FloatGoal -import net.minecraft.world.entity.ai.goal.FollowBoatGoal -import net.minecraft.world.entity.ai.goal.FollowMobGoal import net.minecraft.world.entity.ai.goal.Goal -import net.minecraft.world.entity.ai.goal.InteractGoal -import net.minecraft.world.entity.ai.goal.LeapAtTargetGoal -import net.minecraft.world.entity.ai.goal.LookAtPlayerGoal -import net.minecraft.world.entity.ai.goal.MeleeAttackGoal -import net.minecraft.world.entity.ai.goal.MoveBackToVillageGoal -import net.minecraft.world.entity.ai.goal.MoveThroughVillageGoal -import net.minecraft.world.entity.ai.goal.MoveTowardsRestrictionGoal -import net.minecraft.world.entity.ai.goal.MoveTowardsTargetGoal -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.ai.goal.RestrictSunGoal -import net.minecraft.world.entity.ai.goal.StrollThroughVillageGoal -import net.minecraft.world.entity.ai.goal.TemptGoal -import net.minecraft.world.entity.ai.goal.TryFindWaterGoal -import net.minecraft.world.entity.ai.goal.UseItemGoal import net.minecraft.world.entity.ai.goal.WaterAvoidingRandomFlyingGoal import net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal -import net.minecraft.world.entity.monster.CrossbowAttackMob -import net.minecraft.world.entity.monster.Monster -import net.minecraft.world.entity.monster.RangedAttackMob -import net.minecraft.world.entity.player.Player -import net.minecraft.world.item.crafting.Ingredient -fun T.getGoalFactory(): EntityGoalFactory? { +fun > T.getGoalFactory(): EntityGoalFactory? { val versionSpecific = commonsProvider.getVersionSpecificGoalFactory(this) if (versionSpecific != null) { return versionSpecific @@ -116,321 +110,21 @@ fun T.getGoalFactory(): EntityGoalFactory? { is EntityGoalUseItem -> UseItemGoalFactory is EntityGoalWaterAvoidingRandomFlying -> WaterAvoidingRandomFlyingGoalFactory is EntityGoalWaterAvoidingRandomStroll -> WaterAvoidingRandomStrollGoalFactory - is CustomGoal -> CustomGoalFactory + is CustomGoal<*> -> CustomGoalFactory else -> null } as EntityGoalFactory? } -interface EntityGoalFactory { +interface EntityGoalFactory> { fun create(apiGoal: T, entity: PathfinderMob): Goal? } -object AvoidEntityGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalAvoidEntity, entity: PathfinderMob): Goal { - return AvoidEntityGoal( - entity, - apiGoal.avoidClass.toNMSClass(), - apiGoal.fleeDistance.toFloat(), - apiGoal.slowSpeed, - apiGoal.fastSpeed - ) { apiGoal.filter.test(it.toBukkitEntity()) } - } -} -object BreakDoorGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalBreakDoor, entity: PathfinderMob): Goal { - return BreakDoorGoal( - entity, - apiGoal.maxProgress - ) { true } - } -} -object BreatheAirGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalBreatheAir, entity: PathfinderMob): Goal { - return BreathAirGoal( - entity - ) - } -} -object EatBlockGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalEatBlock, entity: PathfinderMob): Goal { - return EatBlockGoal( - entity - ) - } -} -object FleeSunGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalFleeSun, entity: PathfinderMob): Goal { - return FleeSunGoal( - entity, - apiGoal.speed - ) - } -} -object FloatGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalFloat, entity: PathfinderMob): Goal { - return FloatGoal( - entity - ) - } -} -object FollowBoatsGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalFollowBoats, entity: PathfinderMob): Goal { - return FollowBoatGoal( - entity - ) - } -} - -object FollowMobsGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalFollowMobs, entity: PathfinderMob): Goal { - return FollowMobGoal( - entity, - apiGoal.speed, - apiGoal.minDistance.toFloat(), - apiGoal.maxDistance.toFloat(), - ) - } -} - -object InteractGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalInteract, entity: PathfinderMob): Goal { - return InteractGoal( - entity, - apiGoal.targetClass.toNMSClass(), - apiGoal.range.toFloat(), - apiGoal.chance.toFloat() / 100f, - ) - } -} - -object LeapAtTargetGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalLeapAtTarget, entity: PathfinderMob): Goal { - return LeapAtTargetGoal( - entity, - apiGoal.velocity.toFloat() - ) - } -} - -object LookAtPlayerGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalLookAtPlayer, entity: PathfinderMob): Goal { - return LookAtPlayerGoal( - entity, - Player::class.java, - apiGoal.range.toFloat(), - apiGoal.chance.toFloat() / 100f, - ) - } -} - -object MeleeAttackGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalMeleeAttack, entity: PathfinderMob): Goal { - return MeleeAttackGoal( - entity, - apiGoal.speed, - apiGoal.pauseWhenMobIdle - ) - } -} - -object MoveBackToVillageGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalMoveBackToVillage, entity: PathfinderMob): Goal { - return MoveBackToVillageGoal( - entity, - apiGoal.speed, - apiGoal.canDespawn - ) - } -} - -object MoveThroughVillageGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalMoveThroughVillage, entity: PathfinderMob): Goal { - return MoveThroughVillageGoal( - entity, - apiGoal.speed, - apiGoal.onlyAtNight, - apiGoal.distance, - apiGoal.canPassThroughDoorsGetter - ) - } -} - -object MoveTowardsRestrictionGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalMoveTowardsRestriction, entity: PathfinderMob): Goal { - return MoveTowardsRestrictionGoal( - entity, - apiGoal.speed - ) - } -} - -object MoveTowardsTargetGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalMoveTowardsTarget, entity: PathfinderMob): Goal { - return MoveTowardsTargetGoal( - entity, - apiGoal.speed, - apiGoal.maxDistance.toFloat() - ) - } -} - -object OcelotAttackGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalOcelotAttack, entity: PathfinderMob): Goal { - return OcelotAttackGoal( - entity - ) - } -} - -object OpenDoorsGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalOpenDoors, entity: PathfinderMob): Goal { - return OpenDoorGoal( - entity, - apiGoal.delayedClose - ) - } -} - -object PanicGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalPanic, entity: PathfinderMob): Goal { - return PanicGoal( - entity, - apiGoal.speed - ) - } -} - -object RandomLookAroundGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalRandomLookAround, entity: PathfinderMob): Goal { - return RandomLookAroundGoal( - entity - ) - } -} - -object RandomStrollGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalRandomStroll, entity: PathfinderMob): Goal { - return RandomStrollGoal( - entity, - apiGoal.speed, - apiGoal.interval, - apiGoal.canDespawn - ) - } -} - -object RandomSwimmingGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalRandomSwimming, entity: PathfinderMob): Goal { - return RandomSwimmingGoal( - entity, - apiGoal.speed, - apiGoal.interval - ) - } -} - -object RangedAttackGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalRangedAttack, entity: PathfinderMob): Goal? { - return RangedAttackGoal( - entity as? RangedAttackMob ?: return null, - apiGoal.mobSpeed, - apiGoal.minInterval, - apiGoal.maxInterval, - apiGoal.maxRange.toFloat() - ) - } -} - -object RangedBowAttackGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalRangedBowAttack, entity: PathfinderMob): Goal? { - (if (entity !is Monster) return null) - if (entity !is RangedAttackMob) return null - - return RangedBowAttackGoal( - entity, - apiGoal.speed, - apiGoal.attackInterval, - apiGoal.range.toFloat() - ) - } -} - -object RangedCrossbowAttackGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalRangedCrossbowAttack, entity: PathfinderMob): Goal? { - (if (entity !is Monster) return null) - if (entity !is RangedAttackMob) return null - if (entity !is CrossbowAttackMob) return null - - return RangedCrossbowAttackGoal( - entity, - apiGoal.speed, - apiGoal.range.toFloat() - ) - } -} - -object RestrictSunGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalRestrictSun, entity: PathfinderMob): Goal { - return RestrictSunGoal( - entity - ) - } -} - -object StrollThroughVillageGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalStrollThroughVillage, entity: PathfinderMob): Goal { - return StrollThroughVillageGoal( - entity, - apiGoal.searchRange - ) - } -} - -object TemptGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalTempt, entity: PathfinderMob): Goal { - return TemptGoal( - entity, - apiGoal.speed, - Ingredient.of(*apiGoal.items.map { commonsProvider.toNMSStack(it) }.toTypedArray()), - apiGoal.canBeScared - ) - } -} - -object TryFindWaterGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalTryFindWater, entity: PathfinderMob): Goal { - return TryFindWaterGoal( - entity - ) - } -} - -object UseItemGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalUseItem, entity: PathfinderMob): Goal { - return UseItemGoal( - entity, - commonsProvider.toNMSStack(apiGoal.item), - SoundEvent(commonsProvider.toResourceLocation(apiGoal.sound.key)), - ) { - apiGoal.condition.test(it.toBukkitEntity()) - } - } -} - -object WaterAvoidingRandomFlyingGoalFactory : EntityGoalFactory { - override fun create(apiGoal: EntityGoalWaterAvoidingRandomFlying, entity: PathfinderMob): Goal { - return WaterAvoidingRandomFlyingGoal( - entity, - apiGoal.speed - ) - } -} object WaterAvoidingRandomStrollGoalFactory : EntityGoalFactory { override fun create(apiGoal: EntityGoalWaterAvoidingRandomStroll, entity: PathfinderMob): Goal { diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/TargetGoals.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/TargetGoals.kt index e5fd06ec..20c681b2 100644 --- a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/TargetGoals.kt +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/TargetGoals.kt @@ -1,25 +1,25 @@ package com.willfp.eco.internal.spigot.proxy.common.ai -import com.willfp.eco.core.entities.ai.goals.CustomGoal -import com.willfp.eco.core.entities.ai.goals.TargetGoal -import com.willfp.eco.core.entities.ai.goals.target.TargetGoalHurtBy -import com.willfp.eco.core.entities.ai.goals.target.TargetGoalNearestAttackable +import com.willfp.eco.core.entities.ai.CustomGoal +import com.willfp.eco.core.entities.ai.TargetGoal +import com.willfp.eco.core.entities.ai.target.TargetGoalHurtBy +import com.willfp.eco.core.entities.ai.target.TargetGoalNearestAttackable import net.minecraft.world.entity.PathfinderMob import net.minecraft.world.entity.ai.goal.Goal import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal -fun T.getGoalFactory(): TargetGoalFactory? { +fun > T.getGoalFactory(): TargetGoalFactory? { @Suppress("UNCHECKED_CAST") return when (this) { is TargetGoalHurtBy -> HurtByGoalFactory is TargetGoalNearestAttackable -> NearestAttackableGoalFactory - is CustomGoal -> CustomGoalFactory + is CustomGoal<*> -> CustomGoalFactory else -> null } as TargetGoalFactory? } -interface TargetGoalFactory { +interface TargetGoalFactory> { fun create(apiGoal: T, entity: PathfinderMob): Goal? } diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/AvoidEntityGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/AvoidEntityGoalFactory.kt new file mode 100644 index 00000000..13877794 --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/AvoidEntityGoalFactory.kt @@ -0,0 +1,21 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalAvoidEntity +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.toBukkitEntity +import com.willfp.eco.internal.spigot.proxy.common.ai.toNMSClass +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.AvoidEntityGoal +import net.minecraft.world.entity.ai.goal.Goal + +object AvoidEntityGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalAvoidEntity, entity: PathfinderMob): Goal { + return AvoidEntityGoal( + entity, + apiGoal.avoidClass.toNMSClass(), + apiGoal.fleeDistance.toFloat(), + apiGoal.slowSpeed, + apiGoal.fastSpeed + ) { apiGoal.filter.test(it.toBukkitEntity()) } + } +} \ No newline at end of file diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/BreakDoorGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/BreakDoorGoalFactory.kt new file mode 100644 index 00000000..31df8543 --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/BreakDoorGoalFactory.kt @@ -0,0 +1,16 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalBreakDoor +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.BreakDoorGoal +import net.minecraft.world.entity.ai.goal.Goal + +object BreakDoorGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalBreakDoor, entity: PathfinderMob): Goal { + return BreakDoorGoal( + entity, + apiGoal.maxProgress + ) { true } + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/BreatheAirGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/BreatheAirGoalFactory.kt new file mode 100644 index 00000000..df790332 --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/BreatheAirGoalFactory.kt @@ -0,0 +1,15 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalBreatheAir +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.BreathAirGoal +import net.minecraft.world.entity.ai.goal.Goal + +object BreatheAirGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalBreatheAir, entity: PathfinderMob): Goal { + return BreathAirGoal( + entity + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/EatBlockGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/EatBlockGoalFactory.kt new file mode 100644 index 00000000..1b5ed3d2 --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/EatBlockGoalFactory.kt @@ -0,0 +1,15 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalEatBlock +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.EatBlockGoal +import net.minecraft.world.entity.ai.goal.Goal + +object EatBlockGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalEatBlock, entity: PathfinderMob): Goal { + return EatBlockGoal( + entity + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/FleeSunGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/FleeSunGoalFactory.kt new file mode 100644 index 00000000..757a1072 --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/FleeSunGoalFactory.kt @@ -0,0 +1,16 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalFleeSun +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.FleeSunGoal +import net.minecraft.world.entity.ai.goal.Goal + +object FleeSunGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalFleeSun, entity: PathfinderMob): Goal { + return FleeSunGoal( + entity, + apiGoal.speed + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/FloatGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/FloatGoalFactory.kt new file mode 100644 index 00000000..cf230960 --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/FloatGoalFactory.kt @@ -0,0 +1,15 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalFloat +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.FloatGoal +import net.minecraft.world.entity.ai.goal.Goal + +object FloatGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalFloat, entity: PathfinderMob): Goal { + return FloatGoal( + entity + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/FollowBoatsGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/FollowBoatsGoalFactory.kt new file mode 100644 index 00000000..efc1e74c --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/FollowBoatsGoalFactory.kt @@ -0,0 +1,15 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalFollowBoats +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.FollowBoatGoal +import net.minecraft.world.entity.ai.goal.Goal + +object FollowBoatsGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalFollowBoats, entity: PathfinderMob): Goal { + return FollowBoatGoal( + entity + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/FollowMobsGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/FollowMobsGoalFactory.kt new file mode 100644 index 00000000..6cece7a4 --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/FollowMobsGoalFactory.kt @@ -0,0 +1,18 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalFollowMobs +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.FollowMobGoal +import net.minecraft.world.entity.ai.goal.Goal + +object FollowMobsGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalFollowMobs, entity: PathfinderMob): Goal { + return FollowMobGoal( + entity, + apiGoal.speed, + apiGoal.minDistance.toFloat(), + apiGoal.maxDistance.toFloat(), + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/InteractGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/InteractGoalFactory.kt new file mode 100644 index 00000000..8b01b6ba --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/InteractGoalFactory.kt @@ -0,0 +1,19 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalInteract +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.toNMSClass +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.Goal +import net.minecraft.world.entity.ai.goal.InteractGoal + +object InteractGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalInteract, entity: PathfinderMob): Goal { + return InteractGoal( + entity, + apiGoal.targetClass.toNMSClass(), + apiGoal.range.toFloat(), + apiGoal.chance.toFloat() / 100f, + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/LeapAtTargetGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/LeapAtTargetGoalFactory.kt new file mode 100644 index 00000000..e88c3da5 --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/LeapAtTargetGoalFactory.kt @@ -0,0 +1,16 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalLeapAtTarget +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.Goal +import net.minecraft.world.entity.ai.goal.LeapAtTargetGoal + +object LeapAtTargetGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalLeapAtTarget, entity: PathfinderMob): Goal { + return LeapAtTargetGoal( + entity, + apiGoal.velocity.toFloat() + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/LookAtPlayerGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/LookAtPlayerGoalFactory.kt new file mode 100644 index 00000000..cac878cc --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/LookAtPlayerGoalFactory.kt @@ -0,0 +1,19 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalLookAtPlayer +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.Goal +import net.minecraft.world.entity.ai.goal.LookAtPlayerGoal +import net.minecraft.world.entity.player.Player + +object LookAtPlayerGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalLookAtPlayer, entity: PathfinderMob): Goal { + return LookAtPlayerGoal( + entity, + Player::class.java, + apiGoal.range.toFloat(), + apiGoal.chance.toFloat() / 100f, + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/MeleeAttackGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/MeleeAttackGoalFactory.kt new file mode 100644 index 00000000..e3b6e089 --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/MeleeAttackGoalFactory.kt @@ -0,0 +1,17 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalMeleeAttack +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.Goal +import net.minecraft.world.entity.ai.goal.MeleeAttackGoal + +object MeleeAttackGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalMeleeAttack, entity: PathfinderMob): Goal { + return MeleeAttackGoal( + entity, + apiGoal.speed, + apiGoal.pauseWhenMobIdle + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/MoveBackToVillageGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/MoveBackToVillageGoalFactory.kt new file mode 100644 index 00000000..da8391c7 --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/MoveBackToVillageGoalFactory.kt @@ -0,0 +1,17 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalMoveBackToVillage +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.Goal +import net.minecraft.world.entity.ai.goal.MoveBackToVillageGoal + +object MoveBackToVillageGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalMoveBackToVillage, entity: PathfinderMob): Goal { + return MoveBackToVillageGoal( + entity, + apiGoal.speed, + apiGoal.canDespawn + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/MoveThroughVillageGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/MoveThroughVillageGoalFactory.kt new file mode 100644 index 00000000..02f2a34d --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/MoveThroughVillageGoalFactory.kt @@ -0,0 +1,19 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalMoveThroughVillage +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.Goal +import net.minecraft.world.entity.ai.goal.MoveThroughVillageGoal + +object MoveThroughVillageGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalMoveThroughVillage, entity: PathfinderMob): Goal { + return MoveThroughVillageGoal( + entity, + apiGoal.speed, + apiGoal.onlyAtNight, + apiGoal.distance, + apiGoal.canPassThroughDoorsGetter + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/MoveTowardsRestrictionGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/MoveTowardsRestrictionGoalFactory.kt new file mode 100644 index 00000000..5ee04782 --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/MoveTowardsRestrictionGoalFactory.kt @@ -0,0 +1,16 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalMoveTowardsRestriction +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.Goal +import net.minecraft.world.entity.ai.goal.MoveTowardsRestrictionGoal + +object MoveTowardsRestrictionGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalMoveTowardsRestriction, entity: PathfinderMob): Goal { + return MoveTowardsRestrictionGoal( + entity, + apiGoal.speed + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/MoveTowardsTargetGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/MoveTowardsTargetGoalFactory.kt new file mode 100644 index 00000000..14b7edda --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/MoveTowardsTargetGoalFactory.kt @@ -0,0 +1,17 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalMoveTowardsTarget +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.Goal +import net.minecraft.world.entity.ai.goal.MoveTowardsTargetGoal + +object MoveTowardsTargetGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalMoveTowardsTarget, entity: PathfinderMob): Goal { + return MoveTowardsTargetGoal( + entity, + apiGoal.speed, + apiGoal.maxDistance.toFloat() + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/OcelotAttackGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/OcelotAttackGoalFactory.kt new file mode 100644 index 00000000..69934b8d --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/OcelotAttackGoalFactory.kt @@ -0,0 +1,15 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalOcelotAttack +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.Goal +import net.minecraft.world.entity.ai.goal.OcelotAttackGoal + +object OcelotAttackGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalOcelotAttack, entity: PathfinderMob): Goal { + return OcelotAttackGoal( + entity + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/OpenDoorsGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/OpenDoorsGoalFactory.kt new file mode 100644 index 00000000..193d4404 --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/OpenDoorsGoalFactory.kt @@ -0,0 +1,16 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalOpenDoors +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.Goal +import net.minecraft.world.entity.ai.goal.OpenDoorGoal + +object OpenDoorsGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalOpenDoors, entity: PathfinderMob): Goal { + return OpenDoorGoal( + entity, + apiGoal.delayedClose + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/PanicGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/PanicGoalFactory.kt new file mode 100644 index 00000000..56c9450e --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/PanicGoalFactory.kt @@ -0,0 +1,16 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalPanic +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.Goal +import net.minecraft.world.entity.ai.goal.PanicGoal + +object PanicGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalPanic, entity: PathfinderMob): Goal { + return PanicGoal( + entity, + apiGoal.speed + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/RandomLookAroundGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/RandomLookAroundGoalFactory.kt new file mode 100644 index 00000000..7baa3e23 --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/RandomLookAroundGoalFactory.kt @@ -0,0 +1,15 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalRandomLookAround +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.Goal +import net.minecraft.world.entity.ai.goal.RandomLookAroundGoal + +object RandomLookAroundGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalRandomLookAround, entity: PathfinderMob): Goal { + return RandomLookAroundGoal( + entity + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/RandomStrollGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/RandomStrollGoalFactory.kt new file mode 100644 index 00000000..c0e8daae --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/RandomStrollGoalFactory.kt @@ -0,0 +1,18 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalRandomStroll +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.Goal +import net.minecraft.world.entity.ai.goal.RandomStrollGoal + +object RandomStrollGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalRandomStroll, entity: PathfinderMob): Goal { + return RandomStrollGoal( + entity, + apiGoal.speed, + apiGoal.interval, + apiGoal.canDespawn + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/RandomSwimmingGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/RandomSwimmingGoalFactory.kt new file mode 100644 index 00000000..c1f4002c --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/RandomSwimmingGoalFactory.kt @@ -0,0 +1,17 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalRandomSwimming +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.Goal +import net.minecraft.world.entity.ai.goal.RandomSwimmingGoal + +object RandomSwimmingGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalRandomSwimming, entity: PathfinderMob): Goal { + return RandomSwimmingGoal( + entity, + apiGoal.speed, + apiGoal.interval + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/RangedAttackGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/RangedAttackGoalFactory.kt new file mode 100644 index 00000000..4107e372 --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/RangedAttackGoalFactory.kt @@ -0,0 +1,20 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalRangedAttack +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.Goal +import net.minecraft.world.entity.ai.goal.RangedAttackGoal +import net.minecraft.world.entity.monster.RangedAttackMob + +object RangedAttackGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalRangedAttack, entity: PathfinderMob): Goal? { + return RangedAttackGoal( + entity as? RangedAttackMob ?: return null, + apiGoal.mobSpeed, + apiGoal.minInterval, + apiGoal.maxInterval, + apiGoal.maxRange.toFloat() + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/RangedBowAttackGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/RangedBowAttackGoalFactory.kt new file mode 100644 index 00000000..890dd71a --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/RangedBowAttackGoalFactory.kt @@ -0,0 +1,23 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalRangedBowAttack +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.Goal +import net.minecraft.world.entity.ai.goal.RangedBowAttackGoal +import net.minecraft.world.entity.monster.Monster +import net.minecraft.world.entity.monster.RangedAttackMob + +object RangedBowAttackGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalRangedBowAttack, entity: PathfinderMob): Goal? { + (if (entity !is Monster) return null) + if (entity !is RangedAttackMob) return null + + return RangedBowAttackGoal( + entity, + apiGoal.speed, + apiGoal.attackInterval, + apiGoal.range.toFloat() + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/RangedCrossbowAttackGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/RangedCrossbowAttackGoalFactory.kt new file mode 100644 index 00000000..e076706d --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/RangedCrossbowAttackGoalFactory.kt @@ -0,0 +1,24 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalRangedCrossbowAttack +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.Goal +import net.minecraft.world.entity.ai.goal.RangedCrossbowAttackGoal +import net.minecraft.world.entity.monster.CrossbowAttackMob +import net.minecraft.world.entity.monster.Monster +import net.minecraft.world.entity.monster.RangedAttackMob + +object RangedCrossbowAttackGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalRangedCrossbowAttack, entity: PathfinderMob): Goal? { + (if (entity !is Monster) return null) + if (entity !is RangedAttackMob) return null + if (entity !is CrossbowAttackMob) return null + + return RangedCrossbowAttackGoal( + entity, + apiGoal.speed, + apiGoal.range.toFloat() + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/RestrictSunGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/RestrictSunGoalFactory.kt new file mode 100644 index 00000000..b87bc75c --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/RestrictSunGoalFactory.kt @@ -0,0 +1,15 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalRestrictSun +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.Goal +import net.minecraft.world.entity.ai.goal.RestrictSunGoal + +object RestrictSunGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalRestrictSun, entity: PathfinderMob): Goal { + return RestrictSunGoal( + entity + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/StrollThroughVillageGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/StrollThroughVillageGoalFactory.kt new file mode 100644 index 00000000..d54ce2f1 --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/StrollThroughVillageGoalFactory.kt @@ -0,0 +1,16 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalStrollThroughVillage +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.Goal +import net.minecraft.world.entity.ai.goal.StrollThroughVillageGoal + +object StrollThroughVillageGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalStrollThroughVillage, entity: PathfinderMob): Goal { + return StrollThroughVillageGoal( + entity, + apiGoal.searchRange + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/TemptGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/TemptGoalFactory.kt new file mode 100644 index 00000000..2e63dbd0 --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/TemptGoalFactory.kt @@ -0,0 +1,20 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalTempt +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.commonsProvider +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.Goal +import net.minecraft.world.entity.ai.goal.TemptGoal +import net.minecraft.world.item.crafting.Ingredient + +object TemptGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalTempt, entity: PathfinderMob): Goal { + return TemptGoal( + entity, + apiGoal.speed, + Ingredient.of(*apiGoal.items.map { commonsProvider.toNMSStack(it) }.toTypedArray()), + apiGoal.canBeScared + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/TryFindWaterGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/TryFindWaterGoalFactory.kt new file mode 100644 index 00000000..d6d6187e --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/TryFindWaterGoalFactory.kt @@ -0,0 +1,15 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalTryFindWater +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.Goal +import net.minecraft.world.entity.ai.goal.TryFindWaterGoal + +object TryFindWaterGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalTryFindWater, entity: PathfinderMob): Goal { + return TryFindWaterGoal( + entity + ) + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/UseItemGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/UseItemGoalFactory.kt new file mode 100644 index 00000000..a039890d --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/UseItemGoalFactory.kt @@ -0,0 +1,22 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalUseItem +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import com.willfp.eco.internal.spigot.proxy.common.ai.toBukkitEntity +import com.willfp.eco.internal.spigot.proxy.common.commonsProvider +import net.minecraft.sounds.SoundEvent +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.Goal +import net.minecraft.world.entity.ai.goal.UseItemGoal + +object UseItemGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalUseItem, entity: PathfinderMob): Goal { + return UseItemGoal( + entity, + commonsProvider.toNMSStack(apiGoal.item), + SoundEvent(commonsProvider.toResourceLocation(apiGoal.sound.key)), + ) { + apiGoal.condition.test(it.toBukkitEntity()) + } + } +} diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/WaterAvoidingRandomFlyingGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/WaterAvoidingRandomFlyingGoalFactory.kt new file mode 100644 index 00000000..810915ed --- /dev/null +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/WaterAvoidingRandomFlyingGoalFactory.kt @@ -0,0 +1,16 @@ +package com.willfp.eco.internal.spigot.proxy.common.ai.entity + +import com.willfp.eco.core.entities.ai.entity.EntityGoalWaterAvoidingRandomFlying +import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory +import net.minecraft.world.entity.PathfinderMob +import net.minecraft.world.entity.ai.goal.Goal +import net.minecraft.world.entity.ai.goal.WaterAvoidingRandomFlyingGoal + +object WaterAvoidingRandomFlyingGoalFactory : EntityGoalFactory { + override fun create(apiGoal: EntityGoalWaterAvoidingRandomFlying, entity: PathfinderMob): Goal { + return WaterAvoidingRandomFlyingGoal( + entity, + apiGoal.speed + ) + } +}