Java Code Examples for net.minecraft.entity.ai.EntityAIBase

The following are top voted examples for showing how to use net.minecraft.entity.ai.EntityAIBase. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: pnc-repressurized   File: DroneAIManager.java   Source Code and License 6 votes vote down vote up
/**
 * 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();
        }
    }
}
 
Example 2
Project: LightningCraft   File: EntityUnderworldGhast.java   Source Code and License 6 votes vote down vote up
@Override
protected void initEntityAI() {
	super.initEntityAI();
	EntityAIBase remove = null;
	for(EntityAITaskEntry task : this.tasks.taskEntries) {
		if(task.action.getClass().getSimpleName().equals("AIFireballAttack")) {
			remove = task.action;
			break;
		}
	}
	if(remove != null) {
		this.tasks.removeTask(remove);
		this.tasks.addTask(7, new AIUnderworldFireballAttack(this));
	} else {
		Log.logger.error(this.getName() + " failed to override Ghast fireball AI.");
	}
}
 
Example 3
Project: CustomAI   File: GuiCustomAI.java   Source Code and License 6 votes vote down vote up
private String[] generateAIList(boolean target)
{
    Iterator<Class<? extends EntityAIBase>> it = CustomAIHelper.isTarget.keySet().iterator();
    ArrayList<String> list = new ArrayList<String>();
    while(it.hasNext())
    {
        Class<? extends EntityAIBase> c = it.next();
        Boolean bool = CustomAIHelper.isTarget.get(c);
        if(bool == null)
            ;
        else if(bool)
        {
            if(target && CustomAIHelper.isSuitableForEntity((EntityLiving) entity, c))
                list.add(CustomAIHelper.getNameFromClass(c));
        }
        else
        {
            if(!target && CustomAIHelper.isSuitableForEntity((EntityLiving) entity, c))
                list.add(CustomAIHelper.getNameFromClass(c));
        }
    }
    
    return list.toArray(new String[0]);
}
 
Example 4
Project: CustomAI   File: GuiAIEmitter.java   Source Code and License 6 votes vote down vote up
private String[] generateAIList(boolean target)
{
    Iterator<Class<? extends EntityAIBase>> it = CustomAIHelper.isTarget.keySet().iterator();
    ArrayList<String> list = new ArrayList<String>();
    while(it.hasNext())
    {
        Class<? extends EntityAIBase> c = it.next();
        Boolean bool = CustomAIHelper.isTarget.get(c);
        if(bool == null)
            ;
        else if(bool)
        {
            if(target)
                list.add(CustomAIHelper.getNameFromClass(c));
        }
        else
        {
            if(!target)
                list.add(CustomAIHelper.getNameFromClass(c));
        }
    }
    
    return list.toArray(new String[0]);
}
 
Example 5
Project: CustomAI   File: EntityAIFactory.java   Source Code and License 6 votes vote down vote up
public EntityAIWorker getWorkerFromClass(Class<? extends EntityAIBase> c)
{
    Set<Class<? extends EntityAIBase>[]> keys = workerRegistry.keySet();
    Iterator<Class<? extends EntityAIBase>[]> it = keys.iterator();
    while(it.hasNext())
    {
        Class<? extends EntityAIBase>[] classes = it.next();
        for(Class<? extends EntityAIBase> clazz : classes)
        {
            if(clazz == c)
            {
                return workerRegistry.get(classes);
            }
        }
    }
    return null;
}
 
Example 6
Project: enderutilities   File: EntityUtils.java   Source Code and License 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 7
Project: RuneCraftery   File: EntityAITasks.java   Source Code and License 6 votes vote down vote up
public void func_85156_a(EntityAIBase p_85156_1_) {
   Iterator var2 = this.field_75782_a.iterator();

   while(var2.hasNext()) {
      EntityAITaskEntry var3 = (EntityAITaskEntry)var2.next();
      EntityAIBase var4 = var3.field_75733_a;
      if(var4 == p_85156_1_) {
         if(this.field_75780_b.contains(var3)) {
            var4.func_75251_c();
            this.field_75780_b.remove(var3);
         }

         var2.remove();
      }
   }

}
 
Example 8
Project: PneumaticCraft   File: DroneAIManager.java   Source Code and License 6 votes vote down vote up
/**
 * 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();
        }
    }
}
 
Example 9
Project: pnc-repressurized   File: ProgWidgetEntityRightClick.java   Source Code and License 5 votes vote down vote up
@Override
public EntityAIBase getWidgetAI(IDroneBase drone, IProgWidget widget) {
    return new DroneEntityBase<IProgWidget, EntityLivingBase>(drone, widget) {
        private final List<Entity> visitedEntities = new ArrayList<Entity>();

        @Override
        protected boolean isEntityValid(Entity entity) {
            return entity instanceof EntityLivingBase && !visitedEntities.contains(entity);
        }

        @Override
        protected boolean doAction() {
            visitedEntities.add(targetedEntity);
            boolean activated = false;
            ItemStack stack = drone.getInv().getStackInSlot(0);
            if (stack.getItem().itemInteractionForEntity(stack, drone.getFakePlayer(), targetedEntity, EnumHand.MAIN_HAND)) {
                activated = true;
            }
            if (!activated && targetedEntity instanceof EntityAgeable && ((EntityAgeable) targetedEntity).processInteract(drone.getFakePlayer(), EnumHand.MAIN_HAND)) {
                activated = true;
            }
            DroneAIBlockInteract.transferToDroneFromFakePlayer(drone);
            return false;//return activated; <-- will right click as long as it's sucessfully activated.
        }

    };
}
 
Example 10
Project: pnc-repressurized   File: ProgWidgetDroneEvaluation.java   Source Code and License 5 votes vote down vote up
@Override
public EntityAIBase getWidgetAI(IDroneBase drone, IProgWidget widget) {
    if (widget instanceof ProgWidgetDroneEvaluation) {
        return null;
    } else {
        return new EntityAIBase() {//Trick the CC program into thinking this is an executable piece.
            @Override
            public boolean shouldExecute() {
                return false;
            }
        };
    }
}
 
Example 11
Project: ObsidianSuite   File: ObsidianAPIUtil.java   Source Code and License 5 votes vote down vote up
public static boolean isEntityAITaskActive(EntityLiving entity, String AIName) {
	for(Object obj : entity.tasks.taskEntries) {
		EntityAITaskEntry taskEntry = (EntityAITaskEntry) obj;
		EntityAIBase task = taskEntry.action;
		if(task instanceof IEntityAIAnimation) {
			IEntityAIAnimation animatedTask = (IEntityAIAnimation) task;
			if(animatedTask.getAIName().equals(AIName) && animatedTask.isExecuting())
				return true;
		}
	}
	return false;
}
 
Example 12
Project: Factorization   File: BuffNametags.java   Source Code and License 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOW)
public void buffedNametag(EntityInteractEvent event) {
    ItemStack is = event.entityPlayer.getHeldItem();
    if (is == null) return;
    if (is.getItem() != Items.name_tag) return;
    if (!(event.target instanceof EntityLiving)) return;
    final EntityLiving ent = (EntityLiving) event.target;
    final String origName = ent.getCustomNameTag();
    if (!Strings.isNullOrEmpty(origName)) return;
    NBTTagCompound tag = ent.getEntityData();
    final String name = "FZMiscBuffNametags";
    if (tag.hasKey(name)) return;
    tag.setBoolean(name, true);
    ent.tasks.addTask(0, new EntityAIBase() {
        boolean buffApplied = false; // Might not be necessary.
        
        @Override
        public boolean shouldExecute() {
            if (buffApplied) return false;
            buffApplied = true;
            if (ent.getCustomNameTag().equals(origName)) return false;
            float delta = 2*3;
            float origHealth = ent.getMaxHealth();
            float newMaxHealth = origHealth + delta;
            ent.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(newMaxHealth);
            ent.heal(delta);

            EnumParticleTypes particleType = EnumParticleTypes.HEART;
            if (ent instanceof IMob) {
                particleType = EnumParticleTypes.SMOKE_NORMAL;
            }
            if (ent.worldObj instanceof WorldServer) {
                WorldServer ws = (WorldServer) ent.worldObj;
                ws.spawnParticle(particleType, false, ent.posX, ent.posY, ent.posZ, 8, 0.0, 0.0, 0.0, 0.0);
            }
            return false;
        }
    });
}
 
Example 13
Project: NeptuneMod   File: MixinEntityAITasks.java   Source Code and License 5 votes vote down vote up
@Override
public boolean addTask(int priority, AIBase ai) {
    if (ai instanceof EntityAIBase) {
        this.addTask(priority, (EntityAIBase) ai);
    } else {
        this.addTask(priority, new NeptuneCustomEntityAI(ai));
    }
    return this.hasTask(ai.getClass());
}
 
Example 14
Project: RidiculousWorld   File: EntityPeep.java   Source Code and License 5 votes vote down vote up
public EntityPeep(World world){
    super(world);
    this.timeUntilNextEasterEgg = this.rand.nextInt(6000) + 6000;
    EntityAIBase tempt = null;
    for(Object thingy : tasks.taskEntries){
        EntityAITasks.EntityAITaskEntry ai = (EntityAITasks.EntityAITaskEntry)thingy;
        if(ai.action instanceof EntityAITempt) {
            tempt = ai.action;
            break;
        }
    }
    if(tempt !=null)
        this.tasks.removeTask(tempt);
    this.tasks.addTask(3, new EntityAITempt(this, 1.0D, Items.sugar, false));
}
 
Example 15
Project: CustomAI   File: CustomAIHelper.java   Source Code and License 5 votes vote down vote up
public static String getNameForTask(Class<? extends EntityAIBase> action)
{
    if(map.containsKey(action))
    {
        return map.get(action);
    }
    String s = action.getCanonicalName();
    if(s.contains("."))
    {
        return s.substring(s.lastIndexOf('.')+1);
    }
    return s;
}
 
Example 16
Project: CustomAI   File: CustomAIHelper.java   Source Code and License 5 votes vote down vote up
public static String getNameForTask(EntityAIBase action)
{
    if(map.containsKey(action.getClass()))
    {
        return map.get(action.getClass());
    }
    String s = action.getClass().getCanonicalName();
    if(s.contains("."))
    {
        return s.substring(s.lastIndexOf('.')+1);
    }
    return s;
}
 
Example 17
Project: CustomAI   File: CustomAIHelper.java   Source Code and License 5 votes vote down vote up
public static boolean isSuitableForEntity(EntityLiving entity, Class<? extends EntityAIBase> c)
{
    EntityAIWorker worker = EntityAIFactory.instance().getWorkerFromClass(c);
    if(worker == null)
        return false;
    return worker.isSuitableForEntity(entity, c);
}
 
Example 18
Project: CustomAI   File: CustomAIHelper.java   Source Code and License 5 votes vote down vote up
public static Class<? extends EntityAIBase> getClassFromName(String name)
{
    Iterator<Class<? extends EntityAIBase>> it = map.keySet().iterator();
    while(it.hasNext())
    {
        Class<? extends EntityAIBase> c = it.next();
        if(map.get(c).equals(name))
        {
            return c;
        }
    }
    return null;
}
 
Example 19
Project: CustomAI   File: CustomAIHelper.java   Source Code and License 5 votes vote down vote up
public static Class<? extends EntityAIBase> tryToGetAITaskFromName(String clazz)
{
    Set<Class<? extends EntityAIBase>> tasks = map.keySet();
    Iterator<Class<? extends EntityAIBase>> it = tasks.iterator();
    while(it.hasNext())
    {
        Class<? extends EntityAIBase> c = it.next();
        String s = map.get(c);
        if(s.equalsIgnoreCase(clazz))
        {
            return c;
        }
    }
    return null;
}
 
Example 20
Project: CustomAI   File: EntityCustomAIAddedWorker.java   Source Code and License 5 votes vote down vote up
@Override
public JSONObject createDefaultJSON(Class<? extends EntityAIBase> clazz)
{
    JSONObject object = new JSONObject();
    object.put("type", clazz.getCanonicalName());
    object.put("priority", 1);
    if(clazz == EntityAIFleeSunEvenNotBurning.class)
    {
        object.put("Move speed", 0.9);
    }
    else if(clazz == EntityAIFollowEntity.class)
    {
        object.put("Entity class name", "none");
        object.put("Move speed", 0.9);
        object.put("Max distance", 10f);
    }
    else if(clazz == EntityAITeleportRandomly.class)
    {
        object.put("Tick rate", 60);
        object.put("Play teleport sound", true);
        object.put("Avoid liquids", true);
    }
    else if(clazz == EntityAIRangeAttack.class)
    {
        object.put("Move speed", 0.9);
        object.put("Reload time", 20);
        object.put("Max reload time", 60);
        object.put("Distance from target", 10f);
        object.put("Projectile type", "Arrows");
    }
    return object;
}
 
Example 21
Project: CustomAI   File: EntityCustomAIAddedWorker.java   Source Code and License 5 votes vote down vote up
@Override
public boolean isSuitableForEntity(EntityLiving living,
        Class<? extends EntityAIBase> clazz)
{
    if(clazz == EntityAIFleeSunEvenNotBurning.class && ! (living instanceof EntityCreature))
        return false;
    return true;
}
 
Example 22
Project: CustomAI   File: EntityAIFactory.java   Source Code and License 5 votes vote down vote up
public JSONObject generateJSON(EntityLiving entity, EntityAITaskEntry entry)
{
    Class<? extends EntityAIBase> clazz = entry.action.getClass();
    EntityAIWorker worker = this.getWorkerFromClass(clazz);
    if(worker == null)
        System.out.println(clazz);
    if(worker != null)
    {
        return worker.generateJSON(entity, entry);
    }
    return new JSONObject();
}
 
Example 23
Project: CustomAI   File: EntityAIFactory.java   Source Code and License 5 votes vote down vote up
public JSONObject createDefaultJSON(Class<? extends EntityAIBase> clazz)
{
    EntityAIWorker worker = getWorkerFromClass(clazz);
    if(worker != null)
    {
        return worker.createDefaultJSON(clazz);
    }
    return new JSONObject();
}
 
Example 24
Project: AdventureBackpack2   File: BackpackAbilities.java   Source Code and License 5 votes vote down vote up
/**
 * The Wolf Backpack is a handy one if you're out in the wild. It checks around for any wolves that may lurk around.
 * If any of them gets mad at you, it will smell the scent of it's kin on you and promptly forget about the whole
 * deal. Smelling like dog is awesome.
 *
 * @param player   the player
 * @param world    the world
 * @param backpack the backpack
 */
@SuppressWarnings("unchecked")
public void itemWolf(EntityPlayer player, World world, ItemStack backpack)
{
    //lastTime is in Ticks for this backpack
    InventoryBackpack inv = new InventoryBackpack(backpack);
    int lastCheckTime =  inv.getLastTime() - 1;

    if (lastCheckTime <= 0)
    {
        lastCheckTime = 20;
        List<EntityWolf> wolves = world.getEntitiesWithinAABB(
                EntityWolf.class,
                AxisAlignedBB.getBoundingBox(player.posX, player.posY, player.posZ,
                        player.posX + 1.0D, player.posY + 1.0D,
                        player.posZ + 1.0D).expand(16.0D, 4.0D, 16.0D));
        if (wolves.isEmpty()) return;

        for (EntityWolf wolf : wolves)
        {
            if (wolf.isAngry() && wolf.getAttackTarget() == player)
            {
                wolf.setAngry(false);
                wolf.setAttackTarget(null);
                wolf.setRevengeTarget(null);
                Iterator<?> i2 = wolf.targetTasks.taskEntries.iterator();
                while (i2.hasNext())
                {
                    ((EntityAIBase) i2.next()).resetTask();
                }
            }
        }
    }
    inv.setLastTime(lastCheckTime);
    inv.dirtyTime();
}
 
Example 25
Project: FysiksFun   File: AnimalAIRewriter.java   Source Code and License 5 votes vote down vote up
/**
 * All AI's with higher or equal priority value (less valued) is incremented
 * by one before this AI is inserted. Thus it comes before an old AI with same
 * priority value
 */
private static void insertAI(EntityAnimal animal, int priority, EntityAIBase aitask) {
  // System.out.println("Rewriting the animal: "+cow);
  // First increment the priority of every taskEntry that has same-or-higher
  // priority as the new one
  for (Object o2 : animal.tasks.taskEntries) {
    EntityAITaskEntry taskEntry = (EntityAITaskEntry) o2;
    if (taskEntry.priority >= priority) {
      taskEntry.priority++;
    }
  }
  animal.tasks.addTask(priority, aitask);
}
 
Example 26
Project: RideableCows   File: CommonProxy.java   Source Code and License 5 votes vote down vote up
private boolean addTask(EntityCow cow, int priority, EntityAIBase action) {
    for (Object obj : cow.tasks.taskEntries) {
        EntityAITasks.EntityAITaskEntry taskEntry = (EntityAITasks.EntityAITaskEntry) obj;
        if (action.getClass().isInstance(taskEntry.action)) {
            return false;
        }
    }
    cow.tasks.addTask(priority, action);
    return true;
}
 
Example 27
Project: RideableCows   File: CommonProxy.java   Source Code and License 5 votes vote down vote up
private int getPriorityOfTask(EntityLiving living, Class<? extends EntityAIBase> clazz) {
    for (Object obj : living.tasks.taskEntries) {
        EntityAITasks.EntityAITaskEntry taskEntry = (EntityAITasks.EntityAITaskEntry) obj;
        if (clazz.isInstance(taskEntry.action)) {
            return taskEntry.priority;
        }
    }
    return -1;
}
 
Example 28
Project: PneumaticCraft   File: ProgWidgetEntityRightClick.java   Source Code and License 5 votes vote down vote up
@Override
public EntityAIBase getWidgetAI(IDroneBase drone, IProgWidget widget){
    return new DroneEntityBase<IProgWidget, EntityLivingBase>(drone, widget){
        private final List<Entity> visitedEntities = new ArrayList<Entity>();

        @Override
        protected boolean isEntityValid(Entity entity){
            return entity instanceof EntityLivingBase && !visitedEntities.contains(entity);
        }

        @Override
        protected boolean doAction(){
            visitedEntities.add(targetedEntity);
            boolean activated = false;
            ItemStack stack = drone.getInventory().getStackInSlot(0);
            if(stack != null && stack.getItem().itemInteractionForEntity(stack, drone.getFakePlayer(), targetedEntity)) {
                activated = true;
            }
            if(!activated && targetedEntity instanceof EntityAgeable && ((EntityAgeable)targetedEntity).interact(drone.getFakePlayer())) {
                activated = true;
            }
            DroneAIBlockInteract.transferToDroneFromFakePlayer(drone);
            return false;//return activated; <-- will right click as long as it's sucessfully activated.
        }

    };
}
 
Example 29
Project: PneumaticCraft   File: ProgWidgetDroneEvaluation.java   Source Code and License 5 votes vote down vote up
@Override
public EntityAIBase getWidgetAI(IDroneBase drone, IProgWidget widget){
    if(widget instanceof ProgWidgetDroneEvaluation) {
        return null;
    } else {
        return new EntityAIBase(){//Trick the CC program into thinking this is an executable piece.
            @Override
            public boolean shouldExecute(){
                return false;
            }
        };
    }
}
 
Example 30
Project: EnderIO   File: AIAttractionHandler.java   Source Code and License 5 votes vote down vote up
@Override
public void startAttracting(TileAttractor attractor, EntityLiving entity) {
  EntityAIBase remove = findAITask(attractor, entity);
  if (remove != null) {
    entity.tasks.removeTask(remove);
  }
  cancelCurrentTasks(entity);
  entity.tasks.addTask(0, new AttractTask(entity, attractor.getTarget(), attractor.getPos()));
}
 
Example 31
Project: EnderIO   File: AIAttractionHandler.java   Source Code and License 5 votes vote down vote up
private EntityAIBase findAITask(TileAttractor attractor, EntityLiving entity) {
  for (EntityAITaskEntry entry : entity.tasks.taskEntries) {
    if (entry.action instanceof AttractTask) {
      AttractTask at = (AttractTask) entry.action;
      if (attractor == null || at.coord.equals(BlockCoord.get(attractor)) || !at.continueExecuting()) {
        return entry.action;
      } else {
        return null;
      }
    }
  }
  return null;
}
 
Example 32
Project: EnderIO   File: AIAttractionHandler.java   Source Code and License 5 votes vote down vote up
@Override
public void release(TileAttractor attractor, EntityLiving entity) {
  EntityAIBase remove = findAITask(attractor, entity);
  if (remove != null) {
    entity.tasks.removeTask(remove);
    cancelCurrentTasks(entity);
  }
}
 
Example 33
Project: pnc-repressurized   File: EntityDrone.java   Source Code and License 4 votes vote down vote up
public EntityAIBase getRunningTargetAI() {
    return aiManager.getTargetAI();
}
 
Example 34
Project: pnc-repressurized   File: DroneAICC.java   Source Code and License 4 votes vote down vote up
public synchronized void setAction(IProgWidget widget, EntityAIBase ai) throws IllegalArgumentException {
    curAction = ai;
    newAction = true;
    curActionActive = true;
}
 
Example 35
Project: pnc-repressurized   File: ProgWidgetCC.java   Source Code and License 4 votes vote down vote up
@Override
public EntityAIBase getWidgetAI(IDroneBase drone, IProgWidget widget) {
    return new DroneAICC((EntityDrone) drone, (ProgWidgetCC) widget, false);
}
 
Example 36
Project: pnc-repressurized   File: ProgWidgetCC.java   Source Code and License 4 votes vote down vote up
@Override
public EntityAIBase getWidgetTargetAI(IDroneBase drone, IProgWidget widget) {
    return new DroneAICC((EntityDrone) drone, (ProgWidgetCC) widget, true);
}
 
Example 37
Project: pnc-repressurized   File: DroneAIManager.java   Source Code and License 4 votes vote down vote up
public EntityAIBase getCurrentAI() {
    return curWidgetAI;
}
 
Example 38
Project: pnc-repressurized   File: DroneAIManager.java   Source Code and License 4 votes vote down vote up
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);
        Set<IProgWidget> visitedWidgets = new HashSet<IProgWidget>();//Prevent endless loops
        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;
}
 
Example 39
Project: pnc-repressurized   File: DroneAIManager.java   Source Code and License 4 votes vote down vote up
public EntityAIBase getTargetAI() {
    return curWidgetTargetAI;
}
 
Example 40
Project: pnc-repressurized   File: DroneAIManager.java   Source Code and License 4 votes vote down vote up
/**
 * START EntityAITasks code
 */

public void addTask(int par1, EntityAIBase par2EntityAIBase) {
    taskEntries.add(new EntityAITaskEntry(par1, par2EntityAIBase));
}
 
Example 41
Project: pnc-repressurized   File: DroneAIManager.java   Source Code and License 4 votes vote down vote up
public EntityAITaskEntry(int par2, EntityAIBase par3EntityAIBase) {
    priority = par2;
    action = par3EntityAIBase;
}
 
Example 42
Project: pnc-repressurized   File: DroneAIExternalProgram.java   Source Code and License 4 votes vote down vote up
private boolean isRunningSameProgram(EntityAIBase ai) {
    return ai instanceof DroneAIExternalProgram && curProgramTag.equals(((DroneAIExternalProgram) ai).curProgramTag);
}
 
Example 43
Project: pnc-repressurized   File: ProgWidgetEditSign.java   Source Code and License 4 votes vote down vote up
@Override
public EntityAIBase getWidgetAI(IDroneBase drone, IProgWidget widget) {
    return new DroneAIEditSign(drone, (ProgWidgetAreaItemBase) widget);
}
 
Example 44
Project: pnc-repressurized   File: ProgWidgetPickupItem.java   Source Code and License 4 votes vote down vote up
@Override
public EntityAIBase getWidgetAI(IDroneBase drone, IProgWidget widget) {
    return new DroneEntityAIPickupItems(drone, (ProgWidgetAreaItemBase) widget);
}
 
Example 45
Project: pnc-repressurized   File: ProgWidgetTeleport.java   Source Code and License 4 votes vote down vote up
@Override
public EntityAIBase getWidgetAI(IDroneBase drone, IProgWidget widget) {
    return new DroneAITeleport((EntityDrone) drone, (ProgWidget) widget);
}
 
Example 46
Project: pnc-repressurized   File: ProgWidgetStandby.java   Source Code and License 4 votes vote down vote up
@Override
public EntityAIBase getWidgetAI(IDroneBase drone, IProgWidget widget) {
    return new DroneAIStandby((EntityDrone) drone);
}
 
Example 47
Project: pnc-repressurized   File: ProgWidgetRename.java   Source Code and License 4 votes vote down vote up
@Override
public EntityAIBase getWidgetAI(final IDroneBase drone, final IProgWidget widget) {
    return new DroneAIRename(drone, (IRenamingWidget) widget);
}
 
Example 48
Project: pnc-repressurized   File: ProgWidgetLiquidExport.java   Source Code and License 4 votes vote down vote up
@Override
public EntityAIBase getWidgetAI(IDroneBase drone, IProgWidget widget) {
    return new DroneAILiquidExport(drone, (ProgWidgetAreaItemBase) widget);
}
 
Example 49
Project: pnc-repressurized   File: ProgWidgetEmitRedstone.java   Source Code and License 4 votes vote down vote up
@Override
public EntityAIBase getWidgetAI(IDroneBase drone, IProgWidget widget) {
    return new DroneAIEmitRedstone(drone, widget);
}
 
Example 50
Project: pnc-repressurized   File: ProgWidgetCustomBlockInteract.java   Source Code and License 4 votes vote down vote up
@Override
public EntityAIBase getWidgetAI(IDroneBase drone, IProgWidget widget) {
    return new DroneAICustomBlockInteract(drone, (ProgWidgetAreaItemBase) widget, interactor);
}
 
Example 51
Project: pnc-repressurized   File: ProgWidgetWait.java   Source Code and License 4 votes vote down vote up
@Override
public EntityAIBase getWidgetAI(IDroneBase drone, IProgWidget widget) {
    return widget instanceof ProgWidgetWait ? widget.getConnectedParameters()[0] != null ? new DroneAIWait((ProgWidgetString) widget.getConnectedParameters()[0]) : null : null;
}
 
Example 52
Project: pnc-repressurized   File: ProgWidgetInventoryImport.java   Source Code and License 4 votes vote down vote up
@Override
public EntityAIBase getWidgetAI(IDroneBase drone, IProgWidget widget) {
    return new DroneEntityAIInventoryImport(drone, (ProgWidgetAreaItemBase) widget);
}
 
Example 53
Project: pnc-repressurized   File: ProgWidgetLiquidImport.java   Source Code and License 4 votes vote down vote up
@Override
public EntityAIBase getWidgetAI(IDroneBase drone, IProgWidget widget) {
    return new DroneAILiquidImport(drone, (ProgWidgetAreaItemBase) widget);
}
 
Example 54
Project: pnc-repressurized   File: ProgWidgetEntityImport.java   Source Code and License 4 votes vote down vote up
@Override
public EntityAIBase getWidgetAI(IDroneBase drone, IProgWidget widget) {
    return new DroneAIEntityImport(drone, widget);
}
 
Example 55
Project: pnc-repressurized   File: ProgWidgetBlockRightClick.java   Source Code and License 4 votes vote down vote up
@Override
public EntityAIBase getWidgetAI(IDroneBase drone, IProgWidget widget) {
    return setupMaxActions(new DroneAIBlockInteract(drone, (ProgWidgetAreaItemBase) widget), (IMaxActions) widget);
}
 
Example 56
Project: pnc-repressurized   File: ProgWidget.java   Source Code and License 4 votes vote down vote up
@Override
public EntityAIBase getWidgetTargetAI(IDroneBase drone, IProgWidget widget) {
    return null;
}
 
Example 57
Project: pnc-repressurized   File: ProgWidget.java   Source Code and License 4 votes vote down vote up
@Override
public EntityAIBase getWidgetAI(IDroneBase drone, IProgWidget widget) {
    return null;
}
 
Example 58
Project: pnc-repressurized   File: ProgWidgetCondition.java   Source Code and License 4 votes vote down vote up
@Override
public EntityAIBase getWidgetAI(IDroneBase drone, IProgWidget widget) {
    evaluator = getEvaluator(drone, widget);
    return evaluator;
}
 
Example 59
Project: pnc-repressurized   File: ProgWidgetForEachCoordinate.java   Source Code and License 4 votes vote down vote up
@Override
public EntityAIBase getWidgetAI(IDroneBase drone, IProgWidget widget) {
    return ai = new DroneAIForEachCoordinate(drone, (ProgWidgetForEachCoordinate) widget);
}
 
Example 60
Project: pnc-repressurized   File: ProgWidgetSuicide.java   Source Code and License 4 votes vote down vote up
@Override
public EntityAIBase getWidgetAI(IDroneBase drone, IProgWidget widget) {
    return new DroneAISuicide((EntityDrone) drone);
}