Began entity controller system
This commit is contained in:
@@ -5,6 +5,7 @@ import com.willfp.eco.core.config.wrapper.ConfigFactory;
|
||||
import com.willfp.eco.core.data.ProfileHandler;
|
||||
import com.willfp.eco.core.data.keys.KeyRegistry;
|
||||
import com.willfp.eco.core.drops.DropQueueFactory;
|
||||
import com.willfp.eco.core.entities.ai.ControlledEntity;
|
||||
import com.willfp.eco.core.events.EventManager;
|
||||
import com.willfp.eco.core.extensions.ExtensionLoader;
|
||||
import com.willfp.eco.core.factory.MetadataValueFactory;
|
||||
@@ -20,6 +21,7 @@ import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Mob;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -262,4 +264,13 @@ public interface Handler {
|
||||
@NotNull
|
||||
PluginProps getProps(@Nullable PluginProps existing,
|
||||
@NotNull Class<? extends EcoPlugin> plugin);
|
||||
|
||||
/**
|
||||
* Create controlled entity from a mob.
|
||||
*
|
||||
* @param mob The mob.
|
||||
* @return The controlled entity.
|
||||
*/
|
||||
@NotNull
|
||||
ControlledEntity createControlledEntity(@NotNull Mob mob);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.willfp.eco.core.entities.ai;
|
||||
|
||||
import com.willfp.eco.core.Eco;
|
||||
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
|
||||
import org.bukkit.entity.Mob;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A controlled entity allows for adding targets and goals to entities.
|
||||
*/
|
||||
public interface ControlledEntity {
|
||||
/**
|
||||
* Add a target to the entity.
|
||||
*
|
||||
* @param priority The priority.
|
||||
* @param goal The goal.
|
||||
* @return The entity.
|
||||
*/
|
||||
ControlledEntity addTarget(int priority,
|
||||
@NotNull EntityGoal goal);
|
||||
|
||||
/**
|
||||
* Add a goal to the entity.
|
||||
*
|
||||
* @param priority The priority.
|
||||
* @param goal The goal.
|
||||
* @return The entity.
|
||||
*/
|
||||
ControlledEntity addGoal(int priority,
|
||||
@NotNull EntityGoal goal);
|
||||
|
||||
/**
|
||||
* Get the mob back from the controlled entity.
|
||||
*
|
||||
* @return The mob.
|
||||
*/
|
||||
Mob getEntity();
|
||||
|
||||
/**
|
||||
* Wrap an entity into a controlled entity in order to modify targets and goals.
|
||||
*
|
||||
* @param entity The entity.
|
||||
* @return The controlled entity.
|
||||
*/
|
||||
static ControlledEntity from(@NotNull final Mob entity) {
|
||||
return Eco.getHandler().createControlledEntity(entity);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.willfp.eco.core.entities.ai.goals;
|
||||
|
||||
/**
|
||||
* A goal for entity AI.
|
||||
*/
|
||||
public interface EntityGoal {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.willfp.eco.core.entities.ai.goals;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public record EntityGoalNearestAttackableTarget(
|
||||
@NotNull Class<? extends LivingEntity> targetClass,
|
||||
boolean checkVisibility
|
||||
) implements EntityGoal {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user