Exemple #1
0
  private void func_40144_b(EntityAnimal entityanimal) {
    EntityAnimal entityanimal1 = func_40145_a(entityanimal);
    if (entityanimal1 != null) {
      func_40142_a_(6000);
      entityanimal.func_40142_a_(6000);
      field_39004_a = 0;
      field_39005_b = 0;
      entityToAttack = null;
      entityanimal.entityToAttack = null;
      entityanimal.field_39005_b = 0;
      entityanimal.field_39004_a = 0;
      entityanimal1.func_40142_a_(-24000);
      entityanimal1.setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch);
      for (int i = 0; i < 7; i++) {
        double d = rand.nextGaussian() * 0.02D;
        double d1 = rand.nextGaussian() * 0.02D;
        double d2 = rand.nextGaussian() * 0.02D;
        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,
            d,
            d1,
            d2);
      }

      worldObj.entityJoinedWorld(entityanimal1);
    }
  }
Exemple #2
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;
     }
   }
 }