Пример #1
0
  /** Called to update the entity's position/logic. */
  public void onUpdate() {
    if (!worldObj.isRemote
        && (shootingEntity != null && shootingEntity.isDead
            || !worldObj.blockExists((int) posX, (int) posY, (int) posZ))) {
      setDead();
      return;
    }

    super.onUpdate();
    setFire(1);

    if (inGround) {
      int i = worldObj.getBlockId(xTile, yTile, zTile);

      if (i != inTile) {
        inGround = false;
        motionX *= rand.nextFloat() * 0.2F;
        motionY *= rand.nextFloat() * 0.2F;
        motionZ *= rand.nextFloat() * 0.2F;
        ticksAlive = 0;
        ticksInAir = 0;
      } else {
        ticksAlive++;

        if (ticksAlive == 600) {
          setDead();
        }

        return;
      }
    } else {
      ticksInAir++;
    }

    Vec3D vec3d = Vec3D.createVector(posX, posY, posZ);
    Vec3D vec3d1 = Vec3D.createVector(posX + motionX, posY + motionY, posZ + motionZ);
    MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1);
    vec3d = Vec3D.createVector(posX, posY, posZ);
    vec3d1 = Vec3D.createVector(posX + motionX, posY + motionY, posZ + motionZ);

    if (movingobjectposition != null) {
      vec3d1 =
          Vec3D.createVector(
              movingobjectposition.hitVec.xCoord,
              movingobjectposition.hitVec.yCoord,
              movingobjectposition.hitVec.zCoord);
    }

    Entity entity = null;
    List list =
        worldObj.getEntitiesWithinAABBExcludingEntity(
            this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
    double d = 0.0D;

    for (int j = 0; j < list.size(); j++) {
      Entity entity1 = (Entity) list.get(j);

      if (!entity1.canBeCollidedWith()
          || entity1.isEntityEqual(shootingEntity) && ticksInAir < 25) {
        continue;
      }

      float f2 = 0.3F;
      AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f2, f2, f2);
      MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3d, vec3d1);

      if (movingobjectposition1 == null) {
        continue;
      }

      double d1 = vec3d.distanceTo(movingobjectposition1.hitVec);

      if (d1 < d || d == 0.0D) {
        entity = entity1;
        d = d1;
      }
    }

    if (entity != null) {
      movingobjectposition = new MovingObjectPosition(entity);
    }

    if (movingobjectposition != null) {
      func_40063_a(movingobjectposition);
    }

    posX += motionX;
    posY += motionY;
    posZ += motionZ;
    float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
    rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / Math.PI);

    for (rotationPitch = (float) ((Math.atan2(motionY, f) * 180D) / Math.PI);
        rotationPitch - prevRotationPitch < -180F;
        prevRotationPitch -= 360F) {}

    for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F) {}

    for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F) {}

    for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F) {}

    rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
    rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
    float f1 = 0.95F;

    if (isInWater()) {
      for (int k = 0; k < 4; k++) {
        float f3 = 0.25F;
        worldObj.spawnParticle(
            "bubble",
            posX - motionX * (double) f3,
            posY - motionY * (double) f3,
            posZ - motionZ * (double) f3,
            motionX,
            motionY,
            motionZ);
      }

      f1 = 0.8F;
    }

    motionX += accelerationX;
    motionY += accelerationY;
    motionZ += accelerationZ;
    motionX *= f1;
    motionY *= f1;
    motionZ *= f1;
    worldObj.spawnParticle("smoke", posX, posY + 0.5D, posZ, 0.0D, 0.0D, 0.0D);
    setPosition(posX, posY, posZ);
  }
Пример #2
0
  public void onUpdate() {
    if (!this.worldObj.isRemote
        && (this.shootingEntity != null && this.shootingEntity.isDead
            || !this.worldObj.blockExists((int) this.posX, (int) this.posY, (int) this.posZ))) {
      this.setDead();
    } else {
      super.onUpdate();
      this.setFire(1);
      if (this.inGround) {
        int var1 = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile);
        if (var1 == this.inTile) {
          ++this.ticksAlive;
          if (this.ticksAlive == 600) {
            this.setDead();
          }

          return;
        }

        this.inGround = false;
        this.motionX *= (double) (this.rand.nextFloat() * 0.2F);
        this.motionY *= (double) (this.rand.nextFloat() * 0.2F);
        this.motionZ *= (double) (this.rand.nextFloat() * 0.2F);
        this.ticksAlive = 0;
        this.ticksInAir = 0;
      } else {
        ++this.ticksInAir;
      }

      Vec3D var15 = Vec3D.createVector(this.posX, this.posY, this.posZ);
      Vec3D var2 =
          Vec3D.createVector(
              this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
      MovingObjectPosition var3 = this.worldObj.rayTraceBlocks(var15, var2);
      var15 = Vec3D.createVector(this.posX, this.posY, this.posZ);
      var2 =
          Vec3D.createVector(
              this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
      if (var3 != null) {
        var2 = Vec3D.createVector(var3.hitVec.xCoord, var3.hitVec.yCoord, var3.hitVec.zCoord);
      }

      Entity var4 = null;
      List var5 =
          this.worldObj.getEntitiesWithinAABBExcludingEntity(
              this,
              this.boundingBox
                  .addCoord(this.motionX, this.motionY, this.motionZ)
                  .expand(1.0D, 1.0D, 1.0D));
      double var6 = 0.0D;

      for (int var8 = 0; var8 < var5.size(); ++var8) {
        Entity var9 = (Entity) var5.get(var8);
        if (var9.canBeCollidedWith()
            && (!var9.isEntityEqual(this.shootingEntity) || this.ticksInAir >= 25)) {
          float var10 = 0.3F;
          AxisAlignedBB var11 =
              var9.boundingBox.expand((double) var10, (double) var10, (double) var10);
          MovingObjectPosition var12 = var11.calculateIntercept(var15, var2);
          if (var12 != null) {
            double var13 = var15.distanceTo(var12.hitVec);
            if (var13 < var6 || var6 == 0.0D) {
              var4 = var9;
              var6 = var13;
            }
          }
        }
      }

      if (var4 != null) {
        var3 = new MovingObjectPosition(var4);
      }

      if (var3 != null) {
        this.func_40071_a(var3);
      }

      this.posX += this.motionX;
      this.posY += this.motionY;
      this.posZ += this.motionZ;
      float var16 =
          MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
      this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);

      for (this.rotationPitch =
              (float) (Math.atan2(this.motionY, (double) var16) * 180.0D / Math.PI);
          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;
      }

      this.rotationPitch =
          this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
      this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
      float var17 = 0.95F;
      if (this.isInWater()) {
        for (int var19 = 0; var19 < 4; ++var19) {
          float var18 = 0.25F;
          this.worldObj.spawnParticle(
              "bubble",
              this.posX - this.motionX * (double) var18,
              this.posY - this.motionY * (double) var18,
              this.posZ - this.motionZ * (double) var18,
              this.motionX,
              this.motionY,
              this.motionZ);
        }

        var17 = 0.8F;
      }

      this.motionX += this.accelerationX;
      this.motionY += this.accelerationY;
      this.motionZ += this.accelerationZ;
      this.motionX *= (double) var17;
      this.motionY *= (double) var17;
      this.motionZ *= (double) var17;
      this.worldObj.spawnParticle(
          "smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D);
      this.setPosition(this.posX, this.posY, this.posZ);
    }
  }
Пример #3
0
  /** Called to update the entity's position/logic. */
  public void onUpdate() {
    super.onUpdate();

    if (this.fishPosRotationIncrements > 0) {
      double var21 = this.posX + (this.fishX - this.posX) / (double) this.fishPosRotationIncrements;
      double var22 = this.posY + (this.fishY - this.posY) / (double) this.fishPosRotationIncrements;
      double var23 = this.posZ + (this.fishZ - this.posZ) / (double) this.fishPosRotationIncrements;
      double var7;

      for (var7 = this.fishYaw - (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.fishPosRotationIncrements);
      this.rotationPitch =
          (float)
              ((double) this.rotationPitch
                  + (this.fishPitch - (double) this.rotationPitch)
                      / (double) this.fishPosRotationIncrements);
      --this.fishPosRotationIncrements;
      this.setPosition(var21, var22, var23);
      this.setRotation(this.rotationYaw, this.rotationPitch);
    } else {
      if (!this.worldObj.isRemote) {
        ItemStack var1 = this.angler.getCurrentEquippedItem();

        if (this.angler.isDead
            || !this.angler.isEntityAlive()
            || var1 == null
            || var1.getItem() != Item.fishingRod
            || this.getDistanceSqToEntity(this.angler) > 1024.0D) {
          this.setDead();
          this.angler.fishEntity = null;
          return;
        }

        if (this.bobber != null) {
          if (!this.bobber.isDead) {
            this.posX = this.bobber.posX;
            this.posY = this.bobber.boundingBox.minY + (double) this.bobber.height * 0.8D;
            this.posZ = this.bobber.posZ;
            return;
          }

          this.bobber = null;
        }
      }

      if (this.shake > 0) {
        --this.shake;
      }

      if (this.inGround) {
        int var19 = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile);

        if (var19 == this.inTile) {
          ++this.ticksInGround;

          if (this.ticksInGround == 1200) {
            this.setDead();
          }

          return;
        }

        this.inGround = false;
        this.motionX *= (double) (this.rand.nextFloat() * 0.2F);
        this.motionY *= (double) (this.rand.nextFloat() * 0.2F);
        this.motionZ *= (double) (this.rand.nextFloat() * 0.2F);
        this.ticksInGround = 0;
        this.ticksInAir = 0;
      } else {
        ++this.ticksInAir;
      }

      Vec3D var20 = Vec3D.createVector(this.posX, this.posY, this.posZ);
      Vec3D var2 =
          Vec3D.createVector(
              this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
      MovingObjectPosition var3 = this.worldObj.rayTraceBlocks(var20, var2);
      var20 = Vec3D.createVector(this.posX, this.posY, this.posZ);
      var2 =
          Vec3D.createVector(
              this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);

      if (var3 != null) {
        var2 = Vec3D.createVector(var3.hitVec.xCoord, var3.hitVec.yCoord, var3.hitVec.zCoord);
      }

      Entity var4 = null;
      List var5 =
          this.worldObj.getEntitiesWithinAABBExcludingEntity(
              this,
              this.boundingBox
                  .addCoord(this.motionX, this.motionY, this.motionZ)
                  .expand(1.0D, 1.0D, 1.0D));
      double var6 = 0.0D;
      double var13;

      for (int var8 = 0; var8 < var5.size(); ++var8) {
        Entity var9 = (Entity) var5.get(var8);

        if (var9.canBeCollidedWith() && (var9 != this.angler || this.ticksInAir >= 5)) {
          float var10 = 0.3F;
          AxisAlignedBB var11 =
              var9.boundingBox.expand((double) var10, (double) var10, (double) var10);
          MovingObjectPosition var12 = var11.calculateIntercept(var20, var2);

          if (var12 != null) {
            var13 = var20.distanceTo(var12.hitVec);

            if (var13 < var6 || var6 == 0.0D) {
              var4 = var9;
              var6 = var13;
            }
          }
        }
      }

      if (var4 != null) {
        var3 = new MovingObjectPosition(var4);
      }

      if (var3 != null) {
        if (var3.entityHit != null) {
          if (var3.entityHit.attackEntityFrom(
              DamageSource.causeThrownDamage(this, this.angler), 0)) {
            this.bobber = var3.entityHit;
          }
        } else {
          this.inGround = true;
        }
      }

      if (!this.inGround) {
        this.moveEntity(this.motionX, this.motionY, this.motionZ);
        float var24 =
            MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
        this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);

        for (this.rotationPitch =
                (float) (Math.atan2(this.motionY, (double) var24) * 180.0D / Math.PI);
            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;
        }

        this.rotationPitch =
            this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
        this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
        float var25 = 0.92F;

        if (this.onGround || this.isCollidedHorizontally) {
          var25 = 0.5F;
        }

        byte var27 = 5;
        double var26 = 0.0D;

        for (int var29 = 0; var29 < var27; ++var29) {
          double var14 =
              this.boundingBox.minY
                  + (this.boundingBox.maxY - this.boundingBox.minY)
                      * (double) (var29 + 0)
                      / (double) var27
                  - 0.125D
                  + 0.125D;
          double var16 =
              this.boundingBox.minY
                  + (this.boundingBox.maxY - this.boundingBox.minY)
                      * (double) (var29 + 1)
                      / (double) var27
                  - 0.125D
                  + 0.125D;
          AxisAlignedBB var18 =
              AxisAlignedBB.getBoundingBoxFromPool(
                  this.boundingBox.minX,
                  var14,
                  this.boundingBox.minZ,
                  this.boundingBox.maxX,
                  var16,
                  this.boundingBox.maxZ);

          if (this.worldObj.isAABBInMaterial(var18, Material.water)) {
            var26 += 1.0D / (double) var27;
          }
        }

        if (var26 > 0.0D) {
          if (this.ticksCatchable > 0) {
            --this.ticksCatchable;
          } else {
            short var28 = 500;

            if (this.worldObj.canLightningStrikeAt(
                MathHelper.floor_double(this.posX),
                MathHelper.floor_double(this.posY) + 1,
                MathHelper.floor_double(this.posZ))) {
              var28 = 300;
            }

            if (this.rand.nextInt(var28) == 0) {
              this.ticksCatchable = this.rand.nextInt(30) + 10;
              this.motionY -= 0.20000000298023224D;
              this.worldObj.playSoundAtEntity(
                  this,
                  "random.splash",
                  0.25F,
                  1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F);
              float var30 = (float) MathHelper.floor_double(this.boundingBox.minY);
              int var15;
              float var17;
              float var31;

              for (var15 = 0; (float) var15 < 1.0F + this.width * 20.0F; ++var15) {
                var31 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
                var17 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
                this.worldObj.spawnParticle(
                    "bubble",
                    this.posX + (double) var31,
                    (double) (var30 + 1.0F),
                    this.posZ + (double) var17,
                    this.motionX,
                    this.motionY - (double) (this.rand.nextFloat() * 0.2F),
                    this.motionZ);
              }

              for (var15 = 0; (float) var15 < 1.0F + this.width * 20.0F; ++var15) {
                var31 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
                var17 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
                this.worldObj.spawnParticle(
                    "splash",
                    this.posX + (double) var31,
                    (double) (var30 + 1.0F),
                    this.posZ + (double) var17,
                    this.motionX,
                    this.motionY,
                    this.motionZ);
              }
            }
          }
        }

        if (this.ticksCatchable > 0) {
          this.motionY -=
              (double) (this.rand.nextFloat() * this.rand.nextFloat() * this.rand.nextFloat())
                  * 0.2D;
        }

        var13 = var26 * 2.0D - 1.0D;
        this.motionY += 0.03999999910593033D * var13;

        if (var26 > 0.0D) {
          var25 = (float) ((double) var25 * 0.9D);
          this.motionY *= 0.8D;
        }

        this.motionX *= (double) var25;
        this.motionY *= (double) var25;
        this.motionZ *= (double) var25;
        this.setPosition(this.posX, this.posY, this.posZ);
      }
    }
  }