Exemplo n.º 1
0
 protected void attackEntity(Entity entity, float f) {
   if (entity instanceof EntityPlayer) {
     if (f < 3F) {
       double d = entity.posX - posX;
       double d1 = entity.posZ - posZ;
       rotationYaw = (float) ((Math.atan2(d1, d) * 180D) / 3.1415927410125732D) - 90F;
       hasAttacked = true;
     }
     EntityPlayer entityplayer = (EntityPlayer) entity;
     if (entityplayer.getCurrentEquippedItem() == null
         || !func_40143_a(entityplayer.getCurrentEquippedItem())) {
       entityToAttack = null;
     }
   } else if (entity instanceof EntityAnimal) {
     EntityAnimal entityanimal = (EntityAnimal) entity;
     if (func_40146_g() > 0 && entityanimal.func_40146_g() < 0) {
       if ((double) f < 2.5D) {
         hasAttacked = true;
       }
     } else if (field_39004_a > 0 && entityanimal.field_39004_a > 0) {
       if (entityanimal.entityToAttack == null) {
         entityanimal.entityToAttack = this;
       }
       if (entityanimal.entityToAttack == this && (double) f < 3.5D) {
         entityanimal.field_39004_a++;
         field_39004_a++;
         field_39005_b++;
         if (field_39005_b % 4 == 0) {
           worldObj.spawnParticle(
               "heart",
               (posX + (double) (rand.nextFloat() * width * 2.0F)) - (double) width,
               posY + 0.5D + (double) (rand.nextFloat() * height),
               (posZ + (double) (rand.nextFloat() * width * 2.0F)) - (double) width,
               0.0D,
               0.0D,
               0.0D);
         }
         if (field_39005_b == 60) {
           func_40144_b((EntityAnimal) entity);
         }
       } else {
         field_39005_b = 0;
       }
     } else {
       field_39005_b = 0;
     }
   }
 }
Exemplo n.º 2
0
  protected Entity findPlayerToAttack() {
    if (fleeingTick > 0) {
      return null;
    }
    float f = 8F;
    if (field_39004_a > 0) {
      List list = worldObj.getEntitiesWithinAABB(getClass(), boundingBox.addCoord(f, f, f));
      for (int i = 0; i < list.size(); i++) {
        EntityAnimal entityanimal = (EntityAnimal) list.get(i);
        if (entityanimal != this && entityanimal.field_39004_a > 0) {
          return entityanimal;
        }
      }

    } else if (func_40146_g() == 0) {
      List list1 =
          worldObj.getEntitiesWithinAABB(
              net.minecraft.src.EntityPlayer.class, boundingBox.addCoord(f, f, f));
      for (int j = 0; j < list1.size(); j++) {
        EntityPlayer entityplayer = (EntityPlayer) list1.get(j);
        if (entityplayer.getCurrentEquippedItem() != null
            && func_40143_a(entityplayer.getCurrentEquippedItem())) {
          return entityplayer;
        }
      }

    } else if (func_40146_g() > 0) {
      List list2 = worldObj.getEntitiesWithinAABB(getClass(), boundingBox.addCoord(f, f, f));
      for (int k = 0; k < list2.size(); k++) {
        EntityAnimal entityanimal1 = (EntityAnimal) list2.get(k);
        if (entityanimal1 != this && entityanimal1.func_40146_g() < 0) {
          return entityanimal1;
        }
      }
    }
    return null;
  }