Exemplo n.º 1
0
 public void setHeading(
     double movementX,
     double movementY,
     double movementZ,
     double projectileSpeed,
     double projectileSpeed2) {
   float f =
       MathHelper.sqrt_double(
           movementX * movementX + movementY * movementY + movementZ * movementZ);
   movementX /= f;
   movementY /= f;
   movementZ /= f;
   movementX += rand.nextGaussian() * 0.0074999998323619366D * projectileSpeed2;
   movementY += rand.nextGaussian() * 0.0074999998323619366D * projectileSpeed2;
   movementZ += rand.nextGaussian() * 0.0074999998323619366D * projectileSpeed2;
   movementX *= projectileSpeed;
   movementY *= projectileSpeed;
   movementZ *= projectileSpeed;
   motionX = movementX;
   motionY = movementY;
   motionZ = movementZ;
   float f1 = MathHelper.sqrt_double(movementX * movementX + movementZ * movementZ);
   prevRotationYaw = rotationYaw = (float) ((Math.atan2(movementX, movementZ) * 180D) / Math.PI);
   prevRotationPitch = rotationPitch = (float) ((Math.atan2(movementY, f1) * 180D) / Math.PI);
 }
Exemplo n.º 2
0
 public void setThrowableHeading(double par1, double par3, double par5, float par7, float par8) {
   float f2 = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5);
   par1 /= (double) f2;
   par3 /= (double) f2;
   par5 /= (double) f2;
   par1 +=
       this.rand.nextGaussian()
           * (double) (this.rand.nextBoolean() ? -1 : 1)
           * 0.007499999832361937D
           * (double) par8;
   par3 +=
       this.rand.nextGaussian()
           * (double) (this.rand.nextBoolean() ? -1 : 1)
           * 0.007499999832361937D
           * (double) par8;
   par5 +=
       this.rand.nextGaussian()
           * (double) (this.rand.nextBoolean() ? -1 : 1)
           * 0.007499999832361937D
           * (double) par8;
   par1 *= (double) par7;
   par3 *= (double) par7;
   par5 *= (double) par7;
   this.motionX = par1;
   this.motionY = par3;
   this.motionZ = par5;
   float f3 = 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) f3) * 180.0D / Math.PI);
   this.ticksInGround = 0;
 }
Exemplo n.º 3
0
 public void handleHookCasting(
     double p_146035_1_,
     double p_146035_3_,
     double p_146035_5_,
     float p_146035_7_,
     float p_146035_8_) {
   float f =
       MathHelper.sqrt_double(
           p_146035_1_ * p_146035_1_ + p_146035_3_ * p_146035_3_ + p_146035_5_ * p_146035_5_);
   p_146035_1_ = p_146035_1_ / (double) f;
   p_146035_3_ = p_146035_3_ / (double) f;
   p_146035_5_ = p_146035_5_ / (double) f;
   p_146035_1_ =
       p_146035_1_ + this.rand.nextGaussian() * 0.007499999832361937D * (double) p_146035_8_;
   p_146035_3_ =
       p_146035_3_ + this.rand.nextGaussian() * 0.007499999832361937D * (double) p_146035_8_;
   p_146035_5_ =
       p_146035_5_ + this.rand.nextGaussian() * 0.007499999832361937D * (double) p_146035_8_;
   p_146035_1_ = p_146035_1_ * (double) p_146035_7_;
   p_146035_3_ = p_146035_3_ * (double) p_146035_7_;
   p_146035_5_ = p_146035_5_ * (double) p_146035_7_;
   this.motionX = p_146035_1_;
   this.motionY = p_146035_3_;
   this.motionZ = p_146035_5_;
   float f1 = MathHelper.sqrt_double(p_146035_1_ * p_146035_1_ + p_146035_5_ * p_146035_5_);
   this.prevRotationYaw =
       this.rotationYaw =
           (float) (MathHelper.func_181159_b(p_146035_1_, p_146035_5_) * 180.0D / Math.PI);
   this.prevRotationPitch =
       this.rotationPitch =
           (float) (MathHelper.func_181159_b(p_146035_3_, (double) f1) * 180.0D / Math.PI);
   this.ticksInGround = 0;
 }
  /** Updates the task */
  @Override
  public void updateTask() {
    double distToTargetSq =
        entityHost.getDistanceSq(
            attackTarget.posX, attackTarget.boundingBox.minY, attackTarget.posZ);
    boolean canSeeTarget = entityHost.getEntitySenses().canSee(attackTarget);

    if (canSeeTarget) {
      ++timeTargetVisible;
    } else {
      timeTargetVisible = 0;
    }

    boolean runningAway = isRunningAway();
    if (!runningAway) {
      runAwayTimer--;
    }

    if (!runningAway && distToTargetSq <= attackRangeSq && timeTargetVisible >= 20) {
      getNavigator().clearPathEntity();
    } else if (distToTargetSq > (attackRangeSq * 0.9)) {
      getNavigator().tryMoveToEntityLiving(attackTarget, getMoveSpeed());
    }

    if (canSeeTarget
        && entityHost.isRiding()
        && distToTargetSq < 36
        && runAwayTimer <= 0
        && runAway()) {
      --timeUntilNextAttack;
      return;
    }

    if (runningAway) {
      --timeUntilNextAttack;
      return;
    }

    entityHost.getLookHelper().setLookPositionWithEntity(attackTarget, 30.0F, 30.0F);

    if (--timeUntilNextAttack == 0) {
      if (distToTargetSq > attackRangeSq || !canSeeTarget) {
        return;
      }
      float rangeRatio = MathHelper.sqrt_double(distToTargetSq) / attackRange;
      rangeRatio = MathHelper.clamp_float(rangeRatio, 0.1f, 1);
      rangedAttackEntityHost.attackEntityWithRangedAttack(attackTarget, rangeRatio);
      timeUntilNextAttack =
          MathHelper.floor_float(
              rangeRatio * (maxRangedAttackTime - minRangedAttackTime) + minRangedAttackTime);
    } else if (timeUntilNextAttack < 0) {
      float rangeRatio = MathHelper.sqrt_double(distToTargetSq) / attackRange;
      timeUntilNextAttack =
          MathHelper.floor_float(
              rangeRatio * (maxRangedAttackTime - minRangedAttackTime) + minRangedAttackTime);
    }
  }
  public EntitySkylineHook(
      World world,
      double x,
      double y,
      double z,
      Connection connection,
      ChunkCoordinates target,
      Vec3[] subPoints) {
    super(world);
    this.noClip = true;
    this.setSize(0.125F, 0.125F);
    this.setLocationAndAngles(x, y, z, this.rotationYaw, this.rotationPitch);
    this.setPosition(x, y, z);
    this.connection = connection;
    this.target = target;
    this.subPoints = subPoints;

    float f1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
    this.rotationYaw = (float) (Math.atan2(this.motionZ, this.motionX) * 180.0D / Math.PI) + 90.0F;

    for (this.rotationPitch =
            (float) (Math.atan2((double) f1, this.motionY) * 180.0D / Math.PI) - 90.0F;
        this.rotationPitch - this.prevRotationPitch < -180.0F;
        this.prevRotationPitch -= 360.0F) ;

    while (this.rotationPitch - this.prevRotationPitch >= 180.0F) this.prevRotationPitch += 360.0F;
    while (this.rotationYaw - this.prevRotationYaw < -180.0F) this.prevRotationYaw -= 360.0F;
    while (this.rotationYaw - this.prevRotationYaw >= 180.0F) this.prevRotationYaw += 360.0F;
  }
 @Override
 public void updateEntity() {
   if (drone != null && drone.isDead) {
     setDrone(null);
   }
   if (drone != null) {
     if (worldObj.isRemote) {
       double dx = drone.posX - (xCoord + 0.5);
       double dy = drone.posY - (yCoord + 0.5);
       double dz = drone.posZ - (zCoord + 0.5);
       float f3 = MathHelper.sqrt_double(dx * dx + dz * dz);
       rotationYaw = (float) -Math.atan2(dx, dz);
       rotationPitch = (float) -Math.atan2(dy, f3);
     } else {
       if (ringSendCooldown > 0) ringSendCooldown--;
       if (ringSendList.size() > 0 && ringSendCooldown <= 0) {
         ringSendCooldown = ringSendList.size() > 10 ? 1 : 5;
         NetworkHandler.sendToDimension(
             new PacketSpawnRing(
                 xCoord + 0.5, yCoord + 0.8, zCoord + 0.5, drone, ringSendList.remove(0)),
             worldObj.provider.dimensionId);
       }
     }
   }
 }
Exemplo n.º 7
0
  public EntityMeteorChunk(
      World world,
      EntityLivingBase shootingEntity,
      EntityLivingBase target,
      float speed,
      float randMod) {
    super(world);
    this.renderDistanceWeight = 10.0D;
    this.shootingEntity = shootingEntity;

    if (shootingEntity instanceof EntityPlayer) {
      this.canBePickedUp = 1;
    }

    this.posY = shootingEntity.posY + shootingEntity.getEyeHeight() - 0.10000000149011612D;
    double d0 = target.posX - shootingEntity.posX;
    double d1 = target.getEntityBoundingBox().minY + target.height / 3.0F - this.posY;
    double d2 = target.posZ - shootingEntity.posZ;
    double d3 = MathHelper.sqrt_double(d0 * d0 + d2 * d2);

    if (d3 >= 1.0E-7D) {
      float f2 = (float) (Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F;
      float f3 = (float) -(Math.atan2(d1, d3) * 180.0D / Math.PI);
      double d4 = d0 / d3;
      double d5 = d2 / d3;
      this.setLocationAndAngles(
          shootingEntity.posX + d4, this.posY, shootingEntity.posZ + d5, f2, f3);
      float f4 = (float) d3 * 0.2F;
      this.setThrowableHeading(d0, d1 + f4, d2, speed, randMod);
    }
  }
  /**
   * Basic mob attack. Default to touch of death in EntityCreature. Overridden by each mob to define
   * their attack.
   */
  protected void attackEntity(Entity entity, float f) {
    if (onGround) {
      double d = entity.posX - posX;
      double d1 = entity.posZ - posZ;
      float f1 = MathHelper.sqrt_double(d * d + d1 * d1);
      motionX =
          (d / (double) f1)
              * 0.20000000000000001D
              * (0.850000011920929D + motionX * 0.20000000298023224D);
      motionZ =
          (d1 / (double) f1)
              * 0.20000000000000001D
              * (0.80000001192092896D + motionZ * 0.20000000298023224D);
      motionY = 0.10000000596246449D;
      fallDistance = -25F;
    }

    if ((double) f < 2D
        && entity.getBoundingBox().maxY > this.getBoundingBox().minY
        && entity.getBoundingBox().minY < this.getBoundingBox().maxY
        && !(entity instanceof CREEPSEntityCamel)) {
      // attackTime = 20;
      entity.attackEntityFrom(DamageSource.causeMobDamage(this), attack);
    }
  }
  public EntitySchrab(
      World p_i1755_1_,
      EntityLivingBase p_i1755_2_,
      EntityLivingBase p_i1755_3_,
      float p_i1755_4_,
      float p_i1755_5_) {
    super(p_i1755_1_);
    this.renderDistanceWeight = 10.0D;
    this.shootingEntity = p_i1755_2_;

    if (p_i1755_2_ instanceof EntityPlayer) {
      this.canBePickedUp = 1;
    }

    this.posY = p_i1755_2_.posY + p_i1755_2_.getEyeHeight() - 0.10000000149011612D;
    double d0 = p_i1755_3_.posX - p_i1755_2_.posX;
    double d1 = p_i1755_3_.boundingBox.minY + p_i1755_3_.height / 3.0F - this.posY;
    double d2 = p_i1755_3_.posZ - p_i1755_2_.posZ;
    double d3 = MathHelper.sqrt_double(d0 * d0 + d2 * d2);

    if (d3 >= 1.0E-7D) {
      float f2 = (float) (Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F;
      float f3 = (float) (-(Math.atan2(d1, d3) * 180.0D / Math.PI));
      double d4 = d0 / d3;
      double d5 = d2 / d3;
      this.setLocationAndAngles(p_i1755_2_.posX + d4, this.posY, p_i1755_2_.posZ + d5, f2, f3);
      this.yOffset = 0.0F;
      float f4 = (float) d3 * 0.2F;
      this.setThrowableHeading(d0, d1 + f4, d2, p_i1755_4_, p_i1755_5_);
    }
  }
Exemplo n.º 10
0
  /** Updates look */
  public void onUpdateLook() {
    this.entity.rotationPitch = 0.0F;

    if (this.isLooking) {
      this.isLooking = false;
      double var1 = this.posX - this.entity.posX;
      double var3 = this.posY - (this.entity.posY + (double) this.entity.getEyeHeight());
      double var5 = this.posZ - this.entity.posZ;
      double var7 = (double) MathHelper.sqrt_double(var1 * var1 + var5 * var5);
      float var9 = (float) (Math.atan2(var5, var1) * 180.0D / Math.PI) - 90.0F;
      float var10 = (float) (-(Math.atan2(var3, var7) * 180.0D / Math.PI));
      this.entity.rotationPitch =
          this.updateRotation(this.entity.rotationPitch, var10, this.deltaLookPitch);
      this.entity.rotationYawHead =
          this.updateRotation(this.entity.rotationYawHead, var9, this.deltaLookYaw);
    } else {
      this.entity.rotationYawHead =
          this.updateRotation(this.entity.rotationYawHead, this.entity.renderYawOffset, 10.0F);
    }

    float var11 =
        MathHelper.wrapAngleTo180_float(this.entity.rotationYawHead - this.entity.renderYawOffset);

    if (!this.entity.getNavigator().noPath()) {
      if (var11 < -75.0F) {
        this.entity.rotationYawHead = this.entity.renderYawOffset - 75.0F;
      }

      if (var11 > 75.0F) {
        this.entity.rotationYawHead = this.entity.renderYawOffset + 75.0F;
      }
    }
  }
Exemplo n.º 11
0
  public EntityLaser(
      World par1World,
      EntityLivingBase par2EntityLivingBase,
      EntityLivingBase par3EntityLivingBase,
      float par4,
      float par5) {
    super(par1World);
    this.renderDistanceWeight = 10.0D;
    this.shootingEntity = par2EntityLivingBase;

    this.posY =
        par2EntityLivingBase.posY
            + (double) par2EntityLivingBase.getEyeHeight()
            - 0.10000000149011612D;
    double d0 = par3EntityLivingBase.posX - par2EntityLivingBase.posX;
    double d1 =
        par3EntityLivingBase.boundingBox.minY
            + (double) (par3EntityLivingBase.height / 3.0F)
            - this.posY;
    double d2 = par3EntityLivingBase.posZ - par2EntityLivingBase.posZ;
    double d3 = (double) MathHelper.sqrt_double(d0 * d0 + d2 * d2);

    if (d3 >= 1.0E-7D) {
      float f2 = (float) (Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F;
      float f3 = (float) (-(Math.atan2(d1, d3) * 180.0D / Math.PI));
      double d4 = d0 / d3;
      double d5 = d2 / d3;
      this.setLocationAndAngles(
          par2EntityLivingBase.posX + d4, this.posY, par2EntityLivingBase.posZ + d5, f2, f3);
      this.yOffset = 0.0F;
      float f4 = (float) d3 * 0.2F;
      this.setThrowableHeading(d0, d1 + (double) f4, d2, par4, par5);
    }
  }
Exemplo n.º 12
0
  public void setHeading(Pos3D motion) {
    float d = MathHelper.sqrt_double((motion.xPos * motion.xPos) + (motion.zPos * motion.zPos));

    prevRotationYaw =
        rotationYaw = (float) (Math.atan2(motion.xPos, motion.zPos) * 180.0D / Math.PI);
    prevRotationPitch = rotationPitch = (float) (Math.atan2(motion.yPos, d) * 180.0D / Math.PI);
  }
Exemplo n.º 13
0
  @Override
  protected void updateAITasks() {
    super.updateAITasks();
    if (this.spawnPosition != null
        && (!this.worldObj.isAirBlock(
                this.spawnPosition.posX, this.spawnPosition.posY, this.spawnPosition.posZ)
            || this.spawnPosition.posY < 1)) {
      this.spawnPosition = null;
    }

    if (this.spawnPosition == null
        || this.rand.nextInt(30) == 0
        || this.spawnPosition.getDistanceSquared((int) this.posX, (int) this.posY, (int) this.posZ)
            < 4.0F) {
      this.spawnPosition =
          new ChunkCoordinates(
              (int) this.posX + this.rand.nextInt(7) - this.rand.nextInt(7),
              (int) this.posY + this.rand.nextInt(6) - 2,
              (int) this.posZ + this.rand.nextInt(7) - this.rand.nextInt(7));
    }

    double d0 = (double) this.spawnPosition.posX + 0.01D - this.posX;
    double d1 = (double) this.spawnPosition.posY + 0.1D - this.posY;
    double d2 = (double) this.spawnPosition.posZ + 0.01D - this.posZ;
    double d3 = (double) MathHelper.sqrt_double(d0 * d0 + d1 * d1 + d2 * d2);
    this.motionX += d0 / d3 * 0.05D;
    this.motionY += d1 / d3 * 0.1D;
    this.motionZ += d2 / d3 * 0.05D;
    float f = (float) (Math.atan2(this.motionZ, this.motionX) * 180.0D / Math.PI) - 90.0F;
    float f1 = MathHelper.wrapAngleTo180_float(f - this.rotationYaw);
    this.moveForward = 0.001F;
    this.rotationYaw += f1;
  }
Exemplo n.º 14
0
  public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLiving, float par2) {
    if (!this.getAggressive()) {
      EntityPotion var2 = new EntityPotion(this.worldObj, this, 32732);
      var2.rotationPitch -= -20.0F;
      double var3 = par1EntityLiving.posX + par1EntityLiving.motionX - this.posX;
      double var5 =
          par1EntityLiving.posY
              + (double) par1EntityLiving.getEyeHeight()
              - 1.100000023841858D
              - this.posY;
      double var7 = par1EntityLiving.posZ + par1EntityLiving.motionZ - this.posZ;
      float var9 = MathHelper.sqrt_double(var3 * var3 + var7 * var7);
      if (var9 >= 8.0F && !par1EntityLiving.isPotionActive(Potion.moveSlowdown)) {
        var2.setPotionDamage(32698);
      } else if (par1EntityLiving.getHealth() >= 8.0F
          && !par1EntityLiving.isPotionActive(Potion.poison)) {
        var2.setPotionDamage(32660);
      } else if (var9 <= 3.0F
          && !par1EntityLiving.isPotionActive(Potion.weakness)
          && this.rand.nextFloat() < 0.25F) {
        var2.setPotionDamage(32696);
      }

      var2.setThrowableHeading(var3, var5 + (double) (var9 * 0.2F), var7, 0.75F, 8.0F);
      this.worldObj.spawnEntityInWorld(var2);
    }
  }
  public EntityMamormeterShot(
      World world,
      EntityLivingBase thrower,
      EntityLivingBase target,
      float var4,
      float var5,
      boolean b) {
    super(world);
    this.shootingEntity = thrower;

    if (thrower instanceof EntityPlayer) {
      this.canBePickedUp = 1;
    }

    this.posY = thrower.posY + thrower.getEyeHeight() - 0.10000000149011612D;
    double var6 = target.posX - thrower.posX;
    double var8 = target.posY + target.getEyeHeight() - 0.699999988079071D - this.posY;
    double var10 = target.posZ - thrower.posZ;
    double var12 = MathHelper.sqrt_double(var6 * var6 + var10 * var10);

    if (var12 >= 1.0E-7D) {
      float var14 = (float) (Math.atan2(var10, var6) * 180.0D / Math.PI) - 90.0F;
      float var15 = (float) (-(Math.atan2(var8, var12) * 180.0D / Math.PI));
      double var16 = var6 / var12;
      double var18 = var10 / var12;
      this.setLocationAndAngles(
          thrower.posX + var16, this.posY, thrower.posZ + var18, var14, var15);
      this.yOffset = 0.0F;
      float var20 = (float) var12 * 0.2F;
      this.setArrowHeading(var6, var8 + var20, var10, var4, var5);
    }
    this.explosive = b;
  }
Exemplo n.º 16
0
 public static float[] getRotationsNeeded(Entity entity) {
   if (entity == null) return null;
   double diffX = entity.posX - Minecraft.getMinecraft().thePlayer.posX;
   double diffY;
   if (entity instanceof EntityLivingBase) {
     EntityLivingBase entityLivingBase = (EntityLivingBase) entity;
     diffY =
         entityLivingBase.posY
             + entityLivingBase.getEyeHeight() * 0.9
             - (Minecraft.getMinecraft().thePlayer.posY
                 + Minecraft.getMinecraft().thePlayer.getEyeHeight());
   } else
     diffY =
         (entity.boundingBox.minY + entity.boundingBox.maxY) / 2.0D
             - (Minecraft.getMinecraft().thePlayer.posY
                 + Minecraft.getMinecraft().thePlayer.getEyeHeight());
   double diffZ = entity.posZ - Minecraft.getMinecraft().thePlayer.posZ;
   double dist = MathHelper.sqrt_double(diffX * diffX + diffZ * diffZ);
   float yaw = (float) (Math.atan2(diffZ, diffX) * 180.0D / Math.PI) - 90.0F;
   float pitch = (float) -(Math.atan2(diffY, dist) * 180.0D / Math.PI);
   return new float[] {
     Minecraft.getMinecraft().thePlayer.rotationYaw
         + MathHelper.wrapAngleTo180_float(yaw - Minecraft.getMinecraft().thePlayer.rotationYaw),
     Minecraft.getMinecraft().thePlayer.rotationPitch
         + MathHelper.wrapAngleTo180_float(
             pitch - Minecraft.getMinecraft().thePlayer.rotationPitch)
   };
 }
Exemplo n.º 17
0
  public void onGroundHit(MovingObjectPosition mop) {
    this.xTile = mop.blockX;
    this.yTile = mop.blockY;
    this.zTile = mop.blockZ;
    this.inTile = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile);
    this.inData = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile);
    this.motionX = (mop.hitVec.xCoord - this.posX);
    this.motionY = (mop.hitVec.yCoord - this.posY);
    this.motionZ = (mop.hitVec.zCoord - this.posZ);
    float f1 =
        MathHelper.sqrt_double(
            this.motionX * this.motionX
                + this.motionY * this.motionY
                + this.motionZ * this.motionZ);
    this.posX -= this.motionX / f1 * 0.05D;
    this.posY -= this.motionY / f1 * 0.05D;
    this.posZ -= this.motionZ / f1 * 0.05D;
    this.inGround = true;
    this.beenInGround = true;
    setCritical(false);
    this.arrowShake = getMaxArrowShake();
    playHitSound();

    if (this.inTile != 0) {
      Block.blocksList[this.inTile].onEntityCollidedWithBlock(
          this.worldObj, this.xTile, this.yTile, this.zTile, this);
    }
  }
Exemplo n.º 18
0
  public int handleHookRetraction() {
    if (this.worldObj.isRemote) {
      return 0;
    } else {
      int i = 0;

      if (this.caughtEntity != null) {
        double d0 = this.angler.posX - this.posX;
        double d2 = this.angler.posY - this.posY;
        double d4 = this.angler.posZ - this.posZ;
        double d6 = (double) MathHelper.sqrt_double(d0 * d0 + d2 * d2 + d4 * d4);
        double d8 = 0.1D;
        this.caughtEntity.motionX += d0 * d8;
        this.caughtEntity.motionY += d2 * d8 + (double) MathHelper.sqrt_double(d6) * 0.08D;
        this.caughtEntity.motionZ += d4 * d8;
        i = 3;
      } else if (this.ticksCatchable > 0) {
        EntityItem entityitem =
            new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, this.getFishingResult());
        double d1 = this.angler.posX - this.posX;
        double d3 = this.angler.posY - this.posY;
        double d5 = this.angler.posZ - this.posZ;
        double d7 = (double) MathHelper.sqrt_double(d1 * d1 + d3 * d3 + d5 * d5);
        double d9 = 0.1D;
        entityitem.motionX = d1 * d9;
        entityitem.motionY = d3 * d9 + (double) MathHelper.sqrt_double(d7) * 0.08D;
        entityitem.motionZ = d5 * d9;
        this.worldObj.spawnEntityInWorld(entityitem);
        this.angler.worldObj.spawnEntityInWorld(
            new EntityXPOrb(
                this.angler.worldObj,
                this.angler.posX,
                this.angler.posY + 0.5D,
                this.angler.posZ + 0.5D,
                this.rand.nextInt(6) + 1));
        i = 1;
      }

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

      this.setDead();
      this.angler.fishEntity = null;
      return i;
    }
  }
Exemplo n.º 19
0
  public void moveEntityWithHeading(float par1, float par2) {
    if (this.isInWater()) {
      this.moveFlying(par1, par2, 0.02F);
      this.moveEntity(this.motionX, this.motionY, this.motionZ);
      this.motionX *= 0.800000011920929D;
      this.motionY *= 0.800000011920929D;
      this.motionZ *= 0.800000011920929D;
    } else if (this.handleLavaMovement()) {
      this.moveFlying(par1, par2, 0.02F);
      this.moveEntity(this.motionX, this.motionY, this.motionZ);
      this.motionX *= 0.5D;
      this.motionY *= 0.5D;
      this.motionZ *= 0.5D;
    } else {
      float f2 = 0.91F;

      if (this.onGround) {
        f2 =
            this.worldObj.getBlock(
                        MathHelper.floor_double(this.posX),
                        MathHelper.floor_double(this.boundingBox.minY) - 1,
                        MathHelper.floor_double(this.posZ))
                    .slipperiness
                * 0.91F;
      }

      float f3 = 0.16277136F / (f2 * f2 * f2);
      this.moveFlying(par1, par2, this.onGround ? 0.1F * f3 : 0.02F);
      f2 = 0.91F;

      if (this.onGround) {
        f2 =
            this.worldObj.getBlock(
                        MathHelper.floor_double(this.posX),
                        MathHelper.floor_double(this.boundingBox.minY) - 1,
                        MathHelper.floor_double(this.posZ))
                    .slipperiness
                * 0.91F;
      }

      this.moveEntity(this.motionX, this.motionY, this.motionZ);
      this.motionX *= (double) f2;
      this.motionY *= (double) f2;
      this.motionZ *= (double) f2;
    }

    this.prevLimbSwingAmount = this.limbSwingAmount;
    double d1 = this.posX - this.prevPosX;
    double d0 = this.posZ - this.prevPosZ;
    float f4 = MathHelper.sqrt_double(d1 * d1 + d0 * d0) * 4.0F;

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

    this.limbSwingAmount += (f4 - this.limbSwingAmount) * 0.4F;
    this.limbSwing += this.limbSwingAmount;
  }
Exemplo n.º 20
0
 /** Normalizes the vector to a length of 1 (except if it is the zero vector) */
 public Vec3 normalize() {
   double d0 =
       (double)
           MathHelper.sqrt_double(
               this.xCoord * this.xCoord + this.yCoord * this.yCoord + this.zCoord * this.zCoord);
   return d0 < 1.0E-4D
       ? new Vec3(0.0D, 0.0D, 0.0D)
       : new Vec3(this.xCoord / d0, this.yCoord / d0, this.zCoord / d0);
 }
 public void func_22374_a(double d, double d1, double d2, float f, float f1) {
   float f2 = MathHelper.sqrt_double(d * d + d1 * d1 + d2 * d2);
   d /= f2;
   d1 /= f2;
   d2 /= f2;
   d += rand.nextGaussian() * 0.0074999998323619366D * (double) f1;
   d1 += rand.nextGaussian() * 0.0074999998323619366D * (double) f1;
   d2 += rand.nextGaussian() * 0.0074999998323619366D * (double) f1;
   d *= f;
   d1 *= f;
   d2 *= f;
   motionX = d;
   motionY = d1;
   motionZ = d2;
   float f3 = MathHelper.sqrt_double(d * d + d2 * d2);
   prevRotationYaw = rotationYaw = (float) ((Math.atan2(d, d2) * 180D) / Math.PI);
   prevRotationPitch = rotationPitch = (float) ((Math.atan2(d1, f3) * 180D) / Math.PI);
   aoLightValueScratchXYZNNP = 0;
 }
Exemplo n.º 22
0
 public void setArrowHeading(double d, double d1, double d2, float f, float f1) {
   float f2 = MathHelper.sqrt_double(d * d + d1 * d1 + d2 * d2);
   d /= f2;
   d1 /= f2;
   d2 /= f2;
   d += rand.nextGaussian() * 0.0074999998323619366D * (double) f1;
   d1 += rand.nextGaussian() * 0.0074999998323619366D * (double) f1;
   d2 += rand.nextGaussian() * 0.0074999998323619366D * (double) f1;
   d *= f;
   d1 *= f;
   d2 *= f;
   motionX = d;
   motionY = d1;
   motionZ = d2;
   float f3 = MathHelper.sqrt_double(d * d + d2 * d2);
   prevRotationYaw = rotationYaw = (float) ((Math.atan2(d, d2) * 180D) / 3.1415927410125732D);
   prevRotationPitch = rotationPitch = (float) ((Math.atan2(d1, f3) * 180D) / 3.1415927410125732D);
   ticksInGround = 0;
 }
Exemplo n.º 23
0
 /** Execute a one shot task or start executing a continuous task */
 public void startExecuting() {
   double d0 = this.leapTarget.posX - this.leaper.posX;
   double d1 = this.leapTarget.posZ - this.leaper.posZ;
   float f = MathHelper.sqrt_double(d0 * d0 + d1 * d1);
   this.leaper.motionX +=
       d0 / (double) f * 0.5D * 0.800000011920929D + this.leaper.motionX * 0.20000000298023224D;
   this.leaper.motionZ +=
       d1 / (double) f * 0.5D * 0.800000011920929D + this.leaper.motionZ * 0.20000000298023224D;
   this.leaper.motionY = (double) this.leapMotionY;
 }
Exemplo n.º 24
0
 public void facePosition(int i, int j, int k, float f) {
   double d = (double) i - posX;
   double d1 = (double) k - posZ;
   double d2 = (double) j - posY;
   double d3 = MathHelper.sqrt_double(d * d + d1 * d1);
   float f1 = (float) ((Math.atan2(d1, d) * 180D) / 3.1415927410125728D) - 90F;
   float f2 = (float) ((Math.atan2(d2, d3) * 180D) / 3.1415927410125728D);
   rotationPitch = -b(rotationPitch, f2, f);
   rotationYaw = b(rotationYaw, f1, f);
 }
 public void setArrowHeading(double var1, double var3, double var5, float var7, float var8) {
   float var9 = MathHelper.sqrt_double(var1 * var1 + var3 * var3 + var5 * var5);
   var1 /= var9;
   var3 /= var9;
   var5 /= var9;
   var1 += this.rand.nextGaussian() * 0.007499999832361937D * var8;
   var3 += this.rand.nextGaussian() * 0.007499999832361937D * var8;
   var5 += this.rand.nextGaussian() * 0.007499999832361937D * var8;
   var1 *= var7;
   var3 *= var7;
   var5 *= var7;
   this.motionX = var1;
   this.motionY = var3;
   this.motionZ = var5;
   float var10 = MathHelper.sqrt_double(var1 * var1 + var5 * var5);
   this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(var1, var5) * 180.0D / Math.PI);
   this.prevRotationPitch =
       this.rotationPitch = (float) (Math.atan2(var3, var10) * 180.0D / Math.PI);
   this.ticksInGround = 0;
 }
Exemplo n.º 26
0
 @Override
 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.º 27
0
  @Override
  public void tick() {
    if (getParent() instanceof EntityPlayer) {
      if (Morph.config.getSessionInt("allowFlight") == 0) {
        return;
      }
      EntityPlayer player = (EntityPlayer) getParent();
      if (!player.capabilities.allowFlying) {
        player.capabilities.allowFlying = true;
        player.sendPlayerAbilities();
      }
      if (player.capabilities.isFlying && !player.capabilities.isCreativeMode) {
        double motionX =
            player.worldObj.isRemote ? player.motionX : player.posX - player.lastTickPosX;
        double motionZ =
            player.worldObj.isRemote ? player.motionZ : player.posZ - player.lastTickPosZ;
        int i = Math.round(MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ) * 100.0F);

        if (i > 0 && i < 10) {
          if (player.isInWater() && slowdownInWater) {
            player.addExhaustion(0.125F * (float) i * 0.01F);
          } else {
            player.addExhaustion(0.035F * (float) i * 0.01F);
          }
        } else {
          player.addExhaustion(0.002F);
        }

        if (player.worldObj.isRemote && player.isInWater() && slowdownInWater) {
          MorphInfo info =
              Morph.proxy.tickHandlerClient.playerMorphInfo.get(player.getCommandSenderName());

          if (info != null) {
            boolean swim = false;
            for (Ability ability : info.morphAbilities) {
              if (ability.getType().equalsIgnoreCase("swim")) {
                swim = true;
                break;
              }
            }
            if (!swim) {
              player.motionX *= 0.65D;
              player.motionZ *= 0.65D;

              player.motionY *= 0.2D;
            }
          }
        }
      }
    }
    getParent().fallDistance = 0.0F;
    // TODO make "Thing" take note of this so it can fly...
  }
 @Override
 public void setThrowableHeading(
     double x, double y, double z, float speedMult, float spreadConst) {
   double normal = MathHelper.sqrt_double(x * x + y * y + z * z);
   x /= normal;
   y /= normal;
   z /= normal;
   x += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1D : 1D) * 0.0075D * spreadConst;
   y += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1D : 1D) * 0.0075D * spreadConst;
   z += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1D : 1D) * 0.0075D * spreadConst;
   x *= speedMult;
   y *= speedMult;
   z *= speedMult;
   this.motionX = x;
   this.motionY = y;
   this.motionZ = z;
   float horizSpeed = MathHelper.sqrt_double(x * x + z * z);
   this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(x, z) * 180.0D / Math.PI);
   this.prevRotationPitch =
       this.rotationPitch = (float) (Math.atan2(y, horizSpeed) * 180.0D / Math.PI);
 }
Exemplo n.º 29
0
  @Override
  public void moveEntityWithHeading(float moveStrafe, float moveForward) {
    // This controls the rider spider while it is mounted by the player.
    if (riddenByEntity != null) {
      final int level = getLevel();

      prevRotationYaw = rotationYaw = riddenByEntity.rotationYaw;
      rotationPitch = riddenByEntity.rotationPitch * 0.5F;
      setRotation(rotationYaw, rotationPitch);
      rotationYawHead = renderYawOffset = rotationYaw;

      if (level == 3) {
        moveStrafe = ((EntityLivingBase) riddenByEntity).moveStrafing * level * 0.5F / 4;
        moveForward = ((EntityLivingBase) riddenByEntity).moveForward * level * 0.6F / 4;
      } else if (level == 2) {
        moveStrafe = ((EntityLivingBase) riddenByEntity).moveStrafing * level * 0.4F / 3;
        moveForward = ((EntityLivingBase) riddenByEntity).moveForward * level * 0.5F / 3;
      } else {
        moveStrafe = ((EntityLivingBase) riddenByEntity).moveStrafing * level * 0.7F / 3;
        moveForward = ((EntityLivingBase) riddenByEntity).moveForward * level * 0.8F / 3;
      }

      if (moveForward <= 0.0F) {
        moveForward *= 0.25F;
      }

      stepHeight = 1.0F;
      jumpMovementFactor = getAIMoveSpeed() * 0.1F;

      if (!worldObj.isRemote) {
        setAIMoveSpeed(
            (float) getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue());
        super.moveEntityWithHeading(moveStrafe, moveForward);
      }

      prevLimbSwingAmount = limbSwingAmount;
      final double d1 = posX - prevPosX;
      final double d0 = posZ - prevPosZ;
      float f4 = MathHelper.sqrt_double(d1 * d1 + d0 * d0) * 4.0F;

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

      limbSwingAmount += (f4 - limbSwingAmount) * 0.4F;
      limbSwing += limbSwingAmount;
    } else {
      stepHeight = 0.5F;
      jumpMovementFactor = 0.02F;
      super.moveEntityWithHeading(moveStrafe, moveForward);
    }
  }
Exemplo n.º 30
0
 public void forceCollideWithPlayer(EntityLivingBase entity, float distance) {
   if (distance > 2.0F && distance < 4.0F)
     if (onGround) {
       double distanceX = entity.posX - posX;
       double distanceZ = entity.posZ - posZ;
       float squareRoot = MathHelper.sqrt_double(distanceX * distanceX + distanceZ * distanceZ);
       motionX =
           distanceX / squareRoot * 0.5D * 0.300000011920929D + motionX * 0.10000000298023224D;
       motionZ =
           distanceZ / squareRoot * 0.5D * 0.300000011920929D + motionZ * 0.10000000298023224D;
       motionY = 0D;
     }
 }