Java 类net.minecraft.entity.ai.EntityAIBase 实例源码

项目:pnc-repressurized    文件:DroneAIManager.java   
/**
 * 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();
        }
    }
}
项目:LightningCraft    文件:EntityUnderworldGhast.java   
@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.");
    }
}
项目:CustomAI    文件:GuiCustomAI.java   
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]);
}
项目:CustomAI    文件:GuiAIEmitter.java   
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]);
}
项目:CustomAI    文件:EntityAIFactory.java   
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;
}
项目:enderutilities    文件:EntityUtils.java   
/**
 * 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);
    }
}
项目:RuneCraftery    文件:EntityAITasks.java   
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();
      }
   }

}
项目:PneumaticCraft    文件:DroneAIManager.java   
/**
 * 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();
        }
    }
}
项目:pnc-repressurized    文件:ProgWidgetEntityRightClick.java   
@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.
        }

    };
}
项目:pnc-repressurized    文件:ProgWidgetDroneEvaluation.java   
@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;
            }
        };
    }
}
项目:ObsidianSuite    文件:ObsidianAPIUtil.java   
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;
}
项目:Factorization    文件:BuffNametags.java   
@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;
        }
    });
}
项目:NeptuneMod    文件:MixinEntityAITasks.java   
@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());
}
项目:RidiculousWorld    文件:EntityPeep.java   
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));
}
项目:CustomAI    文件:CustomAIHelper.java   
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;
}
项目:CustomAI    文件:CustomAIHelper.java   
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;
}
项目:CustomAI    文件:CustomAIHelper.java   
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);
}
项目:CustomAI    文件:CustomAIHelper.java   
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;
}
项目:CustomAI    文件:CustomAIHelper.java   
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;
}
项目:CustomAI    文件:EntityCustomAIAddedWorker.java   
@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;
}
项目:CustomAI    文件:EntityCustomAIAddedWorker.java   
@Override
public boolean isSuitableForEntity(EntityLiving living,
        Class<? extends EntityAIBase> clazz)
{
    if(clazz == EntityAIFleeSunEvenNotBurning.class && ! (living instanceof EntityCreature))
        return false;
    return true;
}
项目:CustomAI    文件:EntityAIFactory.java   
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();
}
项目:CustomAI    文件:EntityAIFactory.java   
public JSONObject createDefaultJSON(Class<? extends EntityAIBase> clazz)
{
    EntityAIWorker worker = getWorkerFromClass(clazz);
    if(worker != null)
    {
        return worker.createDefaultJSON(clazz);
    }
    return new JSONObject();
}
项目:AdventureBackpack2    文件:BackpackAbilities.java   
/**
 * 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();
}
项目:FysiksFun    文件:AnimalAIRewriter.java   
/**
 * 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);
}
项目:RideableCows    文件:CommonProxy.java   
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;
}
项目:RideableCows    文件:CommonProxy.java   
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;
}
项目:PneumaticCraft    文件:ProgWidgetEntityRightClick.java   
@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.
        }

    };
}
项目:PneumaticCraft    文件:ProgWidgetDroneEvaluation.java   
@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;
            }
        };
    }
}
项目:EnderIO    文件:AIAttractionHandler.java   
@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()));
}
项目:EnderIO    文件:AIAttractionHandler.java   
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;
}
项目:EnderIO    文件:AIAttractionHandler.java   
@Override
public void release(TileAttractor attractor, EntityLiving entity) {
  EntityAIBase remove = findAITask(attractor, entity);
  if (remove != null) {
    entity.tasks.removeTask(remove);
    cancelCurrentTasks(entity);
  }
}
项目:pnc-repressurized    文件:EntityDrone.java   
public EntityAIBase getRunningTargetAI() {
    return aiManager.getTargetAI();
}
项目:pnc-repressurized    文件:DroneAICC.java   
public synchronized void setAction(IProgWidget widget, EntityAIBase ai) throws IllegalArgumentException {
    curAction = ai;
    newAction = true;
    curActionActive = true;
}
项目:pnc-repressurized    文件:ProgWidgetCC.java   
@Override
public EntityAIBase getWidgetAI(IDroneBase drone, IProgWidget widget) {
    return new DroneAICC((EntityDrone) drone, (ProgWidgetCC) widget, false);
}
项目:pnc-repressurized    文件:ProgWidgetCC.java   
@Override
public EntityAIBase getWidgetTargetAI(IDroneBase drone, IProgWidget widget) {
    return new DroneAICC((EntityDrone) drone, (ProgWidgetCC) widget, true);
}
项目:pnc-repressurized    文件:DroneAIManager.java   
public EntityAIBase getCurrentAI() {
    return curWidgetAI;
}
项目:pnc-repressurized    文件:DroneAIManager.java   
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;
}
项目:pnc-repressurized    文件:DroneAIManager.java   
public EntityAIBase getTargetAI() {
    return curWidgetTargetAI;
}
项目:pnc-repressurized    文件:DroneAIManager.java   
/**
 * START EntityAITasks code
 */

public void addTask(int par1, EntityAIBase par2EntityAIBase) {
    taskEntries.add(new EntityAITaskEntry(par1, par2EntityAIBase));
}