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(); } } }
private boolean func_75775_b(EntityAITaskEntry p_75775_1_) { this.field_75781_c.func_76320_a("canUse"); Iterator var2 = this.field_75782_a.iterator(); while(var2.hasNext()) { EntityAITaskEntry var3 = (EntityAITaskEntry)var2.next(); if(var3 != p_75775_1_) { if(p_75775_1_.field_75731_b >= var3.field_75731_b) { if(this.field_75780_b.contains(var3) && !this.func_75777_a(p_75775_1_, var3)) { this.field_75781_c.func_76319_b(); return false; } } else if(this.field_75780_b.contains(var3) && !var3.field_75733_a.func_75252_g()) { this.field_75781_c.func_76319_b(); return false; } } } this.field_75781_c.func_76319_b(); return true; }
/** * 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); }
public static void rewriteAnimalAIs(World w) { List allEntities = w.loadedEntityList; for (Object o : allEntities) { if (o instanceof EntityCow || o instanceof EntitySheep || o instanceof EntityPig || o instanceof EntityChicken) { EntityAnimal animal = (EntityAnimal) o; boolean hasFeedingAI = false; for (Object o2 : animal.tasks.taskEntries) { EntityAITaskEntry taskEntry = (EntityAITaskEntry) o2; if (taskEntry.action instanceof EntityAIFeeding) hasFeedingAI = true; } if (!hasFeedingAI) { EntityAICoward cowardAI = new EntityAICoward(animal, 2.0F); insertAI(animal, 2, cowardAI); EntityAISleepAtNight sleepAI = new EntityAISleepAtNight(animal); insertAI(animal, 3, sleepAI); float foodPerEating = 1.0F; if (animal instanceof EntityChicken) foodPerEating = 2.0F; EntityAIFeeding ai = new EntityAIFeeding(animal, 0.75f, foodPerEating); ai.addFoodtype(Block.tallGrass.blockID); ai.addFoodtype(Block.crops.blockID); if (o instanceof EntityCow) { for (int i = 0; i < 4096; i++) if (Block.blocksList[i] != null && Block.blocksList[i] instanceof BlockFlower) ai.addFoodtype(i); // ai.addFoodtype(Block.plantYellow.blockID); // ai.addFoodtype(Block.plantRed.blockID); } if (o instanceof EntitySheep) { ai.addFoodtype(Block.sapling.blockID); } if(o instanceof EntityCow || o instanceof EntityPig || o instanceof EntitySheep) ai.addFoodtype(Item.appleRed.itemID); if (o instanceof EntityCow || o instanceof EntitySheep || o instanceof EntityPig) ai.addFoodtype(Item.wheat.itemID); if (o instanceof EntityChicken) ai.addFoodtype(Item.seeds.itemID); if (o instanceof EntityPig) { /* This may make it very hard to find carrots/potatoes... have to test it */ ai.addFoodtype(Block.carrot.blockID); ai.addFoodtype(Block.potato.blockID); } insertAI(animal, 4, ai); EntityAIHerd herdAi = new EntityAIHerd(animal, 1.0F); insertAI(animal, 5, herdAi); } } } }
public void func_75776_a(int p_75776_1_, EntityAIBase p_75776_2_) { this.field_75782_a.add(new EntityAITaskEntry(this, p_75776_1_, p_75776_2_)); }
private boolean func_75773_a(EntityAITaskEntry p_75773_1_) { this.field_75781_c.func_76320_a("canContinue"); boolean var2 = p_75773_1_.field_75733_a.func_75253_b(); this.field_75781_c.func_76319_b(); return var2; }
private boolean func_75777_a(EntityAITaskEntry p_75777_1_, EntityAITaskEntry p_75777_2_) { return (p_75777_1_.field_75733_a.func_75247_h() & p_75777_2_.field_75733_a.func_75247_h()) == 0; }