All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.minestom.server.entity.ai.EntityAI Maven / Gradle / Ivy

There is a newer version: 7320437640
Show newest version
package net.minestom.server.entity.ai;

import java.util.Collection;
import java.util.List;

/**
 * Represents an entity which can contain
 * {@link GoalSelector goal selectors} and {@link TargetSelector target selectors}.
 * 

* Both types of selectors are being stored in {@link EntityAIGroup AI groups}. * For every group there could be only a single {@link GoalSelector goal selector} running at a time, * but multiple groups are independent of each other, so each of them can have own goal selector running. */ public interface EntityAI { /** * Gets the AI groups of this entity. * * @return a modifiable collection of AI groups of this entity. */ Collection getAIGroups(); /** * Adds new AI group to this entity. * * @param group a group to be added. */ default void addAIGroup(EntityAIGroup group) { getAIGroups().add(group); } /** * Adds new AI group to this entity, consisting of the given * {@link GoalSelector goal selectors} and {@link TargetSelector target selectors}. * Their order is also a priority: the lower element index is, the higher priority is. * * @param goalSelectors goal selectors of the group. * @param targetSelectors target selectors of the group. */ default void addAIGroup(List goalSelectors, List targetSelectors) { EntityAIGroup group = new EntityAIGroup(); group.getGoalSelectors().addAll(goalSelectors); group.getTargetSelectors().addAll(targetSelectors); addAIGroup(group); } default void aiTick(long time) { getAIGroups().forEach(group -> group.tick(time)); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy