@Override
  public void attackEntityWithRangedAttack(EntityLivingBase target, float p_82196_2_) {

    double d0 = target.posY + (double) target.getEyeHeight() - 1.100000023841858D;
    double x = target.posX - this.posX;
    double y = d0 - this.posY - this.getEyeHeight();
    double z = target.posZ - this.posZ;
    float f = MathHelper.sqrt_double(x * x + z * z) * 0.2F;

    if (this.rand.nextInt(10) != 0) {
      EntityAttackSnoball entitysnowball = new EntityAttackSnoball(this.worldObj, this);
      entitysnowball.setThrowableHeading(x, y + (double) f, z, 1.6F, 5.0F);
      this.playSound(
          SoundEvents.ENTITY_SNOWMAN_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
      this.worldObj.spawnEntityInWorld(entitysnowball);
    } else {
      this.playSound(
          SoundEvents.ENTITY_CHICKEN_HURT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));

      this.motionX = x * 1.2f;
      this.motionY = y * 1.2f;
      this.motionZ = z * 1.2f;

      this.rotationYaw = (float) (MathHelper.atan2(x, z) * (180D / Math.PI));
      this.rotationPitch = (float) (MathHelper.atan2(x, (double) f) * (180D / Math.PI));
      this.prevRotationYaw = this.rotationYaw;
      this.prevRotationPitch = this.rotationPitch;
    }
  }
Пример #2
0
  /** Moves the entity based on the specified heading. */
  public void moveEntityWithHeading(float strafe, float forward) {
    Entity entity = this.getPassengers().isEmpty() ? null : (Entity) this.getPassengers().get(0);

    if (this.isBeingRidden() && this.canBeSteered()) {
      this.rotationYaw = entity.rotationYaw;
      this.prevRotationYaw = this.rotationYaw;
      this.rotationPitch = entity.rotationPitch * 0.5F;
      this.setRotation(this.rotationYaw, this.rotationPitch);
      this.renderYawOffset = this.rotationYaw;
      this.rotationYawHead = this.rotationYaw;
      this.stepHeight = 1.0F;
      this.jumpMovementFactor = this.getAIMoveSpeed() * 0.1F;

      if (this.canPassengerSteer()) {
        float f =
            (float)
                    this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED)
                        .getAttributeValue()
                * 0.225F;

        if (this.boosting) {
          if (this.boostTime++ > this.totalBoostTime) {
            this.boosting = false;
          }

          f +=
              f
                  * 1.15F
                  * MathHelper.sin(
                      (float) this.boostTime / (float) this.totalBoostTime * (float) Math.PI);
        }

        this.setAIMoveSpeed(f);
        super.moveEntityWithHeading(0.0F, 1.0F);
      } else {
        this.motionX = 0.0D;
        this.motionY = 0.0D;
        this.motionZ = 0.0D;
      }

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

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

      this.limbSwingAmount += (f1 - this.limbSwingAmount) * 0.4F;
      this.limbSwing += this.limbSwingAmount;
    } else {
      this.stepHeight = 0.5F;
      this.jumpMovementFactor = 0.02F;
      super.moveEntityWithHeading(strafe, forward);
    }
  }
 @SideOnly(Side.CLIENT)
 public EntityWandFireball(
     World worldIn, double x, double y, double z, double accelX, double accelY, double accelZ) {
   super(worldIn);
   this.setSize(1.0F, 1.0F);
   this.setLocationAndAngles(x, y, z, this.rotationYaw, this.rotationPitch);
   this.setPosition(x, y, z);
   double d0 =
       (double) MathHelper.sqrt_double(accelX * accelX + accelY * accelY + accelZ * accelZ);
   this.accelerationX = accelX / d0 * 0.1D;
   this.accelerationY = accelY / d0 * 0.1D;
   this.accelerationZ = accelZ / d0 * 0.1D;
 }
Пример #4
0
 /**
  * Returns the euler angles from position 1 to position 2.
  *
  * <p>The returned vector has Y for yaw, and X for pitch. Measurements are in radians.
  *
  * @param pos1 Where we are
  * @param pos2 Where to look at
  */
 public static Vector getRotations(Vector pos1, Vector pos2) {
   Vector diff = pos2.minus(pos1);
   diff.normalize();
   double x = diff.x();
   double y = diff.y();
   double z = diff.z();
   double d0 = x;
   double d1 = y;
   double d2 = z;
   double d3 = (double) MathHelper.sqrt_double(d0 * d0 + d2 * d2);
   double rotY = Math.atan2(d2, d0) - Math.PI / 2;
   double rotX = -Math.atan2(d1, d3);
   double rotZ = 0;
   return new Vector(rotX, rotY, rotZ);
 }