Ejemplo n.º 1
0
  public void shoot(double d0, double d1, double d2, float f, float f1) {
    float f2 = MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2);

    d0 /= (double) f2;
    d1 /= (double) f2;
    d2 /= (double) f2;
    d0 +=
        this.random.nextGaussian()
            * (double) (this.random.nextBoolean() ? -1 : 1)
            * 0.007499999832361937D
            * (double) f1;
    d1 +=
        this.random.nextGaussian()
            * (double) (this.random.nextBoolean() ? -1 : 1)
            * 0.007499999832361937D
            * (double) f1;
    d2 +=
        this.random.nextGaussian()
            * (double) (this.random.nextBoolean() ? -1 : 1)
            * 0.007499999832361937D
            * (double) f1;
    d0 *= (double) f;
    d1 *= (double) f;
    d2 *= (double) f;
    this.motX = d0;
    this.motY = d1;
    this.motZ = d2;
    float f3 = MathHelper.sqrt(d0 * d0 + d2 * d2);

    this.lastYaw = this.yaw = (float) (Math.atan2(d0, d2) * 180.0D / 3.1415927410125732D);
    this.lastPitch =
        this.pitch = (float) (Math.atan2(d1, (double) f3) * 180.0D / 3.1415927410125732D);
    this.at = 0;
  }
Ejemplo n.º 2
0
  private void h(double d0, double d1, double d2) {
    if (this.vehicle != null) {
      int i = Math.round(MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);

      if (i > 0) {
        if (this.vehicle instanceof EntityMinecart) {
          this.a(StatisticList.r, i);
          if (this.c == null) {
            this.c =
                new ChunkCoordinates(
                    MathHelper.floor(this.locX),
                    MathHelper.floor(this.locY),
                    MathHelper.floor(this.locZ));
          } else if (this.c.b(
                  MathHelper.floor(this.locX),
                  MathHelper.floor(this.locY),
                  MathHelper.floor(this.locZ))
              >= 1000.0D) {
            this.a((Statistic) AchievementList.q, 1);
          }
        } else if (this.vehicle instanceof EntityBoat) {
          this.a(StatisticList.s, i);
        } else if (this.vehicle instanceof EntityPig) {
          this.a(StatisticList.t, i);
        }
      }
    }
  }
Ejemplo n.º 3
0
  public void collide(Entity entity) {
    if (entity.passenger != this && entity.vehicle != this) {
      if (!entity.T && !this.T) {
        double d0 = entity.locX - this.locX;
        double d1 = entity.locZ - this.locZ;
        double d2 = MathHelper.a(d0, d1);

        if (d2 >= 0.009999999776482582D) {
          d2 = (double) MathHelper.sqrt(d2);
          d0 /= d2;
          d1 /= d2;
          double d3 = 1.0D / d2;

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

          d0 *= d3;
          d1 *= d3;
          d0 *= 0.05000000074505806D;
          d1 *= 0.05000000074505806D;
          d0 *= (double) (1.0F - this.U);
          d1 *= (double) (1.0F - this.U);
          if (this.passenger == null) {
            this.g(-d0, 0.0D, -d1);
          }

          if (entity.passenger == null) {
            entity.g(d0, 0.0D, d1);
          }
        }
      }
    }
  }
Ejemplo n.º 4
0
  public void a() {
    this.a.pitch = 0.0F;
    if (this.d) {
      this.d = false;
      double d0 = this.e - this.a.locX;
      double d1 = this.f - (this.a.locY + (double) this.a.getHeadHeight());
      double d2 = this.g - this.a.locZ;
      double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2);
      // CraftBukkit start - Math -> TrigMath
      float f = (float) (TrigMath.atan2(d2, d0) * 180.0D / 3.1415927410125732D) - 90.0F;
      float f1 = (float) (-(TrigMath.atan2(d1, d3) * 180.0D / 3.1415927410125732D));
      // CraftBukkit end

      this.a.pitch = this.a(this.a.pitch, f1, this.c);
      this.a.as = this.a(this.a.as, f, this.b);
    } else {
      this.a.as = this.a(this.a.as, this.a.aq, 10.0F);
    }

    float f2 = MathHelper.g(this.a.as - this.a.aq);

    if (!this.a.getNavigation().f()) {
      if (f2 < -75.0F) {
        this.a.as = this.a.aq - 75.0F;
      }

      if (f2 > 75.0F) {
        this.a.as = this.a.aq + 75.0F;
      }
    }
  }
Ejemplo n.º 5
0
  public double f(double d0, double d1, double d2) {
    double d3 = this.locX - d0;
    double d4 = this.locY - d1;
    double d5 = this.locZ - d2;

    return (double) MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
  }
Ejemplo n.º 6
0
  public EntityArrow(
      World world, EntityLiving entityliving, EntityLiving entityliving1, float f, float f1) {
    super(world);
    this.l = 10.0D;
    this.shooter = entityliving;
    if (entityliving instanceof EntityHuman) {
      this.fromPlayer = 1;
    }

    this.locY = entityliving.locY + (double) entityliving.getHeadHeight() - 0.10000000149011612D;
    double d0 = entityliving1.locX - entityliving.locX;
    double d1 =
        entityliving1.locY
            + (double) entityliving1.getHeadHeight()
            - 0.699999988079071D
            - this.locY;
    double d2 = entityliving1.locZ - entityliving.locZ;
    double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2);

    if (d3 >= 1.0E-7D) {
      float f2 = (float) (Math.atan2(d2, d0) * 180.0D / 3.1415927410125732D) - 90.0F;
      float f3 = (float) (-(Math.atan2(d1, d3) * 180.0D / 3.1415927410125732D));
      double d4 = d0 / d3;
      double d5 = d2 / d3;

      this.setPositionRotation(entityliving.locX + d4, this.locY, entityliving.locZ + d5, f2, f3);
      this.height = 0.0F;
      float f4 = (float) d3 * 0.2F;

      this.shoot(d0, d1 + (double) f4, d2, f, f1);
    }
  }
Ejemplo n.º 7
0
  public double b(Vec3D vec3d) {
    double d0 = vec3d.a - this.a;
    double d1 = vec3d.b - this.b;
    double d2 = vec3d.c - this.c;

    return (double) MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
  }
Ejemplo n.º 8
0
  public void setDirection(double d0, double d1, double d2) {
    // CraftBukkit end
    d0 += this.random.nextGaussian() * 0.4D;
    d1 += this.random.nextGaussian() * 0.4D;
    d2 += this.random.nextGaussian() * 0.4D;
    double d3 = (double) MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2);

    this.dirX = d0 / d3 * 0.1D;
    this.dirY = d1 / d3 * 0.1D;
    this.dirZ = d2 / d3 * 0.1D;
  }
Ejemplo n.º 9
0
  public EntityFireball(
      World world, double d0, double d1, double d2, double d3, double d4, double d5) {
    super(world);
    this.a(1.0F, 1.0F);
    this.setPositionRotation(d0, d1, d2, this.yaw, this.pitch);
    this.setPosition(d0, d1, d2);
    double d6 = (double) MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5);

    this.dirX = d3 / d6 * 0.1D;
    this.dirY = d4 / d6 * 0.1D;
    this.dirZ = d5 / d6 * 0.1D;
  }
Ejemplo n.º 10
0
  public void e() {
    if (this.o > 0) {
      --this.o;
    }

    if (this.world.difficulty == 0
        && this.getHealth() < this.getMaxHealth()
        && this.ticksLived % 20 * 12 == 0) {
      this.heal(1);
    }

    this.inventory.i();
    this.r = this.s;
    super.e();
    this.al = this.P;
    this.am = this.Q;
    if (this.isSprinting()) {
      this.al = (float) ((double) this.al + (double) this.P * 0.3D);
      this.am = (float) ((double) this.am + (double) this.Q * 0.3D);
    }

    float f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);
    float f1 = (float) Math.atan(-this.motY * 0.20000000298023224D) * 15.0F;

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

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

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

    this.s += (f - this.s) * 0.4F;
    this.ay += (f1 - this.ay) * 0.8F;
    if (this.getHealth() > 0) {
      List list = this.world.getEntities(this, this.boundingBox.grow(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.dead) {
            this.l(entity);
          }
        }
      }
    }
  }
Ejemplo n.º 11
0
  public void checkMovement(double d0, double d1, double d2) {
    if (this.vehicle == null) {
      int i;

      if (this.a(Material.WATER)) {
        i = Math.round(MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
        if (i > 0) {
          this.a(StatisticList.q, i);
          this.c(0.015F * (float) i * 0.01F);
        }
      } else if (this.aU()) {
        i = Math.round(MathHelper.sqrt(d0 * d0 + d2 * d2) * 100.0F);
        if (i > 0) {
          this.a(StatisticList.m, i);
          this.c(0.015F * (float) i * 0.01F);
        }
      } else if (this.t()) {
        if (d1 > 0.0D) {
          this.a(StatisticList.o, (int) Math.round(d1 * 100.0D));
        }
      } else if (this.onGround) {
        i = Math.round(MathHelper.sqrt(d0 * d0 + d2 * d2) * 100.0F);
        if (i > 0) {
          this.a(StatisticList.l, i);
          if (this.isSprinting()) {
            this.c(0.099999994F * (float) i * 0.01F);
          } else {
            this.c(0.01F * (float) i * 0.01F);
          }
        }
      } else {
        i = Math.round(MathHelper.sqrt(d0 * d0 + d2 * d2) * 100.0F);
        if (i > 25) {
          this.a(StatisticList.p, i);
        }
      }
    }
  }
  public void setRotationToVelocity() {
    float f = MathHelper.sqrt(motX * motX + motZ * motZ);
    yaw = (float) ((Math.atan2(motX, motZ) * 180D) / Math.PI);

    for (pitch = (float) ((Math.atan2(motY, f) * 180D) / Math.PI);
        pitch - lastPitch < -180F;
        lastPitch -= 360F) {}

    for (; pitch - lastPitch >= 180F; lastPitch += 360F) {}

    for (; yaw - lastYaw < -180F; lastYaw -= 360F) {}

    for (; yaw - lastYaw >= 180F; lastYaw += 360F) {}
  }
Ejemplo n.º 13
0
  protected void X() {
    float f =
        MathHelper.sqrt(
                this.motX * this.motX * 0.20000000298023224D
                    + this.motY * this.motY
                    + this.motZ * this.motZ * 0.20000000298023224D)
            * 0.2F;

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

    this.makeSound(this.aa(), f, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
    float f1 = (float) MathHelper.floor(this.getBoundingBox().b);

    int i;
    float f2;
    float f3;

    for (i = 0; (float) i < 1.0F + this.width * 20.0F; ++i) {
      f2 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width;
      f3 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width;
      this.world.addParticle(
          EnumParticle.WATER_BUBBLE,
          this.locX + (double) f2,
          (double) (f1 + 1.0F),
          this.locZ + (double) f3,
          this.motX,
          this.motY - (double) (this.random.nextFloat() * 0.2F),
          this.motZ,
          new int[0]);
    }

    for (i = 0; (float) i < 1.0F + this.width * 20.0F; ++i) {
      f2 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width;
      f3 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width;
      this.world.addParticle(
          EnumParticle.WATER_SPLASH,
          this.locX + (double) f2,
          (double) (f1 + 1.0F),
          this.locZ + (double) f3,
          this.motX,
          this.motY,
          this.motZ,
          new int[0]);
    }
  }
Ejemplo n.º 14
0
  public void a(Entity entity, float f, double d0, double d1) {
    if (this.random.nextDouble() >= this.getAttributeInstance(GenericAttributes.c).getValue()) {
      this.an = true;
      float f1 = MathHelper.sqrt(d0 * d0 + d1 * d1);
      float f2 = 0.4F;

      this.motX /= 2.0D;
      this.motY /= 2.0D;
      this.motZ /= 2.0D;
      this.motX -= d0 / (double) f1 * (double) f2;
      this.motY += (double) f2;
      this.motZ -= d1 / (double) f1 * (double) f2;
      if (this.motY > 0.4000000059604645D) {
        this.motY = 0.4000000059604645D;
      }
    }
  }
Ejemplo n.º 15
0
  @Override
  public void a(Entity entity, int i, double d0, double d1) {
    this.an = true;
    float f = MathHelper.sqrt(d0 * d0 + d1 * d1);
    // float f1 = 0.4F;
    float f1 = Dota.creepknockbackamp;

    this.motX /= 2.0D;
    this.motY /= 2.0D;
    this.motZ /= 2.0D;
    this.motX -= d0 / (double) f * (double) f1;
    this.motY += (double) f1;
    this.motZ -= d1 / (double) f * (double) f1;
    if (this.motY > 0.4000000059604645D) {
      this.motY = 0.4000000059604645D;
    }
  }
  private void f() {
    if (this.g == 1) {
      EntityArrow entityarrow = new EntityArrow(this.a, this.b, this.c, 1.6F, 12.0F);

      this.a.makeSound(this.b, "random.bow", 1.0F, 1.0F / (this.b.au().nextFloat() * 0.4F + 0.8F));
      this.a.addEntity(entityarrow);
    } else if (this.g == 2) {
      EntitySnowball entitysnowball = new EntitySnowball(this.a, this.b);
      double d0 = this.c.locX - this.b.locX;
      double d1 = this.c.locY + this.c.getHeadHeight() - 1.100000023841858D - entitysnowball.locY;
      double d2 = this.c.locZ - this.b.locZ;
      float f = MathHelper.sqrt(d0 * d0 + d2 * d2) * 0.2F;

      entitysnowball.c(d0, d1 + f, d2, 1.6F, 12.0F);
      this.a.makeSound(this.b, "random.bow", 1.0F, 1.0F / (this.b.au().nextFloat() * 0.4F + 0.8F));
      this.a.addEntity(entitysnowball);
    }
  }
Ejemplo n.º 17
0
  public EntityFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) {
    super(world);
    this.shooter = entityliving;
    this.a(1.0F, 1.0F);
    this.setPositionRotation(
        entityliving.locX,
        entityliving.locY,
        entityliving.locZ,
        entityliving.yaw,
        entityliving.pitch);
    this.setPosition(this.locX, this.locY, this.locZ);
    this.height = 0.0F;
    this.motX = this.motY = this.motZ = 0.0D;
    d0 += this.random.nextGaussian() * 0.4D;
    d1 += this.random.nextGaussian() * 0.4D;
    d2 += this.random.nextGaussian() * 0.4D;
    double d3 = (double) MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2);

    this.dirX = d0 / d3 * 0.1D;
    this.dirY = d1 / d3 * 0.1D;
    this.dirZ = d2 / d3 * 0.1D;
  }
Ejemplo n.º 18
0
  public void collide(Entity var1) {
    if (!this.world.isClientSide) {
      if (!var1.noclip && !this.noclip) {
        if (var1 != this.passenger) {
          if (var1 instanceof EntityLiving
              && !(var1 instanceof EntityHuman)
              && !(var1 instanceof EntityIronGolem)
              && this.s() == EntityMinecartAbstract.EnumMinecartType.RIDEABLE
              && this.motX * this.motX + this.motZ * this.motZ > 0.01D
              && this.passenger == null
              && var1.vehicle == null) {
            var1.mount(this);
          }

          double var2 = var1.locX - this.locX;
          double var4 = var1.locZ - this.locZ;
          double var6 = var2 * var2 + var4 * var4;
          if (var6 >= 9.999999747378752E-5D) {
            var6 = (double) MathHelper.sqrt(var6);
            var2 /= var6;
            var4 /= var6;
            double var8 = 1.0D / var6;
            if (var8 > 1.0D) {
              var8 = 1.0D;
            }

            var2 *= var8;
            var4 *= var8;
            var2 *= 0.10000000149011612D;
            var4 *= 0.10000000149011612D;
            var2 *= (double) (1.0F - this.U);
            var4 *= (double) (1.0F - this.U);
            var2 *= 0.5D;
            var4 *= 0.5D;
            if (var1 instanceof EntityMinecartAbstract) {
              double var10 = var1.locX - this.locX;
              double var12 = var1.locZ - this.locZ;
              Vec3D var14 = (new Vec3D(var10, 0.0D, var12)).a();
              Vec3D var15 =
                  (new Vec3D(
                          (double) MathHelper.cos(this.yaw * 3.1415927F / 180.0F),
                          0.0D,
                          (double) MathHelper.sin(this.yaw * 3.1415927F / 180.0F)))
                      .a();
              double var16 = Math.abs(var14.b(var15));
              if (var16 < 0.800000011920929D) {
                return;
              }

              double var18 = var1.motX + this.motX;
              double var20 = var1.motZ + this.motZ;
              if (((EntityMinecartAbstract) var1).s()
                      == EntityMinecartAbstract.EnumMinecartType.FURNACE
                  && this.s() != EntityMinecartAbstract.EnumMinecartType.FURNACE) {
                this.motX *= 0.20000000298023224D;
                this.motZ *= 0.20000000298023224D;
                this.g(var1.motX - var2, 0.0D, var1.motZ - var4);
                var1.motX *= 0.949999988079071D;
                var1.motZ *= 0.949999988079071D;
              } else if (((EntityMinecartAbstract) var1).s()
                      != EntityMinecartAbstract.EnumMinecartType.FURNACE
                  && this.s() == EntityMinecartAbstract.EnumMinecartType.FURNACE) {
                var1.motX *= 0.20000000298023224D;
                var1.motZ *= 0.20000000298023224D;
                var1.g(this.motX + var2, 0.0D, this.motZ + var4);
                this.motX *= 0.949999988079071D;
                this.motZ *= 0.949999988079071D;
              } else {
                var18 /= 2.0D;
                var20 /= 2.0D;
                this.motX *= 0.20000000298023224D;
                this.motZ *= 0.20000000298023224D;
                this.g(var18 - var2, 0.0D, var20 - var4);
                var1.motX *= 0.20000000298023224D;
                var1.motZ *= 0.20000000298023224D;
                var1.g(var18 + var2, 0.0D, var20 + var4);
              }
            } else {
              this.g(-var2, 0.0D, -var4);
              var1.g(var2 / 4.0D, 0.0D, var4 / 4.0D);
            }
          }
        }
      }
    }
  }
Ejemplo n.º 19
0
  public void e(float f, float f1) {
    double d0;

    if (this.H() && (!(this instanceof EntityHuman) || !((EntityHuman) this).abilities.isFlying)) {
      d0 = this.locY;
      this.a(f, f1, this.bf() ? 0.04F : 0.02F);
      this.move(this.motX, this.motY, this.motZ);
      this.motX *= 0.800000011920929D;
      this.motY *= 0.800000011920929D;
      this.motZ *= 0.800000011920929D;
      this.motY -= 0.02D;
      if (this.positionChanged
          && this.c(this.motX, this.motY + 0.6000000238418579D - this.locY + d0, this.motZ)) {
        this.motY = 0.30000001192092896D;
      }
    } else if (this.J()
        && (!(this instanceof EntityHuman) || !((EntityHuman) this).abilities.isFlying)) {
      d0 = this.locY;
      this.a(f, f1, 0.02F);
      this.move(this.motX, this.motY, this.motZ);
      this.motX *= 0.5D;
      this.motY *= 0.5D;
      this.motZ *= 0.5D;
      this.motY -= 0.02D;
      if (this.positionChanged
          && this.c(this.motX, this.motY + 0.6000000238418579D - this.locY + d0, this.motZ)) {
        this.motY = 0.30000001192092896D;
      }
    } else {
      float f2 = 0.91F;

      if (this.onGround) {
        f2 = 0.54600006F;
        int i =
            this.world.getTypeId(
                MathHelper.floor(this.locX),
                MathHelper.floor(this.boundingBox.b) - 1,
                MathHelper.floor(this.locZ));

        if (i > 0) {
          f2 = Block.byId[i].frictionFactor * 0.91F;
        }
      }

      float f3 = 0.16277136F / (f2 * f2 * f2);
      float f4;

      if (this.onGround) {
        f4 = this.bg() * f3;
      } else {
        f4 = this.aR;
      }

      this.a(f, f1, f4);
      f2 = 0.91F;
      if (this.onGround) {
        f2 = 0.54600006F;
        int j =
            this.world.getTypeId(
                MathHelper.floor(this.locX),
                MathHelper.floor(this.boundingBox.b) - 1,
                MathHelper.floor(this.locZ));

        if (j > 0) {
          f2 = Block.byId[j].frictionFactor * 0.91F;
        }
      }

      if (this.e()) {
        float f5 = 0.15F;

        if (this.motX < (double) (-f5)) {
          this.motX = (double) (-f5);
        }

        if (this.motX > (double) f5) {
          this.motX = (double) f5;
        }

        if (this.motZ < (double) (-f5)) {
          this.motZ = (double) (-f5);
        }

        if (this.motZ > (double) f5) {
          this.motZ = (double) f5;
        }

        this.fallDistance = 0.0F;
        if (this.motY < -0.15D) {
          this.motY = -0.15D;
        }

        boolean flag = this.isSneaking() && this instanceof EntityHuman;

        if (flag && this.motY < 0.0D) {
          this.motY = 0.0D;
        }
      }

      this.move(this.motX, this.motY, this.motZ);
      if (this.positionChanged && this.e()) {
        this.motY = 0.2D;
      }

      if (this.world.isStatic
          && (!this.world.isLoaded((int) this.locX, 0, (int) this.locZ)
              || !this.world.getChunkAtWorldCoords((int) this.locX, (int) this.locZ).d)) {
        if (this.locY > 0.0D) {
          this.motY = -0.1D;
        } else {
          this.motY = 0.0D;
        }
      } else {
        this.motY -= 0.08D;
      }

      this.motY *= 0.9800000190734863D;
      this.motX *= (double) f2;
      this.motZ *= (double) f2;
    }

    this.aF = this.aG;
    d0 = this.locX - this.lastX;
    double d1 = this.locZ - this.lastZ;
    float f6 = MathHelper.sqrt(d0 * d0 + d1 * d1) * 4.0F;

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

    this.aG += (f6 - this.aG) * 0.4F;
    this.aH += this.aG;
  }
Ejemplo n.º 20
0
  public void l_() {
    if (!this.world.isStatic
        && (this.shooter != null && this.shooter.dead
            || !this.world.isLoaded((int) this.locX, (int) this.locY, (int) this.locZ))) {
      this.die();
    } else {
      super.l_();
      this.setOnFire(1);
      if (this.i) {
        int i = this.world.getTypeId(this.e, this.f, this.g);

        if (i == this.h) {
          ++this.j;
          if (this.j == 600) {
            this.die();
          }

          return;
        }

        this.i = false;
        this.motX *= (double) (this.random.nextFloat() * 0.2F);
        this.motY *= (double) (this.random.nextFloat() * 0.2F);
        this.motZ *= (double) (this.random.nextFloat() * 0.2F);
        this.j = 0;
        this.au = 0;
      } else {
        ++this.au;
      }

      Vec3D vec3d = this.world.getVec3DPool().create(this.locX, this.locY, this.locZ);
      Vec3D vec3d1 =
          this.world
              .getVec3DPool()
              .create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
      MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1);

      vec3d = this.world.getVec3DPool().create(this.locX, this.locY, this.locZ);
      vec3d1 =
          this.world
              .getVec3DPool()
              .create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
      if (movingobjectposition != null) {
        vec3d1 =
            this.world
                .getVec3DPool()
                .create(
                    movingobjectposition.pos.c,
                    movingobjectposition.pos.d,
                    movingobjectposition.pos.e);
      }

      Entity entity = null;
      List list =
          this.world.getEntities(
              this, this.boundingBox.a(this.motX, this.motY, this.motZ).grow(1.0D, 1.0D, 1.0D));
      double d0 = 0.0D;

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

        if (entity1.K() && (!entity1.h(this.shooter) || this.au >= 25)) {
          float f = 0.3F;
          AxisAlignedBB axisalignedbb =
              entity1.boundingBox.grow((double) f, (double) f, (double) f);
          MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);

          if (movingobjectposition1 != null) {
            double d1 =
                vec3d.distanceSquared(
                    movingobjectposition1.pos); // CraftBukkit - distance efficiency

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

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

      if (movingobjectposition != null) {
        this.a(movingobjectposition);

        // CraftBukkit start
        if (this.dead) {
          org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this);
        }
        // CraftBukkit end
      }

      this.locX += this.motX;
      this.locY += this.motY;
      this.locZ += this.motZ;
      float f1 = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);

      this.yaw = (float) (Math.atan2(this.motZ, this.motX) * 180.0D / 3.1415927410125732D) + 90.0F;

      for (this.pitch =
              (float) (Math.atan2((double) f1, this.motY) * 180.0D / 3.1415927410125732D) - 90.0F;
          this.pitch - this.lastPitch < -180.0F;
          this.lastPitch -= 360.0F) {;
      }

      while (this.pitch - this.lastPitch >= 180.0F) {
        this.lastPitch += 360.0F;
      }

      while (this.yaw - this.lastYaw < -180.0F) {
        this.lastYaw -= 360.0F;
      }

      while (this.yaw - this.lastYaw >= 180.0F) {
        this.lastYaw += 360.0F;
      }

      this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F;
      this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F;
      float f2 = this.c();

      if (this.G()) {
        for (int k = 0; k < 4; ++k) {
          float f3 = 0.25F;

          this.world.addParticle(
              "bubble",
              this.locX - this.motX * (double) f3,
              this.locY - this.motY * (double) f3,
              this.locZ - this.motZ * (double) f3,
              this.motX,
              this.motY,
              this.motZ);
        }

        f2 = 0.8F;
      }

      this.motX += this.dirX;
      this.motY += this.dirY;
      this.motZ += this.dirZ;
      this.motX *= (double) f2;
      this.motY *= (double) f2;
      this.motZ *= (double) f2;
      this.world.addParticle("smoke", this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D);
      this.setPosition(this.locX, this.locY, this.locZ);
    }
  }
Ejemplo n.º 21
0
  /** Does the second part of the explosion (sound, particles, drop spawn) */
  public void a(boolean var1) {
    this.world.makeSound(
        this.posX,
        this.posY,
        this.posZ,
        "random.explode",
        4.0F,
        (1.0F + (this.world.random.nextFloat() - this.world.random.nextFloat()) * 0.2F) * 0.7F);

    if (this.size >= 2.0F && this.b) {
      this.world.addParticle("hugeexplosion", this.posX, this.posY, this.posZ, 1.0D, 0.0D, 0.0D);
    } else {
      this.world.addParticle("largeexplode", this.posX, this.posY, this.posZ, 1.0D, 0.0D, 0.0D);
    }

    Iterator var2;
    ChunkPosition var3;
    int var4;
    int var5;
    int var6;
    int var7;

    if (this.b) {
      var2 = this.field_77281_g.iterator();

      while (var2.hasNext()) {
        var3 = (ChunkPosition) var2.next();
        var4 = var3.x;
        var5 = var3.y;
        var6 = var3.z;
        var7 = this.world.getTypeId(var4, var5, var6);

        if (var1) {
          double var8 = (double) ((float) var4 + this.world.random.nextFloat());
          double var10 = (double) ((float) var5 + this.world.random.nextFloat());
          double var12 = (double) ((float) var6 + this.world.random.nextFloat());
          double var14 = var8 - this.posX;
          double var16 = var10 - this.posY;
          double var18 = var12 - this.posZ;
          double var20 = (double) MathHelper.sqrt(var14 * var14 + var16 * var16 + var18 * var18);
          var14 /= var20;
          var16 /= var20;
          var18 /= var20;
          double var22 = 0.5D / (var20 / (double) this.size + 0.1D);
          var22 *= (double) (this.world.random.nextFloat() * this.world.random.nextFloat() + 0.3F);
          var14 *= var22;
          var16 *= var22;
          var18 *= var22;
          this.world.addParticle(
              "explode",
              (var8 + this.posX * 1.0D) / 2.0D,
              (var10 + this.posY * 1.0D) / 2.0D,
              (var12 + this.posZ * 1.0D) / 2.0D,
              var14,
              var16,
              var18);
          this.world.addParticle("smoke", var8, var10, var12, var14, var16, var18);
        }

        if (var7 > 0) {
          Block.byId[var7].dropNaturally(
              this.world, var4, var5, var6, this.world.getData(var4, var5, var6), 0.3F, 0);

          if (this.world.setRawTypeIdAndData(var4, var5, var6, 0, 0, this.world.isStatic)) {
            this.world.applyPhysics(var4, var5, var6, 0);
          }

          Block.byId[var7].wasExploded(this.world, var4, var5, var6);
        }
      }
    }

    if (this.a) {
      var2 = this.field_77281_g.iterator();

      while (var2.hasNext()) {
        var3 = (ChunkPosition) var2.next();
        var4 = var3.x;
        var5 = var3.y;
        var6 = var3.z;
        var7 = this.world.getTypeId(var4, var5, var6);
        int var24 = this.world.getTypeId(var4, var5 - 1, var6);

        if (var7 == 0 && Block.q[var24] && this.j.nextInt(3) == 0) {
          this.world.setTypeId(var4, var5, var6, Block.FIRE.id);
        }
      }
    }
  }
Ejemplo n.º 22
0
  /** Does the first part of the explosion (destroy blocks) */
  public void a() {
    float var1 = this.size;
    HashSet var2 = new HashSet();
    int var3;
    int var4;
    int var5;
    double var6;
    double var8;
    double var10;

    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 var12 =
                (double) ((float) var3 / ((float) this.field_77289_h - 1.0F) * 2.0F - 1.0F);
            double var14 =
                (double) ((float) var4 / ((float) this.field_77289_h - 1.0F) * 2.0F - 1.0F);
            double var16 =
                (double) ((float) var5 / ((float) this.field_77289_h - 1.0F) * 2.0F - 1.0F);
            double var18 = Math.sqrt(var12 * var12 + var14 * var14 + var16 * var16);
            var12 /= var18;
            var14 /= var18;
            var16 /= var18;
            float var20 = this.size * (0.7F + this.world.random.nextFloat() * 0.6F);
            var6 = this.posX;
            var8 = this.posY;
            var10 = this.posZ;

            for (float var21 = 0.3F; var20 > 0.0F; var20 -= var21 * 0.75F) {
              int var22 = MathHelper.floor(var6);
              int var23 = MathHelper.floor(var8);
              int var24 = MathHelper.floor(var10);
              int var25 = this.world.getTypeId(var22, var23, var24);

              if (var25 > 0) {
                Block var26 = Block.byId[var25];
                float var27 =
                    this.source != null
                        ? this.source.func_82146_a(this, var26, var22, var23, var24)
                        : var26.getExplosionResistance(
                            this.source,
                            this.world,
                            var22,
                            var23,
                            var24,
                            this.posX,
                            this.posY,
                            this.posZ);
                var20 -= (var27 + 0.3F) * var21;
              }

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

              var6 += var12 * (double) var21;
              var8 += var14 * (double) var21;
              var10 += var16 * (double) var21;
            }
          }
        }
      }
    }

    this.field_77281_g.addAll(var2);
    this.size *= 2.0F;
    var3 = MathHelper.floor(this.posX - (double) this.size - 1.0D);
    var4 = MathHelper.floor(this.posX + (double) this.size + 1.0D);
    var5 = MathHelper.floor(this.posY - (double) this.size - 1.0D);
    int var28 = MathHelper.floor(this.posY + (double) this.size + 1.0D);
    int var13 = MathHelper.floor(this.posZ - (double) this.size - 1.0D);
    int var29 = MathHelper.floor(this.posZ + (double) this.size + 1.0D);
    List var15 =
        this.world.getEntities(
            this.source,
            AxisAlignedBB.a()
                .a(
                    (double) var3,
                    (double) var5,
                    (double) var13,
                    (double) var4,
                    (double) var28,
                    (double) var29));
    Vec3D var30 = this.world.getVec3DPool().create(this.posX, this.posY, this.posZ);

    for (int var17 = 0; var17 < var15.size(); ++var17) {
      Entity var31 = (Entity) var15.get(var17);
      double var19 = var31.f(this.posX, this.posY, this.posZ) / (double) this.size;

      if (var19 <= 1.0D) {
        var6 = var31.locX - this.posX;
        var8 = var31.locY + (double) var31.getHeadHeight() - this.posY;
        var10 = var31.locZ - this.posZ;
        double var33 = (double) MathHelper.sqrt(var6 * var6 + var8 * var8 + var10 * var10);

        if (var33 != 0.0D) {
          var6 /= var33;
          var8 /= var33;
          var10 /= var33;
          double var32 = (double) this.world.a(var30, var31.boundingBox);
          double var34 = (1.0D - var19) * var32;
          var31.damageEntity(
              DamageSource.EXPLOSION,
              (int) ((var34 * var34 + var34) / 2.0D * 8.0D * (double) this.size + 1.0D));
          var31.motX += var6 * var34;
          var31.motY += var8 * var34;
          var31.motZ += var10 * var34;

          if (var31 instanceof EntityHuman) {
            this.field_77288_k.put(
                (EntityHuman) var31,
                this.world.getVec3DPool().create(var6 * var34, var8 * var34, var10 * var34));
          }
        }
      }
    }

    this.size = var1;
  }
Ejemplo n.º 23
0
  public void e(float f, float f1) {
    if (this.passenger != null && this.passenger instanceof EntityLiving && this.cu()) {
      this.lastYaw = this.yaw = this.passenger.yaw;
      this.pitch = this.passenger.pitch * 0.5F;
      this.b(this.yaw, this.pitch);
      this.aO = this.aM = this.yaw;
      f = ((EntityLiving) this.passenger).bd * 0.5F;
      f1 = ((EntityLiving) this.passenger).be;
      if (f1 <= 0.0F) {
        f1 *= 0.25F;
        this.bP = 0;
      }

      if (this.onGround && this.bt == 0.0F && this.cn() && !this.bI) {
        f = 0.0F;
        f1 = 0.0F;
      }

      if (this.bt > 0.0F && !this.cj() && this.onGround) {
        this.motY = this.getJumpStrength() * (double) this.bt;
        if (this.hasEffect(MobEffectList.JUMP)) {
          this.motY +=
              (double) ((float) (this.getEffect(MobEffectList.JUMP).getAmplifier() + 1) * 0.1F);
        }

        this.j(true);
        this.al = true;
        if (f1 > 0.0F) {
          float f2 = MathHelper.sin(this.yaw * 3.1415927F / 180.0F);
          float f3 = MathHelper.cos(this.yaw * 3.1415927F / 180.0F);

          this.motX += (double) (-0.4F * f2 * this.bt);
          this.motZ += (double) (0.4F * f3 * this.bt);
          this.makeSound("mob.horse.jump", 0.4F, 1.0F);
        }

        this.bt = 0.0F;
      }

      this.W = 1.0F;
      this.aQ = this.bk() * 0.1F;
      if (!this.world.isStatic) {
        this.i((float) this.getAttributeInstance(GenericAttributes.d).getValue());
        super.e(f, f1);
      }

      if (this.onGround) {
        this.bt = 0.0F;
        this.j(false);
      }

      this.aE = this.aF;
      double d0 = this.locX - this.lastX;
      double d1 = this.locZ - this.lastZ;
      float f4 = MathHelper.sqrt(d0 * d0 + d1 * d1) * 4.0F;

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

      this.aF += (f4 - this.aF) * 0.4F;
      this.aG += this.aF;
    } else {
      this.W = 0.5F;
      this.aQ = 0.02F;
      super.e(f, f1);
    }
  }
Ejemplo n.º 24
0
  public void j_() {
    super.j_();
    if (this.lastPitch == 0.0F && this.lastYaw == 0.0F) {
      float f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);

      this.lastYaw =
          this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);
      this.lastPitch =
          this.pitch = (float) (Math.atan2(this.motY, (double) f) * 180.0D / 3.1415927410125732D);
    }

    int i = this.world.getTypeId(this.d, this.e, this.f);

    if (i > 0) {
      Block.byId[i].updateShape(this.world, this.d, this.e, this.f);
      AxisAlignedBB axisalignedbb = Block.byId[i].e(this.world, this.d, this.e, this.f);

      if (axisalignedbb != null
          && axisalignedbb.a(this.world.getVec3DPool().create(this.locX, this.locY, this.locZ))) {
        this.inGround = true;
      }
    }

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

    if (this.inGround) {
      int j = this.world.getTypeId(this.d, this.e, this.f);
      int k = this.world.getData(this.d, this.e, this.f);

      if (j == this.g && k == this.h) {
        ++this.j;
        if (this.j == 1200) {
          this.die();
        }
      } else {
        this.inGround = false;
        this.motX *= (double) (this.random.nextFloat() * 0.2F);
        this.motY *= (double) (this.random.nextFloat() * 0.2F);
        this.motZ *= (double) (this.random.nextFloat() * 0.2F);
        this.j = 0;
        this.at = 0;
      }
    } else {
      ++this.at;
      Vec3D vec3d = this.world.getVec3DPool().create(this.locX, this.locY, this.locZ);
      Vec3D vec3d1 =
          this.world
              .getVec3DPool()
              .create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
      MovingObjectPosition movingobjectposition = this.world.rayTrace(vec3d, vec3d1, false, true);

      vec3d = this.world.getVec3DPool().create(this.locX, this.locY, this.locZ);
      vec3d1 =
          this.world
              .getVec3DPool()
              .create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
      if (movingobjectposition != null) {
        vec3d1 =
            this.world
                .getVec3DPool()
                .create(
                    movingobjectposition.pos.c,
                    movingobjectposition.pos.d,
                    movingobjectposition.pos.e);
      }

      Entity entity = null;
      List list =
          this.world.getEntities(
              this, this.boundingBox.a(this.motX, this.motY, this.motZ).grow(1.0D, 1.0D, 1.0D));
      double d0 = 0.0D;

      int l;
      float f1;

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

        if (entity1.L() && (entity1 != this.shooter || this.at >= 5)) {
          f1 = 0.3F;
          AxisAlignedBB axisalignedbb1 =
              entity1.boundingBox.grow((double) f1, (double) f1, (double) f1);
          MovingObjectPosition movingobjectposition1 = axisalignedbb1.a(vec3d, vec3d1);

          if (movingobjectposition1 != null) {
            double d1 =
                vec3d.distanceSquared(
                    movingobjectposition1.pos); // CraftBukkit - distance efficiency

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

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

      float f2;
      float f3;

      if (movingobjectposition != null) {
        // CraftBukkit start
        Projectile projectile = (Projectile) this.getBukkitEntity();
        ProjectileHitEvent phe = new ProjectileHitEvent(projectile);
        this.world.getServer().getPluginManager().callEvent(phe);
        // CraftBukkit end
        if (movingobjectposition.entity != null) {
          f2 =
              MathHelper.sqrt(
                  this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ);
          int i1 = MathHelper.f((double) f2 * this.damage);

          if (this.d()) {
            i1 += this.random.nextInt(i1 / 2 + 2);
          }

          DamageSource damagesource = null;

          if (this.shooter == null) {
            damagesource = DamageSource.arrow(this, this);
          } else {
            damagesource = DamageSource.arrow(this, this.shooter);
          }

          // CraftBukkit start - moved damage call
          if (movingobjectposition.entity.damageEntity(damagesource, i1)) {
            if (this.isBurning()
                && !(movingobjectposition.entity instanceof EntityEnderman)
                && (!(movingobjectposition.entity instanceof EntityPlayer)
                    || !(this.shooter instanceof EntityPlayer)
                    || this.world
                        .pvpMode)) { // CraftBukkit - abide by pvp setting if destination is a
                                     // player.
              EntityCombustByEntityEvent combustEvent =
                  new EntityCombustByEntityEvent(
                      this.getBukkitEntity(), entity.getBukkitEntity(), 5);
              org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);

              if (!combustEvent.isCancelled()) {
                movingobjectposition.entity.setOnFire(combustEvent.getDuration());
              }
              // CraftBukkit end
            }

            // if (movingobjectposition.entity.damageEntity(damagesource, i1)) { // CraftBukkit -
            // moved up
            if (movingobjectposition.entity instanceof EntityLiving) {
              EntityLiving entityliving = (EntityLiving) movingobjectposition.entity;

              if (!this.world.isStatic) {
                entityliving.r(entityliving.bJ() + 1);
              }

              if (this.av > 0) {
                f3 = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);

                if (f3 > 0.0F) {
                  movingobjectposition.entity.g(
                      this.motX * (double) this.av * 0.6000000238418579D / (double) f3,
                      0.1D,
                      this.motZ * (double) this.av * 0.6000000238418579D / (double) f3);
                }
              }

              if (this.shooter != null) {
                EnchantmentThorns.a(this.shooter, entityliving, this.random);
              }

              if (this.shooter != null
                  && movingobjectposition.entity != this.shooter
                  && movingobjectposition.entity instanceof EntityHuman
                  && this.shooter instanceof EntityPlayer) {
                ((EntityPlayer) this.shooter).playerConnection.sendPacket(new Packet70Bed(6, 0));
              }
            }

            this.makeSound("random.bowhit", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
            if (!(movingobjectposition.entity instanceof EntityEnderman)) {
              this.die();
            }
          } else {
            this.motX *= -0.10000000149011612D;
            this.motY *= -0.10000000149011612D;
            this.motZ *= -0.10000000149011612D;
            this.yaw += 180.0F;
            this.lastYaw += 180.0F;
            this.at = 0;
          }
        } else {
          this.d = movingobjectposition.b;
          this.e = movingobjectposition.c;
          this.f = movingobjectposition.d;
          this.g = this.world.getTypeId(this.d, this.e, this.f);
          this.h = this.world.getData(this.d, this.e, this.f);
          this.motX = (double) ((float) (movingobjectposition.pos.c - this.locX));
          this.motY = (double) ((float) (movingobjectposition.pos.d - this.locY));
          this.motZ = (double) ((float) (movingobjectposition.pos.e - this.locZ));
          f2 =
              MathHelper.sqrt(
                  this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ);
          this.locX -= this.motX / (double) f2 * 0.05000000074505806D;
          this.locY -= this.motY / (double) f2 * 0.05000000074505806D;
          this.locZ -= this.motZ / (double) f2 * 0.05000000074505806D;
          this.makeSound("random.bowhit", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
          this.inGround = true;
          this.shake = 7;
          this.e(false);
          if (this.g != 0) {
            Block.byId[this.g].a(this.world, this.d, this.e, this.f, this);
          }
        }
      }

      if (this.d()) {
        for (l = 0; l < 4; ++l) {
          this.world.addParticle(
              "crit",
              this.locX + this.motX * (double) l / 4.0D,
              this.locY + this.motY * (double) l / 4.0D,
              this.locZ + this.motZ * (double) l / 4.0D,
              -this.motX,
              -this.motY + 0.2D,
              -this.motZ);
        }
      }

      this.locX += this.motX;
      this.locY += this.motY;
      this.locZ += this.motZ;
      f2 = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);
      this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);

      for (this.pitch = (float) (Math.atan2(this.motY, (double) f2) * 180.0D / 3.1415927410125732D);
          this.pitch - this.lastPitch < -180.0F;
          this.lastPitch -= 360.0F) {;
      }

      while (this.pitch - this.lastPitch >= 180.0F) {
        this.lastPitch += 360.0F;
      }

      while (this.yaw - this.lastYaw < -180.0F) {
        this.lastYaw -= 360.0F;
      }

      while (this.yaw - this.lastYaw >= 180.0F) {
        this.lastYaw += 360.0F;
      }

      this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F;
      this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F;
      float f4 = 0.99F;

      f1 = 0.05F;
      if (this.H()) {
        for (int j1 = 0; j1 < 4; ++j1) {
          f3 = 0.25F;
          this.world.addParticle(
              "bubble",
              this.locX - this.motX * (double) f3,
              this.locY - this.motY * (double) f3,
              this.locZ - this.motZ * (double) f3,
              this.motX,
              this.motY,
              this.motZ);
        }

        f4 = 0.8F;
      }

      this.motX *= (double) f4;
      this.motY *= (double) f4;
      this.motZ *= (double) f4;
      this.motY -= (double) f1;
      this.setPosition(this.locX, this.locY, this.locZ);
      this.D();
    }
  }
Ejemplo n.º 25
0
  public void j_() {
    if (this.g != null) {
      this.g.a();
    }

    if (this.j() > 0) {
      this.h(this.j() - 1);
    }

    if (this.getDamage() > 0) {
      this.setDamage(this.getDamage() - 1);
    }

    if (this.locY < -64.0D) {
      this.C();
    }

    if (this.h() && this.random.nextInt(4) == 0) {
      this.world.addParticle(
          "largesmoke", this.locX, this.locY + 0.8D, this.locZ, 0.0D, 0.0D, 0.0D);
    }

    if (this.world.isStatic) {
      if (this.j > 0) {
        double d0 = this.locX + (this.as - this.locX) / (double) this.j;
        double d1 = this.locY + (this.at - this.locY) / (double) this.j;
        double d2 = this.locZ + (this.au - this.locZ) / (double) this.j;
        double d3 = MathHelper.g(this.av - (double) this.yaw);

        this.yaw = (float) ((double) this.yaw + d3 / (double) this.j);
        this.pitch =
            (float) ((double) this.pitch + (this.aw - (double) this.pitch) / (double) this.j);
        --this.j;
        this.setPosition(d0, d1, d2);
        this.b(this.yaw, this.pitch);
      } else {
        this.setPosition(this.locX, this.locY, this.locZ);
        this.b(this.yaw, this.pitch);
      }
    } else {
      this.lastX = this.locX;
      this.lastY = this.locY;
      this.lastZ = this.locZ;
      this.motY -= 0.03999999910593033D;
      int i = MathHelper.floor(this.locX);
      int j = MathHelper.floor(this.locY);
      int k = MathHelper.floor(this.locZ);

      if (BlockMinecartTrack.e_(this.world, i, j - 1, k)) {
        --j;
      }

      double d4 = 0.4D;
      double d5 = 0.0078125D;
      int l = this.world.getTypeId(i, j, k);

      if (BlockMinecartTrack.d(l)) {
        this.fallDistance = 0.0F;
        Vec3D vec3d = this.a(this.locX, this.locY, this.locZ);
        int i1 = this.world.getData(i, j, k);

        this.locY = (double) j;
        boolean flag = false;
        boolean flag1 = false;

        if (l == Block.GOLDEN_RAIL.id) {
          flag = (i1 & 8) != 0;
          flag1 = !flag;
        }

        if (((BlockMinecartTrack) Block.byId[l]).p()) {
          i1 &= 7;
        }

        if (i1 >= 2 && i1 <= 5) {
          this.locY = (double) (j + 1);
        }

        if (i1 == 2) {
          this.motX -= d5;
        }

        if (i1 == 3) {
          this.motX += d5;
        }

        if (i1 == 4) {
          this.motZ += d5;
        }

        if (i1 == 5) {
          this.motZ -= d5;
        }

        int[][] aint = matrix[i1];
        double d6 = (double) (aint[1][0] - aint[0][0]);
        double d7 = (double) (aint[1][2] - aint[0][2]);
        double d8 = Math.sqrt(d6 * d6 + d7 * d7);
        double d9 = this.motX * d6 + this.motZ * d7;

        if (d9 < 0.0D) {
          d6 = -d6;
          d7 = -d7;
        }

        double d10 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);

        this.motX = d10 * d6 / d8;
        this.motZ = d10 * d7 / d8;
        double d11;
        double d12;

        if (this.passenger != null) {
          d12 =
              this.passenger.motX * this.passenger.motX + this.passenger.motZ * this.passenger.motZ;
          d11 = this.motX * this.motX + this.motZ * this.motZ;
          if (d12 > 1.0E-4D && d11 < 0.01D) {
            this.motX += this.passenger.motX * 0.1D;
            this.motZ += this.passenger.motZ * 0.1D;
            flag1 = false;
          }
        }

        if (flag1) {
          d12 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);
          if (d12 < 0.03D) {
            this.motX *= 0.0D;
            this.motY *= 0.0D;
            this.motZ *= 0.0D;
          } else {
            this.motX *= 0.5D;
            this.motY *= 0.0D;
            this.motZ *= 0.5D;
          }
        }

        d12 = 0.0D;
        d11 = (double) i + 0.5D + (double) aint[0][0] * 0.5D;
        double d13 = (double) k + 0.5D + (double) aint[0][2] * 0.5D;
        double d14 = (double) i + 0.5D + (double) aint[1][0] * 0.5D;
        double d15 = (double) k + 0.5D + (double) aint[1][2] * 0.5D;

        d6 = d14 - d11;
        d7 = d15 - d13;
        double d16;
        double d17;

        if (d6 == 0.0D) {
          this.locX = (double) i + 0.5D;
          d12 = this.locZ - (double) k;
        } else if (d7 == 0.0D) {
          this.locZ = (double) k + 0.5D;
          d12 = this.locX - (double) i;
        } else {
          d16 = this.locX - d11;
          d17 = this.locZ - d13;
          d12 = (d16 * d6 + d17 * d7) * 2.0D;
        }

        this.locX = d11 + d6 * d12;
        this.locZ = d13 + d7 * d12;
        this.setPosition(this.locX, this.locY + (double) this.height, this.locZ);
        d16 = this.motX;
        d17 = this.motZ;
        if (this.passenger != null) {
          d16 *= 0.75D;
          d17 *= 0.75D;
        }

        if (d16 < -d4) {
          d16 = -d4;
        }

        if (d16 > d4) {
          d16 = d4;
        }

        if (d17 < -d4) {
          d17 = -d4;
        }

        if (d17 > d4) {
          d17 = d4;
        }

        this.move(d16, 0.0D, d17);
        if (aint[0][1] != 0
            && MathHelper.floor(this.locX) - i == aint[0][0]
            && MathHelper.floor(this.locZ) - k == aint[0][2]) {
          this.setPosition(this.locX, this.locY + (double) aint[0][1], this.locZ);
        } else if (aint[1][1] != 0
            && MathHelper.floor(this.locX) - i == aint[1][0]
            && MathHelper.floor(this.locZ) - k == aint[1][2]) {
          this.setPosition(this.locX, this.locY + (double) aint[1][1], this.locZ);
        }

        if (this.passenger != null) {
          this.motX *= 0.996999979019165D;
          this.motY *= 0.0D;
          this.motZ *= 0.996999979019165D;
        } else {
          if (this.type == 2) {
            double d18 = this.b * this.b + this.c * this.c;

            if (d18 > 1.0E-4D) {
              d18 = (double) MathHelper.sqrt(d18);
              this.b /= d18;
              this.c /= d18;
              double d19 = 0.04D;

              this.motX *= 0.800000011920929D;
              this.motY *= 0.0D;
              this.motZ *= 0.800000011920929D;
              this.motX += this.b * d19;
              this.motZ += this.c * d19;
            } else {
              this.motX *= 0.8999999761581421D;
              this.motY *= 0.0D;
              this.motZ *= 0.8999999761581421D;
            }
          }

          this.motX *= 0.9599999785423279D;
          this.motY *= 0.0D;
          this.motZ *= 0.9599999785423279D;
        }

        Vec3D vec3d1 = this.a(this.locX, this.locY, this.locZ);

        if (vec3d1 != null && vec3d != null) {
          double d20 = (vec3d.d - vec3d1.d) * 0.05D;

          d10 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);
          if (d10 > 0.0D) {
            this.motX = this.motX / d10 * (d10 + d20);
            this.motZ = this.motZ / d10 * (d10 + d20);
          }

          this.setPosition(this.locX, vec3d1.d, this.locZ);
        }

        int j1 = MathHelper.floor(this.locX);
        int k1 = MathHelper.floor(this.locZ);

        if (j1 != i || k1 != k) {
          d10 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);
          this.motX = d10 * (double) (j1 - i);
          this.motZ = d10 * (double) (k1 - k);
        }

        double d21;

        if (this.type == 2) {
          d21 = this.b * this.b + this.c * this.c;
          if (d21 > 1.0E-4D && this.motX * this.motX + this.motZ * this.motZ > 0.001D) {
            d21 = (double) MathHelper.sqrt(d21);
            this.b /= d21;
            this.c /= d21;
            if (this.b * this.motX + this.c * this.motZ < 0.0D) {
              this.b = 0.0D;
              this.c = 0.0D;
            } else {
              this.b = this.motX;
              this.c = this.motZ;
            }
          }
        }

        if (flag) {
          d21 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);
          if (d21 > 0.01D) {
            double d22 = 0.06D;

            this.motX += this.motX / d21 * d22;
            this.motZ += this.motZ / d21 * d22;
          } else if (i1 == 1) {
            if (this.world.t(i - 1, j, k)) {
              this.motX = 0.02D;
            } else if (this.world.t(i + 1, j, k)) {
              this.motX = -0.02D;
            }
          } else if (i1 == 0) {
            if (this.world.t(i, j, k - 1)) {
              this.motZ = 0.02D;
            } else if (this.world.t(i, j, k + 1)) {
              this.motZ = -0.02D;
            }
          }
        }
      } else {
        if (this.motX < -d4) {
          this.motX = -d4;
        }

        if (this.motX > d4) {
          this.motX = d4;
        }

        if (this.motZ < -d4) {
          this.motZ = -d4;
        }

        if (this.motZ > d4) {
          this.motZ = d4;
        }

        if (this.onGround) {
          this.motX *= 0.5D;
          this.motY *= 0.5D;
          this.motZ *= 0.5D;
        }

        this.move(this.motX, this.motY, this.motZ);
        if (!this.onGround) {
          this.motX *= 0.949999988079071D;
          this.motY *= 0.949999988079071D;
          this.motZ *= 0.949999988079071D;
        }
      }

      this.D();
      this.pitch = 0.0F;
      double d23 = this.lastX - this.locX;
      double d24 = this.lastZ - this.locZ;

      if (d23 * d23 + d24 * d24 > 0.001D) {
        this.yaw = (float) (Math.atan2(d24, d23) * 180.0D / 3.141592653589793D);
        if (this.f) {
          this.yaw += 180.0F;
        }
      }

      double d25 = (double) MathHelper.g(this.yaw - this.lastYaw);

      if (d25 < -170.0D || d25 >= 170.0D) {
        this.yaw += 180.0F;
        this.f = !this.f;
      }

      this.b(this.yaw, this.pitch);
      List list =
          this.world.getEntities(
              this, this.boundingBox.grow(0.20000000298023224D, 0.0D, 0.20000000298023224D));

      if (list != null && !list.isEmpty()) {
        for (int l1 = 0; l1 < list.size(); ++l1) {
          Entity entity = (Entity) list.get(l1);

          if (entity != this.passenger && entity.M() && entity instanceof EntityMinecart) {
            entity.collide(this);
          }
        }
      }

      if (this.passenger != null && this.passenger.dead) {
        if (this.passenger.vehicle == this) {
          this.passenger.vehicle = null;
        }

        this.passenger = null;
      }

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

      if (this.e <= 0) {
        this.b = this.c = 0.0D;
      }

      this.e(this.e > 0);
    }
  }
Ejemplo n.º 26
0
  public void collide(Entity entity) {
    if (!this.world.isStatic) {
      if (entity != this.passenger) {
        if (entity instanceof EntityLiving
            && !(entity instanceof EntityHuman)
            && !(entity instanceof EntityIronGolem)
            && this.type == 0
            && this.motX * this.motX + this.motZ * this.motZ > 0.01D
            && this.passenger == null
            && entity.vehicle == null) {
          entity.mount(this);
        }

        double d0 = entity.locX - this.locX;
        double d1 = entity.locZ - this.locZ;
        double d2 = d0 * d0 + d1 * d1;

        if (d2 >= 9.999999747378752E-5D) {
          d2 = (double) MathHelper.sqrt(d2);
          d0 /= d2;
          d1 /= d2;
          double d3 = 1.0D / d2;

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

          d0 *= d3;
          d1 *= d3;
          d0 *= 0.10000000149011612D;
          d1 *= 0.10000000149011612D;
          d0 *= (double) (1.0F - this.Z);
          d1 *= (double) (1.0F - this.Z);
          d0 *= 0.5D;
          d1 *= 0.5D;
          if (entity instanceof EntityMinecart) {
            double d4 = entity.locX - this.locX;
            double d5 = entity.locZ - this.locZ;
            Vec3D vec3d = this.world.getVec3DPool().create(d4, 0.0D, d5).a();
            Vec3D vec3d1 =
                this.world
                    .getVec3DPool()
                    .create(
                        (double) MathHelper.cos(this.yaw * 3.1415927F / 180.0F),
                        0.0D,
                        (double) MathHelper.sin(this.yaw * 3.1415927F / 180.0F))
                    .a();
            double d6 = Math.abs(vec3d.b(vec3d1));

            if (d6 < 0.800000011920929D) {
              return;
            }

            double d7 = entity.motX + this.motX;
            double d8 = entity.motZ + this.motZ;

            if (((EntityMinecart) entity).type == 2 && this.type != 2) {
              this.motX *= 0.20000000298023224D;
              this.motZ *= 0.20000000298023224D;
              this.g(entity.motX - d0, 0.0D, entity.motZ - d1);
              entity.motX *= 0.949999988079071D;
              entity.motZ *= 0.949999988079071D;
            } else if (((EntityMinecart) entity).type != 2 && this.type == 2) {
              entity.motX *= 0.20000000298023224D;
              entity.motZ *= 0.20000000298023224D;
              entity.g(this.motX + d0, 0.0D, this.motZ + d1);
              this.motX *= 0.949999988079071D;
              this.motZ *= 0.949999988079071D;
            } else {
              d7 /= 2.0D;
              d8 /= 2.0D;
              this.motX *= 0.20000000298023224D;
              this.motZ *= 0.20000000298023224D;
              this.g(d7 - d0, 0.0D, d8 - d1);
              entity.motX *= 0.20000000298023224D;
              entity.motZ *= 0.20000000298023224D;
              entity.g(d7 + d0, 0.0D, d8 + d1);
            }
          } else {
            this.g(-d0, 0.0D, -d1);
            entity.g(d0 / 4.0D, 0.0D, d1 / 4.0D);
          }
        }
      }
    }
  }
Ejemplo n.º 27
0
  public void move(double d0, double d1, double d2) {
    if (this.T) {
      this.a(this.getBoundingBox().c(d0, d1, d2));
      this.recalcPosition();
    } else {
      this.world.methodProfiler.a("move");
      double d3 = this.locX;
      double d4 = this.locY;
      double d5 = this.locZ;

      if (this.H) {
        this.H = false;
        d0 *= 0.25D;
        d1 *= 0.05000000074505806D;
        d2 *= 0.25D;
        this.motX = 0.0D;
        this.motY = 0.0D;
        this.motZ = 0.0D;
      }

      double d6 = d0;
      double d7 = d1;
      double d8 = d2;
      boolean flag = this.onGround && this.isSneaking() && this instanceof EntityHuman;

      if (flag) {
        double d9;

        for (d9 = 0.05D;
            d0 != 0.0D
                && this.world.getCubes(this, this.getBoundingBox().c(d0, -1.0D, 0.0D)).isEmpty();
            d6 = d0) {
          if (d0 < d9 && d0 >= -d9) {
            d0 = 0.0D;
          } else if (d0 > 0.0D) {
            d0 -= d9;
          } else {
            d0 += d9;
          }
        }

        for (;
            d2 != 0.0D
                && this.world.getCubes(this, this.getBoundingBox().c(0.0D, -1.0D, d2)).isEmpty();
            d8 = d2) {
          if (d2 < d9 && d2 >= -d9) {
            d2 = 0.0D;
          } else if (d2 > 0.0D) {
            d2 -= d9;
          } else {
            d2 += d9;
          }
        }

        for (;
            d0 != 0.0D
                && d2 != 0.0D
                && this.world.getCubes(this, this.getBoundingBox().c(d0, -1.0D, d2)).isEmpty();
            d8 = d2) {
          if (d0 < d9 && d0 >= -d9) {
            d0 = 0.0D;
          } else if (d0 > 0.0D) {
            d0 -= d9;
          } else {
            d0 += d9;
          }

          d6 = d0;
          if (d2 < d9 && d2 >= -d9) {
            d2 = 0.0D;
          } else if (d2 > 0.0D) {
            d2 -= d9;
          } else {
            d2 += d9;
          }
        }
      }

      List list = this.world.getCubes(this, this.getBoundingBox().a(d0, d1, d2));
      AxisAlignedBB axisalignedbb = this.getBoundingBox();

      AxisAlignedBB axisalignedbb1;

      for (Iterator iterator = list.iterator();
          iterator.hasNext();
          d1 = axisalignedbb1.b(this.getBoundingBox(), d1)) {
        axisalignedbb1 = (AxisAlignedBB) iterator.next();
      }

      this.a(this.getBoundingBox().c(0.0D, d1, 0.0D));
      boolean flag1 = this.onGround || d7 != d1 && d7 < 0.0D;

      AxisAlignedBB axisalignedbb2;
      Iterator iterator1;

      for (iterator1 = list.iterator();
          iterator1.hasNext();
          d0 = axisalignedbb2.a(this.getBoundingBox(), d0)) {
        axisalignedbb2 = (AxisAlignedBB) iterator1.next();
      }

      this.a(this.getBoundingBox().c(d0, 0.0D, 0.0D));

      for (iterator1 = list.iterator();
          iterator1.hasNext();
          d2 = axisalignedbb2.c(this.getBoundingBox(), d2)) {
        axisalignedbb2 = (AxisAlignedBB) iterator1.next();
      }

      this.a(this.getBoundingBox().c(0.0D, 0.0D, d2));
      if (this.S > 0.0F && flag1 && (d6 != d0 || d8 != d2)) {
        double d10 = d0;
        double d11 = d1;
        double d12 = d2;
        AxisAlignedBB axisalignedbb3 = this.getBoundingBox();

        this.a(axisalignedbb);
        d1 = (double) this.S;
        List list1 = this.world.getCubes(this, this.getBoundingBox().a(d6, d1, d8));
        AxisAlignedBB axisalignedbb4 = this.getBoundingBox();
        AxisAlignedBB axisalignedbb5 = axisalignedbb4.a(d6, 0.0D, d8);
        double d13 = d1;

        AxisAlignedBB axisalignedbb6;

        for (Iterator iterator2 = list1.iterator();
            iterator2.hasNext();
            d13 = axisalignedbb6.b(axisalignedbb5, d13)) {
          axisalignedbb6 = (AxisAlignedBB) iterator2.next();
        }

        axisalignedbb4 = axisalignedbb4.c(0.0D, d13, 0.0D);
        double d14 = d6;

        AxisAlignedBB axisalignedbb7;

        for (Iterator iterator3 = list1.iterator();
            iterator3.hasNext();
            d14 = axisalignedbb7.a(axisalignedbb4, d14)) {
          axisalignedbb7 = (AxisAlignedBB) iterator3.next();
        }

        axisalignedbb4 = axisalignedbb4.c(d14, 0.0D, 0.0D);
        double d15 = d8;

        AxisAlignedBB axisalignedbb8;

        for (Iterator iterator4 = list1.iterator();
            iterator4.hasNext();
            d15 = axisalignedbb8.c(axisalignedbb4, d15)) {
          axisalignedbb8 = (AxisAlignedBB) iterator4.next();
        }

        axisalignedbb4 = axisalignedbb4.c(0.0D, 0.0D, d15);
        AxisAlignedBB axisalignedbb9 = this.getBoundingBox();
        double d16 = d1;

        AxisAlignedBB axisalignedbb10;

        for (Iterator iterator5 = list1.iterator();
            iterator5.hasNext();
            d16 = axisalignedbb10.b(axisalignedbb9, d16)) {
          axisalignedbb10 = (AxisAlignedBB) iterator5.next();
        }

        axisalignedbb9 = axisalignedbb9.c(0.0D, d16, 0.0D);
        double d17 = d6;

        AxisAlignedBB axisalignedbb11;

        for (Iterator iterator6 = list1.iterator();
            iterator6.hasNext();
            d17 = axisalignedbb11.a(axisalignedbb9, d17)) {
          axisalignedbb11 = (AxisAlignedBB) iterator6.next();
        }

        axisalignedbb9 = axisalignedbb9.c(d17, 0.0D, 0.0D);
        double d18 = d8;

        AxisAlignedBB axisalignedbb12;

        for (Iterator iterator7 = list1.iterator();
            iterator7.hasNext();
            d18 = axisalignedbb12.c(axisalignedbb9, d18)) {
          axisalignedbb12 = (AxisAlignedBB) iterator7.next();
        }

        axisalignedbb9 = axisalignedbb9.c(0.0D, 0.0D, d18);
        double d19 = d14 * d14 + d15 * d15;
        double d20 = d17 * d17 + d18 * d18;

        if (d19 > d20) {
          d0 = d14;
          d2 = d15;
          this.a(axisalignedbb4);
        } else {
          d0 = d17;
          d2 = d18;
          this.a(axisalignedbb9);
        }

        d1 = (double) (-this.S);

        AxisAlignedBB axisalignedbb13;

        for (Iterator iterator8 = list1.iterator();
            iterator8.hasNext();
            d1 = axisalignedbb13.b(this.getBoundingBox(), d1)) {
          axisalignedbb13 = (AxisAlignedBB) iterator8.next();
        }

        this.a(this.getBoundingBox().c(0.0D, d1, 0.0D));
        if (d10 * d10 + d12 * d12 >= d0 * d0 + d2 * d2) {
          d0 = d10;
          d1 = d11;
          d2 = d12;
          this.a(axisalignedbb3);
        }
      }

      this.world.methodProfiler.b();
      this.world.methodProfiler.a("rest");
      this.recalcPosition();
      this.positionChanged = d6 != d0 || d8 != d2;
      this.E = d7 != d1;
      this.onGround = this.E && d7 < 0.0D;
      this.F = this.positionChanged || this.E;
      int i = MathHelper.floor(this.locX);
      int j = MathHelper.floor(this.locY - 0.20000000298023224D);
      int k = MathHelper.floor(this.locZ);
      BlockPosition blockposition = new BlockPosition(i, j, k);
      Block block = this.world.getType(blockposition).getBlock();

      if (block.getMaterial() == Material.AIR) {
        Block block1 = this.world.getType(blockposition.down()).getBlock();

        if (block1 instanceof BlockFence
            || block1 instanceof BlockCobbleWall
            || block1 instanceof BlockFenceGate) {
          block = block1;
          blockposition = blockposition.down();
        }
      }

      this.a(d1, this.onGround, block, blockposition);
      if (d6 != d0) {
        this.motX = 0.0D;
      }

      if (d8 != d2) {
        this.motZ = 0.0D;
      }

      if (d7 != d1) {
        block.a(this.world, this);
      }

      if (this.r_() && !flag && this.vehicle == null) {
        double d21 = this.locX - d3;
        double d22 = this.locY - d4;
        double d23 = this.locZ - d5;

        if (block != Blocks.LADDER) {
          d22 = 0.0D;
        }

        if (block != null && this.onGround) {
          block.a(this.world, blockposition, this);
        }

        this.M = (float) ((double) this.M + (double) MathHelper.sqrt(d21 * d21 + d23 * d23) * 0.6D);
        this.N =
            (float)
                ((double) this.N
                    + (double) MathHelper.sqrt(d21 * d21 + d22 * d22 + d23 * d23) * 0.6D);
        if (this.N > (float) this.h && block.getMaterial() != Material.AIR) {
          this.h = (int) this.N + 1;
          if (this.V()) {
            float f =
                MathHelper.sqrt(
                        this.motX * this.motX * 0.20000000298023224D
                            + this.motY * this.motY
                            + this.motZ * this.motZ * 0.20000000298023224D)
                    * 0.35F;

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

            this.makeSound(
                this.P(), f, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
          }

          this.a(blockposition, block);
        }
      }

      try {
        this.checkBlockCollisions();
      } catch (Throwable throwable) {
        CrashReport crashreport = CrashReport.a(throwable, "Checking entity block collision");
        CrashReportSystemDetails crashreportsystemdetails =
            crashreport.a("Entity being checked for collision");

        this.appendEntityCrashDetails(crashreportsystemdetails);
        throw new ReportedException(crashreport);
      }

      boolean flag2 = this.U();

      if (this.world.e(this.getBoundingBox().shrink(0.001D, 0.001D, 0.001D))) {
        this.burn(1);
        if (!flag2) {
          ++this.fireTicks;
          if (this.fireTicks == 0) {
            this.setOnFire(8);
          }
        }
      } else if (this.fireTicks <= 0) {
        this.fireTicks = -this.maxFireTicks;
      }

      if (flag2 && this.fireTicks > 0) {
        this.makeSound(
            "random.fizz", 0.7F, 1.6F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
        this.fireTicks = -this.maxFireTicks;
      }

      this.world.methodProfiler.b();
    }
  }
Ejemplo n.º 28
0
  public void c() {
    this.motY *= 0.6000000238418579D;
    double d0;
    double d1;
    double d2;

    if (!this.world.isStatic && this.q(0) > 0) {
      Entity entity = this.world.getEntity(this.q(0));

      if (entity != null) {
        if (this.locY < entity.locY || !this.bV() && this.locY < entity.locY + 5.0D) {
          if (this.motY < 0.0D) {
            this.motY = 0.0D;
          }

          this.motY += (0.5D - this.motY) * 0.6000000238418579D;
        }

        double d3 = entity.locX - this.locX;

        d0 = entity.locZ - this.locZ;
        d1 = d3 * d3 + d0 * d0;
        if (d1 > 9.0D) {
          d2 = (double) MathHelper.sqrt(d1);
          this.motX += (d3 / d2 * 0.5D - this.motX) * 0.6000000238418579D;
          this.motZ += (d0 / d2 * 0.5D - this.motZ) * 0.6000000238418579D;
        }
      }
    }

    if (this.motX * this.motX + this.motZ * this.motZ > 0.05000000074505806D) {
      this.yaw = (float) Math.atan2(this.motZ, this.motX) * 57.295776F - 90.0F;
    }

    super.c();

    int i;

    for (i = 0; i < 2; ++i) {
      this.bs[i] = this.bq[i];
      this.br[i] = this.bp[i];
    }

    int j;

    for (i = 0; i < 2; ++i) {
      j = this.q(i + 1);
      Entity entity1 = null;

      if (j > 0) {
        entity1 = this.world.getEntity(j);
      }

      if (entity1 != null) {
        d0 = this.r(i + 1);
        d1 = this.s(i + 1);
        d2 = this.t(i + 1);
        double d4 = entity1.locX - d0;
        double d5 = entity1.locY + (double) entity1.getHeadHeight() - d1;
        double d6 = entity1.locZ - d2;
        double d7 = (double) MathHelper.sqrt(d4 * d4 + d6 * d6);
        float f = (float) (Math.atan2(d6, d4) * 180.0D / 3.1415927410125732D) - 90.0F;
        float f1 = (float) (-(Math.atan2(d5, d7) * 180.0D / 3.1415927410125732D));

        this.bp[i] = this.b(this.bp[i], f1, 40.0F);
        this.bq[i] = this.b(this.bq[i], f, 10.0F);
      } else {
        this.bq[i] = this.b(this.bq[i], this.aN, 10.0F);
      }
    }

    boolean flag = this.bV();

    for (j = 0; j < 3; ++j) {
      double d8 = this.r(j);
      double d9 = this.s(j);
      double d10 = this.t(j);

      this.world.addParticle(
          "smoke",
          d8 + this.random.nextGaussian() * 0.30000001192092896D,
          d9 + this.random.nextGaussian() * 0.30000001192092896D,
          d10 + this.random.nextGaussian() * 0.30000001192092896D,
          0.0D,
          0.0D,
          0.0D);
      if (flag && this.world.random.nextInt(4) == 0) {
        this.world.addParticle(
            "mobSpell",
            d8 + this.random.nextGaussian() * 0.30000001192092896D,
            d9 + this.random.nextGaussian() * 0.30000001192092896D,
            d10 + this.random.nextGaussian() * 0.30000001192092896D,
            0.699999988079071D,
            0.699999988079071D,
            0.5D);
      }
    }

    if (this.bU() > 0) {
      for (j = 0; j < 3; ++j) {
        this.world.addParticle(
            "mobSpell",
            this.locX + this.random.nextGaussian() * 1.0D,
            this.locY + (double) (this.random.nextFloat() * 3.3F),
            this.locZ + this.random.nextGaussian() * 1.0D,
            0.699999988079071D,
            0.699999988079071D,
            0.8999999761581421D);
      }
    }
  }
Ejemplo n.º 29
0
  public void a() {
    // CraftBukkit start
    if (this.size < 0.1F) {
      return;
    }
    // CraftBukkit end

    float f = this.size;
    HashSet hashset = new HashSet();

    int i;
    int j;
    int k;
    double d0;
    double d1;
    double d2;

    for (i = 0; i < this.i; ++i) {
      for (j = 0; j < this.i; ++j) {
        for (k = 0; k < this.i; ++k) {
          if (i == 0 || i == this.i - 1 || j == 0 || j == this.i - 1 || k == 0 || k == this.i - 1) {
            double d3 = (double) ((float) i / ((float) this.i - 1.0F) * 2.0F - 1.0F);
            double d4 = (double) ((float) j / ((float) this.i - 1.0F) * 2.0F - 1.0F);
            double d5 = (double) ((float) k / ((float) this.i - 1.0F) * 2.0F - 1.0F);
            double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5);

            d3 /= d6;
            d4 /= d6;
            d5 /= d6;
            float f1 = this.size * (0.7F + this.world.random.nextFloat() * 0.6F);

            d0 = this.posX;
            d1 = this.posY;
            d2 = this.posZ;

            for (float f2 = 0.3F; f1 > 0.0F; f1 -= f2 * 0.75F) {
              int l = MathHelper.floor(d0);
              int i1 = MathHelper.floor(d1);
              int j1 = MathHelper.floor(d2);
              int k1 = this.world.getTypeId(l, i1, j1);

              if (k1 > 0) {
                Block block = Block.byId[k1];
                float f3 =
                    this.source != null
                        ? this.source.a(this, this.world, l, i1, j1, block)
                        : block.a(this.source);

                f1 -= (f3 + 0.3F) * f2;
              }

              if (f1 > 0.0F
                  && (this.source == null || this.source.a(this, this.world, l, i1, j1, k1, f1))
                  && i1 < 256
                  && i1 >= 0) { // CraftBukkit - don't wrap explosions
                hashset.add(new ChunkPosition(l, i1, j1));
              }

              d0 += d3 * (double) f2;
              d1 += d4 * (double) f2;
              d2 += d5 * (double) f2;
            }
          }
        }
      }
    }

    this.blocks.addAll(hashset);
    this.size *= 2.0F;
    i = MathHelper.floor(this.posX - (double) this.size - 1.0D);
    j = MathHelper.floor(this.posX + (double) this.size + 1.0D);
    k = MathHelper.floor(this.posY - (double) this.size - 1.0D);
    int l1 = MathHelper.floor(this.posY + (double) this.size + 1.0D);
    int i2 = MathHelper.floor(this.posZ - (double) this.size - 1.0D);
    int j2 = MathHelper.floor(this.posZ + (double) this.size + 1.0D);
    List list =
        this.world.getEntities(
            this.source,
            AxisAlignedBB.a()
                .a((double) i, (double) k, (double) i2, (double) j, (double) l1, (double) j2));
    Vec3D vec3d = this.world.getVec3DPool().create(this.posX, this.posY, this.posZ);

    for (int k2 = 0; k2 < list.size(); ++k2) {
      Entity entity = (Entity) list.get(k2);
      double d7 = entity.f(this.posX, this.posY, this.posZ) / (double) this.size;

      if (d7 <= 1.0D) {
        d0 = entity.locX - this.posX;
        d1 = entity.locY + (double) entity.getHeadHeight() - this.posY;
        d2 = entity.locZ - this.posZ;
        double d8 = (double) MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2);

        if (d8 != 0.0D) {
          d0 /= d8;
          d1 /= d8;
          d2 /= d8;
          double d9 = (double) this.world.a(vec3d, entity.boundingBox);
          double d10 = (1.0D - d7) * d9;

          // CraftBukkit start - Explosion damage hook
          org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity();
          float damageDone =
              (float) ((int) ((d10 * d10 + d10) / 2.0D * 8.0D * (double) this.size + 1.0D));

          if (damagee == null) {
            // nothing was hurt
          } else if (this.source == null) { // Block explosion (without an entity source; bed etc.)
            EntityDamageByBlockEvent event =
                new EntityDamageByBlockEvent(
                    null, damagee, EntityDamageEvent.DamageCause.BLOCK_EXPLOSION, damageDone);
            Bukkit.getPluginManager().callEvent(event);

            if (!event.isCancelled()) {
              damagee.setLastDamageCause(event);
              entity.damageEntity(DamageSource.explosion(this), (float) event.getDamage());
              double d11 = EnchantmentProtection.a(entity, d10);

              entity.motX += d0 * d11;
              entity.motY += d1 * d11;
              entity.motZ += d2 * d11;
              if (entity instanceof EntityHuman) {
                this.l.put(
                    (EntityHuman) entity,
                    this.world.getVec3DPool().create(d0 * d10, d1 * d10, d2 * d10));
              }
            }
          } else {
            final org.bukkit.entity.Entity damager = this.source.getBukkitEntity();
            final EntityDamageEvent.DamageCause damageCause;

            if (damager instanceof org.bukkit.entity.TNTPrimed) {
              damageCause = EntityDamageEvent.DamageCause.BLOCK_EXPLOSION;
            } else {
              damageCause = EntityDamageEvent.DamageCause.ENTITY_EXPLOSION;
            }

            EntityDamageByEntityEvent event =
                new EntityDamageByEntityEvent(damager, damagee, damageCause, damageDone);
            Bukkit.getPluginManager().callEvent(event);

            if (!event.isCancelled()) {
              entity.getBukkitEntity().setLastDamageCause(event);
              entity.damageEntity(DamageSource.explosion(this), (float) event.getDamage());

              entity.motX += d0 * d10;
              entity.motY += d1 * d10;
              entity.motZ += d2 * d10;
              if (entity instanceof EntityHuman) {
                this.l.put(
                    (EntityHuman) entity,
                    this.world.getVec3DPool().create(d0 * d10, d1 * d10, d2 * d10));
              }
            }
          }
          // CraftBukkit end
        }
      }
    }

    this.size = f;
  }
Ejemplo n.º 30
0
  public void h() {
    super.h();
    if (this.lastPitch == 0.0F && this.lastYaw == 0.0F) {
      float f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);

      this.lastYaw =
          this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);
      this.lastPitch =
          this.pitch = (float) (Math.atan2(this.motY, (double) f) * 180.0D / 3.1415927410125732D);
    }

    Block block = this.world.getType(this.d, this.e, this.f);

    if (block.getMaterial() != Material.AIR) {
      block.updateShape(this.world, this.d, this.e, this.f);
      AxisAlignedBB axisalignedbb = block.a(this.world, this.d, this.e, this.f);

      if (axisalignedbb != null && axisalignedbb.a(Vec3D.a(this.locX, this.locY, this.locZ))) {
        this.inGround = true;
      }
    }

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

    if (this.inGround) {
      int i = this.world.getData(this.d, this.e, this.f);

      if (block == this.g && i == this.h) {
        ++this.at;
        if (this.at == 1200) {
          this.die();
        }
      } else {
        this.inGround = false;
        this.motX *= (double) (this.random.nextFloat() * 0.2F);
        this.motY *= (double) (this.random.nextFloat() * 0.2F);
        this.motZ *= (double) (this.random.nextFloat() * 0.2F);
        this.at = 0;
        this.au = 0;
      }
    } else {
      ++this.au;
      Vec3D vec3d = Vec3D.a(this.locX, this.locY, this.locZ);
      Vec3D vec3d1 = Vec3D.a(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
      MovingObjectPosition movingobjectposition =
          this.world.rayTrace(vec3d, vec3d1, false, true, false);

      vec3d = Vec3D.a(this.locX, this.locY, this.locZ);
      vec3d1 = Vec3D.a(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
      if (movingobjectposition != null) {
        vec3d1 =
            Vec3D.a(
                movingobjectposition.pos.a, movingobjectposition.pos.b, movingobjectposition.pos.c);
      }

      Entity entity = null;
      List list =
          this.world.getEntities(
              this, this.boundingBox.a(this.motX, this.motY, this.motZ).grow(1.0D, 1.0D, 1.0D));
      double d0 = 0.0D;

      int j;
      float f1;

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

        if (entity1.Q() && (entity1 != this.shooter || this.au >= 5)) {
          f1 = 0.3F;
          AxisAlignedBB axisalignedbb1 =
              entity1.boundingBox.grow((double) f1, (double) f1, (double) f1);
          MovingObjectPosition movingobjectposition1 = axisalignedbb1.a(vec3d, vec3d1);

          if (movingobjectposition1 != null) {
            double d1 =
                vec3d.distanceSquared(
                    movingobjectposition1.pos); // CraftBukkit - distance efficiency

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

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

      if (movingobjectposition != null
          && movingobjectposition.entity != null
          && movingobjectposition.entity instanceof EntityHuman) {
        EntityHuman entityhuman = (EntityHuman) movingobjectposition.entity;

        if (entityhuman.abilities.isInvulnerable
            || this.shooter instanceof EntityHuman
                && !((EntityHuman) this.shooter).a(entityhuman)) {
          movingobjectposition = null;
        }
      }

      float f2;
      float f3;

      if (movingobjectposition != null) {
        org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(
            this); // CraftBukkit - Call event

        if (movingobjectposition.entity != null) {
          f2 =
              MathHelper.sqrt(
                  this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ);
          int k = MathHelper.f((double) f2 * this.damage);

          if (this.isCritical()) {
            k += this.random.nextInt(k / 2 + 2);
          }

          DamageSource damagesource = null;

          if (this.shooter == null) {
            damagesource = DamageSource.arrow(this, this);
          } else {
            damagesource = DamageSource.arrow(this, this.shooter);
          }

          // CraftBukkit start - Moved damage call
          if (movingobjectposition.entity.damageEntity(damagesource, k)) {
            if (this.isBurning()
                && !(movingobjectposition.entity instanceof EntityEnderman)
                && (!(movingobjectposition.entity instanceof EntityPlayer)
                    || !(this.shooter instanceof EntityPlayer)
                    || this.world
                        .pvpMode)) { // CraftBukkit - abide by pvp setting if destination is a
                                     // player
              EntityCombustByEntityEvent combustEvent =
                  new EntityCombustByEntityEvent(
                      this.getBukkitEntity(), entity.getBukkitEntity(), 5);
              org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);

              if (!combustEvent.isCancelled()) {
                movingobjectposition.entity.setOnFire(combustEvent.getDuration());
              }
              // CraftBukkit end
            }

            // if (movingobjectposition.entity.damageEntity(damagesource, (float) k)) { //
            // CraftBukkit - moved up
            if (movingobjectposition.entity instanceof EntityLiving) {
              EntityLiving entityliving = (EntityLiving) movingobjectposition.entity;

              if (!this.world.isStatic) {
                entityliving.p(entityliving.aY() + 1);
              }

              if (this.knockbackStrength > 0) {
                f3 = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);
                if (f3 > 0.0F) {
                  movingobjectposition.entity.g(
                      this.motX
                          * (double) this.knockbackStrength
                          * 0.6000000238418579D
                          / (double) f3,
                      0.1D,
                      this.motZ
                          * (double) this.knockbackStrength
                          * 0.6000000238418579D
                          / (double) f3);
                }
              }

              if (this.shooter != null && this.shooter instanceof EntityLiving) {
                EnchantmentManager.a(entityliving, this.shooter);
                EnchantmentManager.b((EntityLiving) this.shooter, entityliving);
              }

              if (this.shooter != null
                  && movingobjectposition.entity != this.shooter
                  && movingobjectposition.entity instanceof EntityHuman
                  && this.shooter instanceof EntityPlayer) {
                ((EntityPlayer) this.shooter)
                    .playerConnection.sendPacket(new PacketPlayOutGameStateChange(6, 0.0F));
              }
            }

            this.makeSound("random.bowhit", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
            if (!(movingobjectposition.entity instanceof EntityEnderman)) {
              this.die();
            }
          } else {
            this.motX *= -0.10000000149011612D;
            this.motY *= -0.10000000149011612D;
            this.motZ *= -0.10000000149011612D;
            this.yaw += 180.0F;
            this.lastYaw += 180.0F;
            this.au = 0;
          }
        } else {
          this.d = movingobjectposition.b;
          this.e = movingobjectposition.c;
          this.f = movingobjectposition.d;
          this.g = this.world.getType(d, e, f); // CraftBukkit - Get correct block for storage
          this.h = this.world.getData(this.d, this.e, this.f);
          this.motX = (double) ((float) (movingobjectposition.pos.a - this.locX));
          this.motY = (double) ((float) (movingobjectposition.pos.b - this.locY));
          this.motZ = (double) ((float) (movingobjectposition.pos.c - this.locZ));
          f2 =
              MathHelper.sqrt(
                  this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ);
          this.locX -= this.motX / (double) f2 * 0.05000000074505806D;
          this.locY -= this.motY / (double) f2 * 0.05000000074505806D;
          this.locZ -= this.motZ / (double) f2 * 0.05000000074505806D;
          this.makeSound("random.bowhit", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
          this.inGround = true;
          this.shake = 7;
          this.setCritical(false);
          if (this.g.getMaterial() != Material.AIR) {
            this.g.a(this.world, this.d, this.e, this.f, (Entity) this);
          }
        }
      }

      if (this.isCritical()) {
        for (j = 0; j < 4; ++j) {
          this.world.addParticle(
              "crit",
              this.locX + this.motX * (double) j / 4.0D,
              this.locY + this.motY * (double) j / 4.0D,
              this.locZ + this.motZ * (double) j / 4.0D,
              -this.motX,
              -this.motY + 0.2D,
              -this.motZ);
        }
      }

      this.locX += this.motX;
      this.locY += this.motY;
      this.locZ += this.motZ;
      f2 = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);
      this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);

      for (this.pitch = (float) (Math.atan2(this.motY, (double) f2) * 180.0D / 3.1415927410125732D);
          this.pitch - this.lastPitch < -180.0F;
          this.lastPitch -= 360.0F) {;
      }

      while (this.pitch - this.lastPitch >= 180.0F) {
        this.lastPitch += 360.0F;
      }

      while (this.yaw - this.lastYaw < -180.0F) {
        this.lastYaw -= 360.0F;
      }

      while (this.yaw - this.lastYaw >= 180.0F) {
        this.lastYaw += 360.0F;
      }

      this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F;
      this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F;
      float f4 = 0.99F;

      f1 = 0.05F;
      if (this.L()) {
        for (int l = 0; l < 4; ++l) {
          f3 = 0.25F;
          this.world.addParticle(
              "bubble",
              this.locX - this.motX * (double) f3,
              this.locY - this.motY * (double) f3,
              this.locZ - this.motZ * (double) f3,
              this.motX,
              this.motY,
              this.motZ);
        }

        f4 = 0.8F;
      }

      if (this.K()) {
        this.extinguish();
      }

      this.motX *= (double) f4;
      this.motY *= (double) f4;
      this.motZ *= (double) f4;
      this.motY -= (double) f1;
      this.setPosition(this.locX, this.locY, this.locZ);
      this.H();
    }
  }