Java源码示例:net.minecraft.entity.ai.EntityAITasks

示例1
/**
 * Removes the (last found) dummy blocker AI task, if any
 * @param tasks
 */
public static void removeDummyAIBlockerTask(EntityAITasks tasks)
{
    EntityAIBase task = null;

    for (EntityAITaskEntry taskEntry : tasks.taskEntries)
    {
        if (taskEntry.action instanceof EntityAIDummyBlockerTask)
        {
            task = taskEntry.action;
        }

        // Restore the default mutex bits.
        // TODO: If modded mob tasks use this bit, then we should store the original value so we can restore it.
        if (taskEntry.action instanceof EntityAIFindEntityNearestPlayer)
        {
            taskEntry.action.setMutexBits(taskEntry.action.getMutexBits() & 0x7F);
        }
    }

    if (task != null)
    {
        tasks.removeTask(task);
    }
}
 
示例2
public static void cancelCurrentTasks(EntityLiving ent) {
  Iterator<EntityAITaskEntry> iterator = ent.tasks.taskEntries.iterator();
  List<EntityAITasks.EntityAITaskEntry> currentTasks = new ArrayList<EntityAITasks.EntityAITaskEntry>();
  while (iterator.hasNext()) {
    EntityAITaskEntry entityaitaskentry = iterator.next();
    if (entityaitaskentry != null) {
      currentTasks.add(entityaitaskentry);
    }
  }
  // Only available way to stop current execution is to remove all current
  // tasks, then re-add them
  for (EntityAITaskEntry task : currentTasks) {
    ent.tasks.removeTask(task.action);
    ent.tasks.addTask(task.priority, task.action);
  }
  ent.getNavigator().clearPathEntity();
}
 
示例3
@Override
public void setRabbitType(Type type) {
    EntityRabbit entity = getHandle();
    if (getRabbitType() == Type.THE_KILLER_BUNNY) {
        // Reset goals and target finders.
        World world = ((CraftWorld) this.getWorld()).getHandle();
        entity.tasks = new EntityAITasks(world != null && world.profiler != null ? world.profiler : null);
        entity.targetTasks = new EntityAITasks(world != null && world.profiler != null ? world.profiler : null);
        entity.initializePathFinderGoals();
    }

    entity.setRabbitType(CraftMagicMapping.toMagic(type));
}
 
示例4
public AffectedEntity(UUID eUUID,
                      List<EntityAITasks.EntityAITaskEntry> tasks,
                      List<EntityAITasks.EntityAITaskEntry> targetTasks) {
    this.eUUID = eUUID;
    this.tasks = tasks;
    this.targetTasks = targetTasks;
}
 
示例5
public EntityAITasksWrapper(EntityGolemBase golem, EntityAITasks tasks, boolean scheduleUpdate) {
    super(tasks.theProfiler);

    this.golem = golem;
    this.original = tasks;

    this.taskEntries = new WrapperList(original.taskEntries);
    this.original.taskEntries = this.taskEntries;

    this.scheduleUpdate = scheduleUpdate;
}
 
示例6
/**
 * Removes all AI tasks from the given EntityAITasks object
 * @param tasks the EntityAITasks object to remove the tasks from
 * @return true if at least some tasks were removed
 */
public static boolean removeAllAITasks(EntityAITasks tasks)
{
    List<EntityAITaskEntry> taskList = new ArrayList<EntityAITaskEntry>(tasks.taskEntries);

    for (EntityAITaskEntry taskEntry : taskList)
    {
        tasks.removeTask(taskEntry.action);
    }

    return taskList.isEmpty() == false;
}
 
示例7
@Override
public EntityAITasks getTargetAI(){
    return targetTasks;
}
 
示例8
@Override
public EntityAITasks getTargetAI(){
    return null;
}
 
示例9
public EntityAITasks getTargetAI();