Exemplo n.º 1
0
 public EntityFireball(
     World par1World, EntityLiving par2EntityLiving, double par3, double par5, double par7) {
   super(par1World);
   xTile = -1;
   yTile = -1;
   zTile = -1;
   inTile = 0;
   inGround = false;
   ticksInAir = 0;
   shootingEntity = par2EntityLiving;
   setSize(1.0F, 1.0F);
   setLocationAndAngles(
       par2EntityLiving.posX,
       par2EntityLiving.posY,
       par2EntityLiving.posZ,
       par2EntityLiving.rotationYaw,
       par2EntityLiving.rotationPitch);
   setPosition(posX, posY, posZ);
   yOffset = 0.0F;
   motionX = motionY = motionZ = 0.0D;
   par3 += rand.nextGaussian() * 0.40000000000000002D;
   par5 += rand.nextGaussian() * 0.40000000000000002D;
   par7 += rand.nextGaussian() * 0.40000000000000002D;
   double d = MathHelper.sqrt_double(par3 * par3 + par5 * par5 + par7 * par7);
   accelerationX = (par3 / d) * 0.10000000000000001D;
   accelerationY = (par5 / d) * 0.10000000000000001D;
   accelerationZ = (par7 / d) * 0.10000000000000001D;
 }
Exemplo n.º 2
0
 private void addMountedMovementStat(double d, double d1, double d2) {
   if (ridingEntity != null) {
     int i = Math.round(MathHelper.sqrt_double(d * d + d1 * d1 + d2 * d2) * 100F);
     if (i > 0) {
       if (ridingEntity instanceof EntityMinecart) {
         addStat(StatList.distanceByMinecartStat, i);
         if (startMinecartRidingCoordinate == null) {
           startMinecartRidingCoordinate =
               new ChunkCoordinates(
                   MathHelper.floor_double(posX),
                   MathHelper.floor_double(posY),
                   MathHelper.floor_double(posZ));
         } else if (startMinecartRidingCoordinate.getSqDistanceTo(
                 MathHelper.floor_double(posX),
                 MathHelper.floor_double(posY),
                 MathHelper.floor_double(posZ))
             >= 1000D) {
           addStat(AchievementList.onARail, 1);
         }
       } else if (ridingEntity instanceof EntityBoat) {
         addStat(StatList.distanceByBoatStat, i);
       } else if (ridingEntity instanceof EntityPig) {
         addStat(StatList.distanceByPigStat, i);
       }
     }
   }
 }
Exemplo n.º 3
0
  /** Adds a value to a mounted movement statistic field - by minecart, boat, or pig. */
  private void addMountedMovementStat(double par1, double par3, double par5) {
    if (this.ridingEntity != null) {
      int var7 =
          Math.round(MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5) * 100.0F);

      if (var7 > 0) {
        if (this.ridingEntity instanceof EntityMinecart) {
          this.addStat(StatList.distanceByMinecartStat, var7);

          if (this.startMinecartRidingCoordinate == null) {
            this.startMinecartRidingCoordinate =
                new ChunkCoordinates(
                    MathHelper.floor_double(this.posX),
                    MathHelper.floor_double(this.posY),
                    MathHelper.floor_double(this.posZ));
          } else if (this.startMinecartRidingCoordinate.getEuclideanDistanceTo(
                  MathHelper.floor_double(this.posX),
                  MathHelper.floor_double(this.posY),
                  MathHelper.floor_double(this.posZ))
              >= 1000.0D) {
            this.addStat(AchievementList.onARail, 1);
          }
        } else if (this.ridingEntity instanceof EntityBoat) {
          this.addStat(StatList.distanceByBoatStat, var7);
        } else if (this.ridingEntity instanceof EntityPig) {
          this.addStat(StatList.distanceByPigStat, var7);
        }
      }
    }
  }
Exemplo n.º 4
0
  /** Applies a velocity to each of the entities pushing them away from each other. Args: entity */
  public void applyEntityCollision(Entity par1Entity) {
    if (par1Entity.riddenByEntity == this || par1Entity.ridingEntity == this) {
      return;
    }

    double d = par1Entity.posX - posX;
    double d1 = par1Entity.posZ - posZ;
    double d2 = MathHelper.abs_max(d, d1);

    if (d2 >= 0.01D) {
      d2 = MathHelper.sqrt_double(d2);
      d /= d2;
      d1 /= d2;
      double d3 = 1.0D / d2;

      if (d3 > 1.0D) {
        d3 = 1.0D;
      }

      d *= d3;
      d1 *= d3;
      d *= 0.05D;
      d1 *= 0.05D;
      d *= 1.0F - entityCollisionReduction;
      d1 *= 1.0F - entityCollisionReduction;
      addVelocity(-d, 0.0D, -d1);
      par1Entity.addVelocity(d, 0.0D, d1);
    }
  }
  /** Called to update the entity's position/logic. */
  public void onUpdate() {
    this.field_71082_cx = 0.0F;
    super.onUpdate();
    this.prevLegYaw = this.legYaw;
    double var1 = this.posX - this.prevPosX;
    double var3 = this.posZ - this.prevPosZ;
    float var5 = MathHelper.sqrt_double(var1 * var1 + var3 * var3) * 4.0F;

    if (var5 > 1.0F) {
      var5 = 1.0F;
    }

    this.legYaw += (var5 - this.legYaw) * 0.4F;
    this.legSwing += this.legYaw;

    if (!this.isItemInUse
        && this.isEating()
        && this.inventory.mainInventory[this.inventory.currentItem] != null) {
      ItemStack var6 = this.inventory.mainInventory[this.inventory.currentItem];
      this.setItemInUse(
          this.inventory.mainInventory[this.inventory.currentItem],
          Item.itemsList[var6.itemID].getMaxItemUseDuration(var6));
      this.isItemInUse = true;
    } else if (this.isItemInUse && !this.isEating()) {
      this.clearItemInUse();
      this.isItemInUse = false;
    }
  }
  /**
   * Called frequently so the entity can update its state every tick as required. For example,
   * zombies and skeletons use this to react to sunlight and start to burn.
   */
  public void onLivingUpdate() {
    super.updateEntityActionState();

    if (this.otherPlayerMPPosRotationIncrements > 0) {
      double var1 =
          this.posX
              + (this.otherPlayerMPX - this.posX)
                  / (double) this.otherPlayerMPPosRotationIncrements;
      double var3 =
          this.posY
              + (this.otherPlayerMPY - this.posY)
                  / (double) this.otherPlayerMPPosRotationIncrements;
      double var5 =
          this.posZ
              + (this.otherPlayerMPZ - this.posZ)
                  / (double) this.otherPlayerMPPosRotationIncrements;
      double var7;

      for (var7 = this.otherPlayerMPYaw - (double) this.rotationYaw;
          var7 < -180.0D;
          var7 += 360.0D) {;
      }

      while (var7 >= 180.0D) {
        var7 -= 360.0D;
      }

      this.rotationYaw =
          (float)
              ((double) this.rotationYaw + var7 / (double) this.otherPlayerMPPosRotationIncrements);
      this.rotationPitch =
          (float)
              ((double) this.rotationPitch
                  + (this.otherPlayerMPPitch - (double) this.rotationPitch)
                      / (double) this.otherPlayerMPPosRotationIncrements);
      --this.otherPlayerMPPosRotationIncrements;
      this.setPosition(var1, var3, var5);
      this.setRotation(this.rotationYaw, this.rotationPitch);
    }

    this.prevCameraYaw = this.cameraYaw;
    float var9 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
    float var2 = (float) Math.atan(-this.motionY * 0.20000000298023224D) * 15.0F;

    if (var9 > 0.1F) {
      var9 = 0.1F;
    }

    if (!this.onGround || this.getHealth() <= 0) {
      var9 = 0.0F;
    }

    if (this.onGround || this.getHealth() <= 0) {
      var2 = 0.0F;
    }

    this.cameraYaw += (var9 - this.cameraYaw) * 0.4F;
    this.cameraPitch += (var2 - this.cameraPitch) * 0.8F;
  }
Exemplo n.º 7
0
  /**
   * Called frequently so the entity can update its state every tick as required. For example,
   * zombies and skeletons use this to react to sunlight and start to burn.
   */
  public void onLivingUpdate() {
    if (this.flyToggleTimer > 0) {
      --this.flyToggleTimer;
    }

    if (this.worldObj.difficultySetting == 0
        && this.getHealth() < this.getMaxHealth()
        && this.ticksExisted % 20 * 12 == 0) {
      this.heal(1);
    }

    this.inventory.decrementAnimations();
    this.prevCameraYaw = this.cameraYaw;
    super.onLivingUpdate();
    this.landMovementFactor = this.speedOnGround;
    this.jumpMovementFactor = this.speedInAir;

    if (this.isSprinting()) {
      this.landMovementFactor =
          (float) ((double) this.landMovementFactor + (double) this.speedOnGround * 0.3D);
      this.jumpMovementFactor =
          (float) ((double) this.jumpMovementFactor + (double) this.speedInAir * 0.3D);
    }

    float var1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
    float var2 = (float) Math.atan(-this.motionY * 0.20000000298023224D) * 15.0F;

    if (var1 > 0.1F) {
      var1 = 0.1F;
    }

    if (!this.onGround || this.getHealth() <= 0) {
      var1 = 0.0F;
    }

    if (this.onGround || this.getHealth() <= 0) {
      var2 = 0.0F;
    }

    this.cameraYaw += (var1 - this.cameraYaw) * 0.4F;
    this.cameraPitch += (var2 - this.cameraPitch) * 0.8F;

    if (this.getHealth() > 0) {
      List var3 =
          this.worldObj.getEntitiesWithinAABBExcludingEntity(
              this, this.boundingBox.expand(1.0D, 0.0D, 1.0D));

      if (var3 != null) {
        for (int var4 = 0; var4 < var3.size(); ++var4) {
          Entity var5 = (Entity) var3.get(var4);

          if (!var5.isDead) {
            this.collideWithPlayer(var5);
          }
        }
      }
    }
  }
 /** Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction. */
 public void setThrowableHeading(double par1, double par3, double par5, float par7, float par8) {
   float f = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5);
   par1 /= f;
   par3 /= f;
   par5 /= f;
   par1 += rand.nextGaussian() * 0.0074999998323619366D * (double) par8;
   par3 += rand.nextGaussian() * 0.0074999998323619366D * (double) par8;
   par5 += rand.nextGaussian() * 0.0074999998323619366D * (double) par8;
   par1 *= par7;
   par3 *= par7;
   par5 *= par7;
   motionX = par1;
   motionY = par3;
   motionZ = par5;
   float f1 = MathHelper.sqrt_double(par1 * par1 + par5 * par5);
   prevRotationYaw = rotationYaw = (float) ((Math.atan2(par1, par5) * 180D) / Math.PI);
   prevRotationPitch = rotationPitch = (float) ((Math.atan2(par3, f1) * 180D) / Math.PI);
   ticksInGround = 0;
 }
Exemplo n.º 9
0
  /** Adds a value to a movement statistic field - like run, walk, swin or climb. */
  public void addMovementStat(double par1, double par3, double par5) {
    if (this.ridingEntity == null) {
      int var7;

      if (this.isInsideOfMaterial(Material.water)) {
        var7 = Math.round(MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5) * 100.0F);

        if (var7 > 0) {
          this.addStat(StatList.distanceDoveStat, var7);
          this.addExhaustion(0.015F * (float) var7 * 0.01F);
        }
      } else if (this.isInWater()) {
        var7 = Math.round(MathHelper.sqrt_double(par1 * par1 + par5 * par5) * 100.0F);

        if (var7 > 0) {
          this.addStat(StatList.distanceSwumStat, var7);
          this.addExhaustion(0.015F * (float) var7 * 0.01F);
        }
      } else if (this.isOnLadder()) {
        if (par3 > 0.0D) {
          this.addStat(StatList.distanceClimbedStat, (int) Math.round(par3 * 100.0D));
        }
      } else if (this.onGround) {
        var7 = Math.round(MathHelper.sqrt_double(par1 * par1 + par5 * par5) * 100.0F);

        if (var7 > 0) {
          this.addStat(StatList.distanceWalkedStat, var7);

          if (this.isSprinting()) {
            this.addExhaustion(0.099999994F * (float) var7 * 0.01F);
          } else {
            this.addExhaustion(0.01F * (float) var7 * 0.01F);
          }
        }
      } else {
        var7 = Math.round(MathHelper.sqrt_double(par1 * par1 + par5 * par5) * 100.0F);

        if (var7 > 25) {
          this.addStat(StatList.distanceFlownStat, var7);
        }
      }
    }
  }
 /** Execute a one shot task or start executing a continuous task */
 public void startExecuting() {
   double d = leapTarget.posX - leaper.posX;
   double d1 = leapTarget.posZ - leaper.posZ;
   float f = MathHelper.sqrt_double(d * d + d1 * d1);
   leaper.motionX +=
       (d / (double) f) * 0.5D * 0.80000001192092896D + leaper.motionX * 0.20000000298023224D;
   leaper.motionZ +=
       (d1 / (double) f) * 0.5D * 0.80000001192092896D + leaper.motionZ * 0.20000000298023224D;
   leaper.motionY = leapMotionY;
 }
Exemplo n.º 11
0
 public void setVelocity(double d, double d1, double d2) {
   motionX = d;
   motionY = d1;
   motionZ = d2;
   if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) {
     float f = MathHelper.sqrt_double(d * d + d2 * d2);
     prevRotationYaw = rotationYaw = (float) ((Math.atan2(d, d2) * 180D) / 3.1415927410125732D);
     prevRotationPitch =
         rotationPitch = (float) ((Math.atan2(d1, f) * 180D) / 3.1415927410125732D);
   }
 }
Exemplo n.º 12
0
 public void setArrowHeading(double par1, double par3, double par5, float par7) {
   float var9 = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5);
   par1 /= (double) var9;
   par3 /= (double) var9;
   par5 /= (double) var9;
   par1 += this.rand.nextGaussian() * 0.007499999832361937D * (double) 0;
   par3 += this.rand.nextGaussian() * 0.007499999832361937D * (double) 0;
   par5 += this.rand.nextGaussian() * 0.007499999832361937D * (double) 0;
   par1 *= (double) par7;
   par3 *= (double) par7;
   par5 *= (double) par7;
   this.motionX = par1;
   this.motionY = par3;
   this.motionZ = par5;
   float var10 = MathHelper.sqrt_double(par1 * par1 + par5 * par5);
   this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI);
   this.prevRotationPitch =
       this.rotationPitch = (float) (Math.atan2(par3, (double) var10) * 180.0D / Math.PI);
   this.ticksInGround = 0;
 }
  /** Sets the velocity to the args. Args: x, y, z */
  public void setVelocity(double par1, double par3, double par5) {
    motionX = par1;
    motionY = par3;
    motionZ = par5;

    if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) {
      float f = MathHelper.sqrt_double(par1 * par1 + par5 * par5);
      prevRotationYaw = rotationYaw = (float) ((Math.atan2(par1, par5) * 180D) / Math.PI);
      prevRotationPitch = rotationPitch = (float) ((Math.atan2(par3, f) * 180D) / Math.PI);
    }
  }
Exemplo n.º 14
0
  protected void attackEntity(Entity par1Entity, float par2) {
    if (onGround) {
      ((EntityLiving) par1Entity).addPotionEffect(new PotionEffect(Potion.poison.id, 100 * 10, 0));

      double d = par1Entity.posX - posX;
      double d1 = par1Entity.posZ - posZ;
      float f1 = MathHelper.sqrt_double(d * d + d1 * d1);
      motionX = (d / (double) f1) * 0.5D * 0.80000001192092896D + motionX * 0.20000000298023224D;
      motionZ = (d1 / (double) f1) * 0.5D * 0.80000001192092896D + motionZ * 0.20000000298023224D;
      motionY = 0.40000000596046448D;
    }
  }
 public void onUpdate() {
   decayFlash();
   super.onUpdate();
   onLivingUpdate();
   double d = posX - prevPosX;
   double d1 = posZ - prevPosZ;
   float f = MathHelper.sqrt_double(d * d + d1 * d1);
   float f1 = renderYawOffset;
   float f2 = 0.0F;
   field_9362_u = field_9361_v;
   float f3 = 0.0F;
   if (f > 0.05F) {
     f3 = 1.0F;
     f2 = f * 3F;
     f1 = ((float) Math.atan2(d1, d) * 180F) / 3.141593F - 90F;
   }
   if (swingProgress > 0.0F) {
     f1 = rotationYaw;
   }
   if (!onGround) {
     f3 = 0.0F;
   }
   field_9361_v = field_9361_v + (f3 - field_9361_v) * 0.3F;
   float f4;
   for (f4 = f1 - renderYawOffset; f4 < -180F; f4 += 360F) {}
   for (; f4 >= 180F; f4 -= 360F) {}
   renderYawOffset += f4 * 0.3F;
   float f5;
   for (f5 = rotationYaw - renderYawOffset; f5 < -180F; f5 += 360F) {}
   for (; f5 >= 180F; f5 -= 360F) {}
   boolean flag = f5 < -90F || f5 >= 90F;
   if (f5 < -75F) {
     f5 = -75F;
   }
   if (f5 >= 75F) {
     f5 = 75F;
   }
   renderYawOffset = rotationYaw - f5;
   if (f5 * f5 > 2500F) {
     renderYawOffset += f5 * 0.2F;
   }
   if (flag) {
     f2 *= -1F;
   }
   for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F) {}
   for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F) {}
   for (; renderYawOffset - prevRenderYawOffset < -180F; prevRenderYawOffset -= 360F) {}
   for (; renderYawOffset - prevRenderYawOffset >= 180F; prevRenderYawOffset += 360F) {}
   for (; rotationPitch - prevRotationPitch < -180F; prevRotationPitch -= 360F) {}
   for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F) {}
   field_9360_w += f2;
 }
 public void onLivingUpdate() {
   super.onLivingUpdate();
   field_21088_b = field_21089_a;
   field_21086_f = field_21087_c;
   field_21084_h = field_21085_g;
   lastTentacleAngle = tentacleAngle;
   field_21085_g += field_21080_l;
   if (field_21085_g > 6.283185F) {
     field_21085_g -= 6.283185F;
     if (rand.nextInt(10) == 0) {
       field_21080_l = (1.0F / (rand.nextFloat() + 1.0F)) * 0.2F;
     }
   }
   if (isInWater()) {
     if (field_21085_g < 3.141593F) {
       float f = field_21085_g / 3.141593F;
       tentacleAngle = MathHelper.sin(f * f * 3.141593F) * 3.141593F * 0.25F;
       if ((double) f > 0.75D) {
         randomMotionSpeed = 1.0F;
         field_21079_m = 1.0F;
       } else {
         field_21079_m = field_21079_m * 0.8F;
       }
     } else {
       tentacleAngle = 0.0F;
       randomMotionSpeed = randomMotionSpeed * 0.9F;
       field_21079_m = field_21079_m * 0.99F;
     }
     if (!worldObj.multiplayerWorld) {
       motionX = randomMotionVecX * randomMotionSpeed;
       motionY = randomMotionVecY * randomMotionSpeed;
       motionZ = randomMotionVecZ * randomMotionSpeed;
     }
     float f1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
     renderYawOffset +=
         ((-(float) Math.atan2(motionX, motionZ) * 180F) / 3.141593F - renderYawOffset) * 0.1F;
     rotationYaw = renderYawOffset;
     field_21087_c = field_21087_c + 3.141593F * field_21079_m * 1.5F;
     field_21089_a +=
         ((-(float) Math.atan2(f1, motionY) * 180F) / 3.141593F - field_21089_a) * 0.1F;
   } else {
     tentacleAngle = MathHelper.abs(MathHelper.sin(field_21085_g)) * 3.141593F * 0.25F;
     if (!worldObj.multiplayerWorld) {
       motionX = 0.0D;
       motionY -= 0.080000000000000002D;
       motionY *= 0.98000001907348633D;
       motionZ = 0.0D;
     }
     field_21089_a += (double) (-90F - field_21089_a) * 0.02D;
   }
 }
Exemplo n.º 17
0
  public int catchFish() {
    byte var1 = 0;

    if (this.bobber != null) {
      double var2 = this.angler.posX - this.posX;
      double var4 = this.angler.posY - this.posY;
      double var6 = this.angler.posZ - this.posZ;
      double var8 = (double) MathHelper.sqrt_double(var2 * var2 + var4 * var4 + var6 * var6);
      double var10 = 0.1D;
      this.bobber.motionX += var2 * var10;
      this.bobber.motionY += var4 * var10 + (double) MathHelper.sqrt_double(var8) * 0.08D;
      this.bobber.motionZ += var6 * var10;
      var1 = 3;
    } else if (this.ticksCatchable > 0) {
      EntityItem var13 =
          new EntityItem(
              this.worldObj, this.posX, this.posY, this.posZ, new ItemStack(Item.fishRaw));
      double var3 = this.angler.posX - this.posX;
      double var5 = this.angler.posY - this.posY;
      double var7 = this.angler.posZ - this.posZ;
      double var9 = (double) MathHelper.sqrt_double(var3 * var3 + var5 * var5 + var7 * var7);
      double var11 = 0.1D;
      var13.motionX = var3 * var11;
      var13.motionY = var5 * var11 + (double) MathHelper.sqrt_double(var9) * 0.08D;
      var13.motionZ = var7 * var11;
      this.worldObj.spawnEntityInWorld(var13);
      this.angler.addStat(StatList.fishCaughtStat, 1);
      var1 = 1;
    }

    if (this.inGround) {
      var1 = 2;
    }

    this.setDead();
    this.angler.fishEntity = null;
    return var1;
  }
  public void knockBack(Entity entity, int i, double d, double d1, float force) {

    float f = MathHelper.sqrt_double(d * d + d1 * d1);
    float f1 = force;
    motionX /= 2D;
    motionY /= 2D;
    motionZ /= 2D;
    motionX -= (d / (double) f) * (double) f1;
    motionY += 0.10000000596046448D;
    motionZ -= (d1 / (double) f) * (double) f1;
    if (motionY > 0.40000000596046448D) {
      motionY = 0.40000000596046448D;
    }
  }
 public void doEffects(boolean flag) {
   worldObj.playSoundEffect(
       explosionX,
       explosionY,
       explosionZ,
       "random.explode",
       4F,
       (1.0F + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F) * 0.7F);
   ArrayList arraylist = new ArrayList();
   arraylist.addAll(destroyedBlockPositions);
   for (int i = arraylist.size() - 1; i >= 0; i--) {
     ChunkPosition chunkposition = (ChunkPosition) arraylist.get(i);
     int j = chunkposition.x;
     int k = chunkposition.y;
     int l = chunkposition.z;
     int i1 = worldObj.getBlockId(j, k, l);
     if (flag) {
       double d = (float) j + worldObj.rand.nextFloat();
       double d1 = (float) k + worldObj.rand.nextFloat();
       double d2 = (float) l + worldObj.rand.nextFloat();
       double d3 = d - explosionX;
       double d4 = d1 - explosionY;
       double d5 = d2 - explosionZ;
       double d6 = MathHelper.sqrt_double(d3 * d3 + d4 * d4 + d5 * d5);
       d3 /= d6;
       d4 /= d6;
       d5 /= d6;
       double d7 = 0.5D / (d6 / (double) explosionSize + 0.10000000000000001D);
       d7 *= worldObj.rand.nextFloat() * worldObj.rand.nextFloat() + 0.3F;
       d3 *= d7;
       d4 *= d7;
       d5 *= d7;
       worldObj.spawnParticle(
           "explode",
           (d + explosionX * 1.0D) / 2D,
           (d1 + explosionY * 1.0D) / 2D,
           (d2 + explosionZ * 1.0D) / 2D,
           d3,
           d4,
           d5);
       worldObj.spawnParticle("smoke", d, d1, d2, d3, d4, d5);
     }
     if (i1 > 0) {
       Block.blocksList[i1].dropBlockAsItemWithChance(
           worldObj, j, k, l, worldObj.getBlockMetadata(j, k, l), 0.3F);
       worldObj.setBlockWithNotify(j, k, l, 0);
       Block.blocksList[i1].onBlockDestroyedByExplosion(worldObj, j, k, l);
     }
   }
 }
Exemplo n.º 20
0
 public void addMovementStat(double d, double d1, double d2) {
   if (ridingEntity != null) {
     return;
   }
   if (isInsideOfMaterial(Material.water)) {
     int i = Math.round(MathHelper.sqrt_double(d * d + d1 * d1 + d2 * d2) * 100F);
     if (i > 0) {
       addStat(StatList.distanceDoveStat, i);
       addExhaustion(0.015F * (float) i * 0.01F);
     }
   } else if (isInWater()) {
     int j = Math.round(MathHelper.sqrt_double(d * d + d2 * d2) * 100F);
     if (j > 0) {
       addStat(StatList.distanceSwumStat, j);
       addExhaustion(0.015F * (float) j * 0.01F);
     }
   } else if (isOnLadder()) {
     if (d1 > 0.0D) {
       addStat(StatList.distanceClimbedStat, (int) Math.round(d1 * 100D));
     }
   } else if (onGround) {
     int k = Math.round(MathHelper.sqrt_double(d * d + d2 * d2) * 100F);
     if (k > 0) {
       addStat(StatList.distanceWalkedStat, k);
       if (isSprinting()) {
         addExhaustion(0.09999999F * (float) k * 0.01F);
       } else {
         addExhaustion(0.01F * (float) k * 0.01F);
       }
     }
   } else {
     int l = Math.round(MathHelper.sqrt_double(d * d + d2 * d2) * 100F);
     if (l > 25) {
       addStat(StatList.distanceFlownStat, l);
     }
   }
 }
Exemplo n.º 21
0
 public void func_40090_a(double d, int i, double d1) {
   double d2 = d - posX;
   double d3 = d1 - posZ;
   float f = MathHelper.sqrt_double(d2 * d2 + d3 * d3);
   if (f > 12F) {
     field_40094_b = posX + (d2 / (double) f) * 12D;
     field_40091_d = posZ + (d3 / (double) f) * 12D;
     field_40095_c = posY + 8D;
   } else {
     field_40094_b = d;
     field_40095_c = i;
     field_40091_d = d1;
   }
   despawnTimer = 0;
   shatterOrDrop = rand.nextInt(5) > 0;
 }
Exemplo n.º 22
0
  public EntityArrow(
      World par1World,
      EntityLiving par2EntityLiving,
      EntityLiving par3EntityLiving,
      float par4,
      float par5) {
    super(par1World);
    this.xTile = -1;
    this.yTile = -1;
    this.zTile = -1;
    this.inTile = 0;
    this.inData = 0;
    this.inGround = false;
    this.field_70251_a = 0;
    this.arrowShake = 0;
    this.ticksInAir = 0;
    this.damage = 2D;
    this.shootingEntity = par2EntityLiving;

    if (par2EntityLiving instanceof EntityPlayer) {
      this.field_70251_a = 1;
    }

    this.posY = (par2EntityLiving.posY + par2EntityLiving.getEyeHeight()) - 0.10000000149011612D;
    double d = par3EntityLiving.posX - par2EntityLiving.posX;
    double d1 =
        (par3EntityLiving.posY + par3EntityLiving.getEyeHeight())
            - 0.69999998807907104D
            - this.posY;
    double d2 = par3EntityLiving.posZ - par2EntityLiving.posZ;
    double d3 = MathHelper.sqrt_double(d * d + d2 * d2);

    if (d3 < 9.9999999999999995E-008D) {
      return;
    } else {
      float f = (float) ((Math.atan2(d2, d) * 180D) / Math.PI) - 90F;
      float f1 = (float) (-((Math.atan2(d1, d3) * 180D) / Math.PI));
      double d4 = d / d3;
      double d5 = d2 / d3;
      setLocationAndAngles(
          par2EntityLiving.posX + d4, this.posY, par2EntityLiving.posZ + d5, f, f1);
      this.yOffset = 0.0F;
      float f2 = (float) d3 * 0.2F;
      setArrowHeading(d, d1 + f2, d2, par4, par5);
      return;
    }
  }
Exemplo n.º 23
0
 public EntityFireball(
     World par1World,
     double par2,
     double par4,
     double par6,
     double par8,
     double par10,
     double par12) {
   super(par1World);
   this.setSize(1.0F, 1.0F);
   this.setLocationAndAngles(par2, par4, par6, this.rotationYaw, this.rotationPitch);
   this.setPosition(par2, par4, par6);
   double var14 = (double) MathHelper.sqrt_double(par8 * par8 + par10 * par10 + par12 * par12);
   this.accelerationX = par8 / var14 * 0.1D;
   this.accelerationY = par10 / var14 * 0.1D;
   this.accelerationZ = par12 / var14 * 0.1D;
 }
Exemplo n.º 24
0
  /** Sets the velocity to the args. Args: x, y, z */
  @Override
  public void setVelocity(double par1, double par3, double par5) {
    this.motionX = par1;
    this.motionY = par3;
    this.motionZ = par5;

    if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
      float f = MathHelper.sqrt_double(par1 * par1 + par5 * par5);
      this.prevRotationYaw = this.rotationYaw = (float) ((Math.atan2(par1, par5) * 180D) / Math.PI);
      this.prevRotationPitch =
          this.rotationPitch = (float) ((Math.atan2(par3, f) * 180D) / Math.PI);
      this.prevRotationPitch = this.rotationPitch;
      this.prevRotationYaw = this.rotationYaw;
      setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
      this.ticksInGround = 0;
    }
  }
Exemplo n.º 25
0
 public void onLivingUpdate() {
   if (flyToggleTimer > 0) {
     flyToggleTimer--;
   }
   if (worldObj.difficultySetting == 0
       && getEntityHealth() < getMaxHealth()
       && (ticksExisted % 20) * 12 == 0) {
     heal(1);
   }
   inventory.decrementAnimations();
   prevCameraYaw = cameraYaw;
   super.onLivingUpdate();
   landMovementFactor = speedOnGround;
   jumpMovementFactor = speedInAir;
   if (isSprinting()) {
     landMovementFactor += (double) speedOnGround * 0.29999999999999999D;
     jumpMovementFactor += (double) speedInAir * 0.29999999999999999D;
   }
   float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
   float f1 = (float) Math.atan(-motionY * 0.20000000298023224D) * 15F;
   if (f > 0.1F) {
     f = 0.1F;
   }
   if (!onGround || getEntityHealth() <= 0) {
     f = 0.0F;
   }
   if (onGround || getEntityHealth() <= 0) {
     f1 = 0.0F;
   }
   cameraYaw += (f - cameraYaw) * 0.4F;
   cameraPitch += (f1 - cameraPitch) * 0.8F;
   if (getEntityHealth() > 0) {
     List list =
         worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(1.0D, 0.0D, 1.0D));
     if (list != null) {
       for (int i = 0; i < list.size(); i++) {
         Entity entity = (Entity) list.get(i);
         if (!entity.isDead) {
           collideWithPlayer(entity);
         }
       }
     }
   }
 }
Exemplo n.º 26
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;
    }
  }
 public void faceEntity(Entity entity, float f) {
   double d = entity.posX - posX;
   double d2 = entity.posZ - posZ;
   double d1;
   if (entity instanceof EntityLiving) {
     EntityLiving entityliving = (EntityLiving) entity;
     d1 =
         (entityliving.posY + (double) entityliving.getEyeHeight())
             - (posY + (double) getEyeHeight());
   } else {
     d1 =
         (entity.boundingBox.minY + entity.boundingBox.maxY) / 2D
             - (posY + (double) getEyeHeight());
   }
   double d3 = MathHelper.sqrt_double(d * d + d2 * d2);
   float f1 = (float) ((Math.atan2(d2, d) * 180D) / 3.1415927410125732D) - 90F;
   float f2 = (float) ((Math.atan2(d1, d3) * 180D) / 3.1415927410125732D);
   rotationPitch = -updateRotation(rotationPitch, f2, f);
   rotationYaw = updateRotation(rotationYaw, f1, f);
 }
Exemplo n.º 28
0
 public EntityFireball(
     World par1World, EntityLiving par2EntityLiving, double par3, double par5, double par7) {
   super(par1World);
   this.shootingEntity = par2EntityLiving;
   this.setSize(1.0F, 1.0F);
   this.setLocationAndAngles(
       par2EntityLiving.posX,
       par2EntityLiving.posY,
       par2EntityLiving.posZ,
       par2EntityLiving.rotationYaw,
       par2EntityLiving.rotationPitch);
   this.setPosition(this.posX, this.posY, this.posZ);
   this.yOffset = 0.0F;
   this.motionX = this.motionY = this.motionZ = 0.0D;
   par3 += this.rand.nextGaussian() * 0.4D;
   par5 += this.rand.nextGaussian() * 0.4D;
   par7 += this.rand.nextGaussian() * 0.4D;
   double var9 = (double) MathHelper.sqrt_double(par3 * par3 + par5 * par5 + par7 * par7);
   this.accelerationX = par3 / var9 * 0.1D;
   this.accelerationY = par5 / var9 * 0.1D;
   this.accelerationZ = par7 / var9 * 0.1D;
 }
Exemplo n.º 29
0
 public EntityFireball(
     World par1World,
     double par2,
     double par4,
     double par6,
     double par8,
     double par10,
     double par12) {
   super(par1World);
   xTile = -1;
   yTile = -1;
   zTile = -1;
   inTile = 0;
   inGround = false;
   ticksInAir = 0;
   setSize(1.0F, 1.0F);
   setLocationAndAngles(par2, par4, par6, rotationYaw, rotationPitch);
   setPosition(par2, par4, par6);
   double d = MathHelper.sqrt_double(par8 * par8 + par10 * par10 + par12 * par12);
   accelerationX = (par8 / d) * 0.10000000000000001D;
   accelerationY = (par10 / d) * 0.10000000000000001D;
   accelerationZ = (par12 / d) * 0.10000000000000001D;
 }
Exemplo n.º 30
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;
   }
 }