Example #1
0
 public void getEntitiesOfTypeWithinAAAB(Class class1, AxisAlignedBB axisalignedbb, List list) {
   int i = MathHelper.floor_double((axisalignedbb.minY - 2D) / 16D);
   int j = MathHelper.floor_double((axisalignedbb.maxY + 2D) / 16D);
   if (i < 0) {
     i = 0;
   }
   if (j >= entities.length) {
     j = entities.length - 1;
   }
   for (int k = i; k <= j; k++) {
     List list1 = entities[k];
     for (int l = 0; l < list1.size(); l++) {
       Entity entity = (Entity) list1.get(l);
       if (class1.isAssignableFrom(entity.getClass())
           && entity.boundingBox.intersectsWith(axisalignedbb)) {
         list.add(entity);
       }
     }
   }
 }
Example #2
0
 public void func_1013_a(Class class1, AxisAlignedBB axisalignedbb, List list) {
   int i = MathHelper.func_1108_b((axisalignedbb.field_1697_b - 2D) / 16D);
   int j = MathHelper.func_1108_b((axisalignedbb.field_1702_e + 2D) / 16D);
   if (i < 0) {
     i = 0;
   } else if (i >= field_1528_m.length) {
     i = field_1528_m.length - 1;
   }
   if (j >= field_1528_m.length) {
     j = field_1528_m.length - 1;
   } else if (j < 0) {
     j = 0;
   }
   for (int k = i; k <= j; k++) {
     List list1 = field_1528_m[k];
     for (int l = 0; l < list1.size(); l++) {
       Entity entity = (Entity) list1.get(l);
       if (class1.isAssignableFrom(entity.getClass())
           && entity.field_601_au.func_1178_a(axisalignedbb)) {
         list.add(entity);
       }
     }
   }
 }
  /**
   * Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses
   * this to count ticks and creates a new spawn inside its implementation.
   */
  public void updateEntity() {
    if (!anyPlayerInRange()) {
      return;
    }

    if (worldObj.isRemote) {
      double d = (float) xCoord + worldObj.rand.nextFloat();
      double d1 = (float) yCoord + worldObj.rand.nextFloat();
      double d3 = (float) zCoord + worldObj.rand.nextFloat();
      worldObj.spawnParticle("smoke", d, d1, d3, 0.0D, 0.0D, 0.0D);
      worldObj.spawnParticle("flame", d, d1, d3, 0.0D, 0.0D, 0.0D);
      yaw2 = yaw % 360D;
      yaw += 4.5454545021057129D;
    } else {
      if (delay == -1) {
        updateDelay();
      }

      if (delay > 0) {
        delay--;
        return;
      }

      for (int i = 0; i < field_70395_h; i++) {
        Entity entity = EntityList.createEntityByName(mobID, worldObj);

        if (entity == null) {
          return;
        }

        int j =
            worldObj
                .getEntitiesWithinAABB(
                    entity.getClass(),
                    AxisAlignedBB.getAABBPool()
                        .addOrModifyAABBInPool(
                            xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)
                        .expand(8D, 4D, 8D))
                .size();

        if (j >= 6) {
          updateDelay();
          return;
        }

        if (entity == null) {
          continue;
        }

        double d2 =
            (double) xCoord + (worldObj.rand.nextDouble() - worldObj.rand.nextDouble()) * 4D;
        double d4 = (yCoord + worldObj.rand.nextInt(3)) - 1;
        double d5 =
            (double) zCoord + (worldObj.rand.nextDouble() - worldObj.rand.nextDouble()) * 4D;
        EntityLiving entityliving = (entity instanceof EntityLiving) ? (EntityLiving) entity : null;
        entity.setLocationAndAngles(d2, d4, d5, worldObj.rand.nextFloat() * 360F, 0.0F);

        if (entityliving != null && !entityliving.getCanSpawnHere()) {
          continue;
        }

        func_70383_a(entity);
        worldObj.spawnEntityInWorld(entity);
        worldObj.playAuxSFX(2004, xCoord, yCoord, zCoord, 0);

        if (entityliving != null) {
          entityliving.spawnExplosionParticle();
        }

        updateDelay();
      }
    }

    super.updateEntity();
  }