From 02497d485be3055f8ed803908f79c4e3aa1fc8d1 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 1 Mar 2022 20:04:04 +0000 Subject: [PATCH] Added more entity goals --- .../goals/entity/EntityGoalOcelotAttack.java | 11 +++++ .../ai/goals/entity/EntityGoalOpenDoors.java | 14 ++++++ .../ai/goals/entity/EntityGoalPanic.java | 14 ++++++ .../entity/EntityGoalRandomLookAround.java | 11 +++++ .../spigot/proxy/v1_17_R1/ai/EntityGoals.kt | 46 +++++++++++++++++++ 5 files changed, 96 insertions(+) create mode 100644 eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalOcelotAttack.java create mode 100644 eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalOpenDoors.java create mode 100644 eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalPanic.java create mode 100644 eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRandomLookAround.java 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 new file mode 100644 index 00000000..17682627 --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalOcelotAttack.java @@ -0,0 +1,11 @@ +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 new file mode 100644 index 00000000..b2b04be3 --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalOpenDoors.java @@ -0,0 +1,14 @@ +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 new file mode 100644 index 00000000..cad56593 --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalPanic.java @@ -0,0 +1,14 @@ +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 new file mode 100644 index 00000000..9610c05b --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/entities/ai/goals/entity/EntityGoalRandomLookAround.java @@ -0,0 +1,11 @@ +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-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_17_R1/ai/EntityGoals.kt b/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_17_R1/ai/EntityGoals.kt index 5b42f6b2..d1c76482 100644 --- a/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_17_R1/ai/EntityGoals.kt +++ b/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_17_R1/ai/EntityGoals.kt @@ -17,6 +17,10 @@ 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 net.minecraft.world.entity.PathfinderMob import net.minecraft.world.entity.ai.goal.AvoidEntityGoal import net.minecraft.world.entity.ai.goal.BreakDoorGoal @@ -35,6 +39,10 @@ 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.player.Player fun T.getImplementation(): EcoEntityGoal { @@ -56,6 +64,10 @@ fun T.getImplementation(): EcoEntityGoal { is EntityGoalMoveThroughVillage -> MoveThroughVillageImpl is EntityGoalMoveTowardsRestriction -> MoveTowardsRestrictionImpl is EntityGoalMoveTowardsTarget -> MoveTowardsTargetImpl + is EntityGoalOcelotAttack -> OcelotAttackImpl + is EntityGoalOpenDoors -> OpenDoorsImpl + is EntityGoalPanic -> PanicImpl + is EntityGoalRandomLookAround -> RandomLookAroundImpl else -> throw IllegalArgumentException("Unknown API goal!") } as EcoEntityGoal } @@ -218,3 +230,37 @@ object MoveTowardsTargetImpl : EcoEntityGoal { ) } } + +object OcelotAttackImpl : EcoEntityGoal { + override fun generateNMSGoal(apiGoal: EntityGoalOcelotAttack, entity: PathfinderMob): Goal { + return OcelotAttackGoal( + entity + ) + } +} + +object OpenDoorsImpl : EcoEntityGoal { + override fun generateNMSGoal(apiGoal: EntityGoalOpenDoors, entity: PathfinderMob): Goal { + return OpenDoorGoal( + entity, + apiGoal.delayedClose + ) + } +} + +object PanicImpl : EcoEntityGoal { + override fun generateNMSGoal(apiGoal: EntityGoalPanic, entity: PathfinderMob): Goal { + return PanicGoal( + entity, + apiGoal.speed + ) + } +} + +object RandomLookAroundImpl : EcoEntityGoal { + override fun generateNMSGoal(apiGoal: EntityGoalRandomLookAround, entity: PathfinderMob): Goal { + return RandomLookAroundGoal( + entity + ) + } +}