public boolean canEntityBeSeen(Entity entity) {
   return worldObj.rayTraceBlocks(
           Vec3D.createVector(posX, posY + (double) getEyeHeight(), posZ),
           Vec3D.createVector(
               entity.posX, entity.posY + (double) entity.getEyeHeight(), entity.posZ))
       == null;
 }
 // through doors at eye height
 public boolean canEntityBeSeen3(Entity entity) {
   return worldObj.rayTraceBlocks_do(
           Vec3D.createVector(posX, posY - yOffset + (double) getEyeHeight(), posZ),
           Vec3D.createVector(
               entity.posX,
               entity.posY - entity.yOffset + (double) entity.getEyeHeight(),
               entity.posZ),
           false)
       == null;
 }
 /** Updates the task */
 public void updateTask() {
   theWatcher
       .getLookHelper()
       .setLookPosition(
           closestEntity.posX,
           closestEntity.posY + (double) closestEntity.getEyeHeight(),
           closestEntity.posZ,
           10F,
           theWatcher.getVerticalFaceSpeed());
   lookTime--;
 }
Exemplo n.º 4
0
  protected void attackEntity(Entity var1, float var2) {
    if (var2 < 10.0F) {
      double var3 = var1.posX - this.posX;
      double var5 = var1.posZ - this.posZ;
      if (this.attackTime == 0) {
        EntityArrow var7 = new EntityArrow(this.worldObj, this, 1.0F);
        double var8 = var1.posY + (double) var1.getEyeHeight() - 0.699999988079071D - var7.posY;
        float var10 = MathHelper.sqrt_double(var3 * var3 + var5 * var5) * 0.2F;
        this.worldObj.playSoundAtEntity(
            this, "random.bow", 1.0F, 1.0F / (this.rand.nextFloat() * 0.4F + 0.8F));
        this.worldObj.entityJoinedWorld(var7);
        var7.setArrowHeading(var3, var8 + (double) var10, var5, 1.6F, 12.0F);
        this.attackTime = 60;
      }

      this.rotationYaw = (float) (Math.atan2(var5, var3) * 180.0D / 3.1415927410125732D) - 90.0F;
      this.hasAttacked = true;
    }
  }
Exemplo n.º 5
0
 protected void attackEntity(Entity entity, float f) {
   if (!fixai) {
     super.attackEntity(entity, f);
   }
   if (f < 10F) {
     double d = entity.posX - posX;
     double d1 = entity.posZ - posZ;
     if (attackTime == 0) {
       EntitySnowball entitysnowball = new EntitySnowball(worldObj, this);
       double d2 =
           (entity.posY + (double) entity.getEyeHeight())
               - 1.1000000238418579D
               - entitysnowball.posY;
       float f1 = MathHelper.sqrt_double(d * d + d1 * d1) * 0.2F;
       worldObj.playSoundAtEntity(
           this, "random.bow", 1.0F, 1.0F / (rand.nextFloat() * 0.4F + 0.8F));
       worldObj.spawnEntityInWorld(entitysnowball);
       entitysnowball.setThrowableHeading(d, d2 + (double) f1, d1, 1.6F, 12F);
       attackTime = 10;
     }
     rotationYaw = (float) ((Math.atan2(d1, d) * 180D) / 3.1415927410125732D) - 90F;
     hasAttacked = true;
   }
 }
Exemplo n.º 6
0
  /** Does the first part of the explosion (destroy blocks) */
  public void doExplosionA() {
    float var1 = this.explosionSize;
    HashSet var2 = new HashSet();
    int var3;
    int var4;
    int var5;
    double var15;
    double var17;
    double var19;

    for (var3 = 0; var3 < this.field_77289_h; ++var3) {
      for (var4 = 0; var4 < this.field_77289_h; ++var4) {
        for (var5 = 0; var5 < this.field_77289_h; ++var5) {
          if (var3 == 0
              || var3 == this.field_77289_h - 1
              || var4 == 0
              || var4 == this.field_77289_h - 1
              || var5 == 0
              || var5 == this.field_77289_h - 1) {
            double var6 =
                (double) ((float) var3 / ((float) this.field_77289_h - 1.0F) * 2.0F - 1.0F);
            double var8 =
                (double) ((float) var4 / ((float) this.field_77289_h - 1.0F) * 2.0F - 1.0F);
            double var10 =
                (double) ((float) var5 / ((float) this.field_77289_h - 1.0F) * 2.0F - 1.0F);
            double var12 = Math.sqrt(var6 * var6 + var8 * var8 + var10 * var10);
            var6 /= var12;
            var8 /= var12;
            var10 /= var12;
            float var14 = this.explosionSize * (0.7F + this.worldObj.rand.nextFloat() * 0.6F);
            var15 = this.explosionX;
            var17 = this.explosionY;
            var19 = this.explosionZ;

            for (float var21 = 0.3F; var14 > 0.0F; var14 -= var21 * 0.75F) {
              int var22 = MathHelper.floor_double(var15);
              int var23 = MathHelper.floor_double(var17);
              int var24 = MathHelper.floor_double(var19);
              int var25 = this.worldObj.getBlockId(var22, var23, var24);

              if (var25 > 0) {
                Block var26 = Block.blocksList[var25];
                float var27 =
                    this.exploder != null
                        ? this.exploder.func_82146_a(this, var26, var22, var23, var24)
                        : var26.getExplosionResistance(this.exploder);
                var14 -= (var27 + 0.3F) * var21;
              }

              if (var14 > 0.0F) {
                var2.add(new ChunkPosition(var22, var23, var24));
              }

              var15 += var6 * (double) var21;
              var17 += var8 * (double) var21;
              var19 += var10 * (double) var21;
            }
          }
        }
      }
    }

    this.affectedBlockPositions.addAll(var2);
    this.explosionSize *= 2.0F;
    var3 = MathHelper.floor_double(this.explosionX - (double) this.explosionSize - 1.0D);
    var4 = MathHelper.floor_double(this.explosionX + (double) this.explosionSize + 1.0D);
    var5 = MathHelper.floor_double(this.explosionY - (double) this.explosionSize - 1.0D);
    int var28 = MathHelper.floor_double(this.explosionY + (double) this.explosionSize + 1.0D);
    int var7 = MathHelper.floor_double(this.explosionZ - (double) this.explosionSize - 1.0D);
    int var29 = MathHelper.floor_double(this.explosionZ + (double) this.explosionSize + 1.0D);
    List var9 =
        this.worldObj.getEntitiesWithinAABBExcludingEntity(
            this.exploder,
            AxisAlignedBB.getAABBPool()
                .addOrModifyAABBInPool(
                    (double) var3,
                    (double) var5,
                    (double) var7,
                    (double) var4,
                    (double) var28,
                    (double) var29));
    Vec3 var30 =
        this.worldObj
            .getWorldVec3Pool()
            .getVecFromPool(this.explosionX, this.explosionY, this.explosionZ);

    for (int var11 = 0; var11 < var9.size(); ++var11) {
      Entity var31 = (Entity) var9.get(var11);
      double var13 =
          var31.getDistance(this.explosionX, this.explosionY, this.explosionZ)
              / (double) this.explosionSize;

      if (var13 <= 1.0D) {
        var15 = var31.posX - this.explosionX;
        var17 = var31.posY + (double) var31.getEyeHeight() - this.explosionY;
        var19 = var31.posZ - this.explosionZ;
        double var33 =
            (double) MathHelper.sqrt_double(var15 * var15 + var17 * var17 + var19 * var19);

        if (var33 != 0.0D) {
          var15 /= var33;
          var17 /= var33;
          var19 /= var33;
          double var32 = (double) this.worldObj.getBlockDensity(var30, var31.boundingBox);
          double var34 = (1.0D - var13) * var32;
          var31.attackEntityFrom(
              DamageSource.explosion,
              (int) ((var34 * var34 + var34) / 2.0D * 8.0D * (double) this.explosionSize + 1.0D));
          var31.motionX += var15 * var34;
          var31.motionY += var17 * var34;
          var31.motionZ += var19 * var34;

          if (var31 instanceof EntityPlayer) {
            this.field_77288_k.put(
                (EntityPlayer) var31,
                this.worldObj
                    .getWorldVec3Pool()
                    .getVecFromPool(var15 * var34, var17 * var34, var19 * var34));
          }
        }
      }
    }

    this.explosionSize = var1;
  }