use of net.minecraft.entity.ai.EntityAIBase in project PneumaticCraft by MineMaarten.
the class DroneAIManager method removeTask.
/**
* removes the indicated task from the entity's AI tasks.
*/
public void removeTask(EntityAIBase par1EntityAIBase) {
Iterator iterator = taskEntries.iterator();
while (iterator.hasNext()) {
EntityAITaskEntry entityaitaskentry = (EntityAITaskEntry) iterator.next();
EntityAIBase entityaibase1 = entityaitaskentry.action;
if (entityaibase1 == par1EntityAIBase) {
if (executingTaskEntries.contains(entityaitaskentry)) {
entityaibase1.resetTask();
executingTaskEntries.remove(entityaitaskentry);
}
iterator.remove();
}
}
}
use of net.minecraft.entity.ai.EntityAIBase in project PneumaticCraft by MineMaarten.
the class DroneAIManager method setActiveWidget.
private void setActiveWidget(IProgWidget widget) {
EntityAIBase targetAI = null;
EntityAIBase ai = null;
if (widget != null) {
boolean first = widget instanceof ProgWidgetStart;
targetAI = widget.getWidgetTargetAI(drone, widget);
ai = widget.getWidgetAI(drone, widget);
//Prevent endless loops
Set<IProgWidget> visitedWidgets = new HashSet<IProgWidget>();
while (!visitedWidgets.contains(widget) && targetAI == null && ai == null) {
visitedWidgets.add(widget);
IProgWidget oldWidget = widget;
widget = widget.getOutputWidget(drone, progWidgets);
if (widget == null) {
if (first) {
return;
} else {
if (stopWhenEndReached) {
setActiveWidget(null);
} else {
gotoFirstWidget();
}
return;
}
} else if (oldWidget.getOutputWidget() != widget) {
if (addJumpBackWidget(oldWidget))
return;
}
targetAI = widget.getWidgetTargetAI(drone, widget);
ai = widget.getWidgetAI(drone, widget);
}
drone.setActiveProgram(widget);
} else {
setLabel("Stopped");
}
curActiveWidget = widget;
if (curWidgetAI != null)
removeTask(curWidgetAI);
if (curWidgetTargetAI != null)
drone.getTargetAI().removeTask(curWidgetTargetAI);
if (ai != null)
addTask(2, ai);
if (targetAI != null)
drone.getTargetAI().addTask(2, targetAI);
curWidgetAI = ai;
curWidgetTargetAI = targetAI;
}
Aggregations