Example #1
0
  public void a(ItemStack itemstack) {
    this.makeSound("random.break", 0.8F, 0.8F + this.world.random.nextFloat() * 0.4F);

    for (int i = 0; i < 5; ++i) {
      Vec3D vec3d =
          this.world
              .getVec3DPool()
              .create(
                  ((double) this.random.nextFloat() - 0.5D) * 0.1D,
                  Math.random() * 0.1D + 0.1D,
                  0.0D);

      vec3d.a(-this.pitch * 3.1415927F / 180.0F);
      vec3d.b(-this.yaw * 3.1415927F / 180.0F);
      Vec3D vec3d1 =
          this.world
              .getVec3DPool()
              .create(
                  ((double) this.random.nextFloat() - 0.5D) * 0.3D,
                  (double) (-this.random.nextFloat()) * 0.6D - 0.3D,
                  0.6D);

      vec3d1.a(-this.pitch * 3.1415927F / 180.0F);
      vec3d1.b(-this.yaw * 3.1415927F / 180.0F);
      vec3d1 = vec3d1.add(this.locX, this.locY + (double) this.getHeadHeight(), this.locZ);
      this.world.addParticle(
          "iconcrack_" + itemstack.getItem().id,
          vec3d1.c,
          vec3d1.d,
          vec3d1.e,
          vec3d.c,
          vec3d.d + 0.05D,
          vec3d.e);
    }
  }
Example #2
0
  public void a(Packet18ArmAnimation packet18armanimation) {
    // CraftBukkit start
    if (this.player.dead) {
      return;
    }
    // CraftBukkit end

    if (packet18armanimation.b == 1) {
      // CraftBukkit start - raytrace to look for 'rogue armswings'
      float f = 1.0F;
      float f1 = this.player.lastPitch + (this.player.pitch - this.player.lastPitch) * f;
      float f2 = this.player.lastYaw + (this.player.yaw - this.player.lastYaw) * f;
      double d0 = this.player.lastX + (this.player.locX - this.player.lastX) * (double) f;
      double d1 =
          this.player.lastY
              + (this.player.locY - this.player.lastY) * (double) f
              + 1.62D
              - (double) this.player.height;
      double d2 = this.player.lastZ + (this.player.locZ - this.player.lastZ) * (double) f;
      Vec3D vec3d = Vec3D.create(d0, d1, d2);

      float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F);
      float f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F);
      float f5 = -MathHelper.cos(-f1 * 0.017453292F);
      float f6 = MathHelper.sin(-f1 * 0.017453292F);
      float f7 = f4 * f5;
      float f8 = f3 * f5;
      double d3 = 5.0D;
      Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
      MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1, true);

      if (movingobjectposition == null || movingobjectposition.type != EnumMovingObjectType.TILE) {
        CraftEventFactory.callPlayerInteractEvent(
            this.player, Action.LEFT_CLICK_AIR, this.player.inventory.getItemInHand());
      }

      // Arm swing animation
      Player player = getPlayer();
      PlayerAnimationEvent event = new PlayerAnimationEvent(player);
      server.getPluginManager().callEvent(event);
      // CraftBukkit end

      this.player.k_();
    }
  }
Example #3
0
  protected boolean c(Entity entity) {
    Vec3D vec3d =
        Vec3D.a(
            this.locX - entity.locX,
            this.boundingBox.b
                + (double) (this.length / 2.0F)
                - entity.locY
                + (double) entity.getHeadHeight(),
            this.locZ - entity.locZ);

    vec3d = vec3d.a();
    double d0 = 16.0D;
    double d1 = this.locX + (this.random.nextDouble() - 0.5D) * 8.0D - vec3d.a * d0;
    double d2 = this.locY + (double) (this.random.nextInt(16) - 8) - vec3d.b * d0;
    double d3 = this.locZ + (this.random.nextDouble() - 0.5D) * 8.0D - vec3d.c * d0;

    return this.k(d1, d2, d3);
  }
 private Vec3D f() {
   Random localRandom = this.a.au();
   for (int i = 0; i < 10; i++) {
     int j = MathHelper.floor(this.a.locX + localRandom.nextInt(20) - 10.0D);
     int k = MathHelper.floor(this.a.boundingBox.b + localRandom.nextInt(6) - 3.0D);
     int m = MathHelper.floor(this.a.locZ + localRandom.nextInt(20) - 10.0D);
     if ((!this.f.j(j, k, m)) && (this.a.a(j, k, m) < 0.0F)) return Vec3D.a().create(j, k, m);
   }
   return null;
 }
Example #5
0
  protected MovingObjectPosition a(World world, EntityHuman entityhuman, boolean flag) {
    float f = 1.0F;
    float f1 = entityhuman.lastPitch + (entityhuman.pitch - entityhuman.lastPitch) * f;
    float f2 = entityhuman.lastYaw + (entityhuman.yaw - entityhuman.lastYaw) * f;
    double d0 = entityhuman.lastX + (entityhuman.locX - entityhuman.lastX) * (double) f;
    double d1 =
        entityhuman.lastY
            + (entityhuman.locY - entityhuman.lastY) * (double) f
            + 1.62D
            - (double) entityhuman.height;
    double d2 = entityhuman.lastZ + (entityhuman.locZ - entityhuman.lastZ) * (double) f;
    Vec3D vec3d = Vec3D.a(d0, d1, d2);
    float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F);
    float f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F);
    float f5 = -MathHelper.cos(-f1 * 0.017453292F);
    float f6 = MathHelper.sin(-f1 * 0.017453292F);
    float f7 = f4 * f5;
    float f8 = f3 * f5;
    double d3 = 5.0D;
    Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);

    return world.rayTrace(vec3d, vec3d1, flag, !flag, false);
  }
Example #6
0
  private boolean f(EntityHuman entityhuman) {
    ItemStack itemstack = entityhuman.inventory.armor[3];

    if (itemstack != null && itemstack.getItem() == Item.getItemOf(Blocks.PUMPKIN)) {
      return false;
    } else {
      Vec3D vec3d = entityhuman.j(1.0F).a();
      Vec3D vec3d1 =
          this.world
              .getVec3DPool()
              .create(
                  this.locX - entityhuman.locX,
                  this.boundingBox.b
                      + (double) (this.length / 2.0F)
                      - (entityhuman.locY + (double) entityhuman.getHeadHeight()),
                  this.locZ - entityhuman.locZ);
      double d0 = vec3d1.b();

      vec3d1 = vec3d1.a();
      double d1 = vec3d.b(vec3d1);

      return d1 > 1.0D - 0.025D / d0 ? entityhuman.o(this) : false;
    }
  }
Example #7
0
  protected void b(ItemStack itemstack, int i) {
    if (itemstack.m() == EnumAnimation.c) {
      this.world.makeSound(this, "random.drink", 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
    }

    if (itemstack.m() == EnumAnimation.b) {
      for (int j = 0; j < i; ++j) {
        Vec3D vec3d =
            Vec3D.create(
                ((double) this.random.nextFloat() - 0.5D) * 0.1D,
                Math.random() * 0.1D + 0.1D,
                0.0D);

        vec3d.a(-this.pitch * 3.1415927F / 180.0F);
        vec3d.b(-this.yaw * 3.1415927F / 180.0F);
        Vec3D vec3d1 =
            Vec3D.create(
                ((double) this.random.nextFloat() - 0.5D) * 0.3D,
                (double) (-this.random.nextFloat()) * 0.6D - 0.3D,
                0.6D);

        vec3d1.a(-this.pitch * 3.1415927F / 180.0F);
        vec3d1.b(-this.yaw * 3.1415927F / 180.0F);
        vec3d1 = vec3d1.add(this.locX, this.locY + (double) this.getHeadHeight(), this.locZ);
        this.world.a(
            "iconcrack_" + itemstack.getItem().id,
            vec3d1.a,
            vec3d1.b,
            vec3d1.c,
            vec3d.a,
            vec3d.b + 0.05D,
            vec3d.c);
      }

      this.world.makeSound(
          this,
          "random.eat",
          0.5F + 0.5F * (float) this.random.nextInt(2),
          (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
    }
  }
  private void w() {
    long i = System.nanoTime();
    ArrayList arraylist = new ArrayList();
    Iterator iterator = trackerList.keySet().iterator();

    while (iterator.hasNext()) {
      String s = (String) iterator.next();
      int j = ((Integer) trackerList.get(s)).intValue();

      if (j > 0) {
        trackerList.put(s, Integer.valueOf(j - 1));
      } else {
        arraylist.add(s);
      }
    }

    int k;

    for (k = 0; k < arraylist.size(); ++k) {
      trackerList.remove(arraylist.get(k));
    }

    AxisAlignedBB.a();
    Vec3D.a();
    ++this.ticks;

    // CraftBukkit start - only send timeupdates to the people in that world

    ((org.bukkit.craftbukkit.scheduler.CraftScheduler) this.server.getScheduler())
        .mainThreadHeartbeat(this.ticks);

    // Send timeupdates to everyone, it will get the right time from the world the player is in.
    if (this.ticks % 20 == 0) {
      for (k = 0; k < this.serverConfigurationManager.players.size(); ++k) {
        EntityPlayer entityplayer = (EntityPlayer) this.serverConfigurationManager.players.get(k);
        entityplayer.netServerHandler.sendPacket(
            new Packet4UpdateTime(entityplayer.getPlayerTime())); // Add support for per player time
      }
    }

    for (k = 0; k < this.worlds.size(); ++k) {
      long l = System.nanoTime();
      // if (k == 0 || this.propertyManager.getBoolean("allow-nether", true)) {
      WorldServer worldserver = this.worlds.get(k);

      /* Drop global timeupdates
      if (this.ticks % 20 == 0) {
          this.serverConfigurationManager.a(new Packet4UpdateTime(worldserver.getTime()), worldserver.worldProvider.dimension);
      }
      // CraftBukkit end */

      worldserver.doTick();

      while (true) {
        if (!worldserver.updateLights()) {
          worldserver.tickEntities();
          break;
        }
      }
    }

    // this.g[k][this.ticks % 100] = System.nanoTime() - l; // CraftBukkit
    // } // CraftBukkit

    this.networkListenThread.a();
    this.serverConfigurationManager.tick();

    // CraftBukkit start
    for (k = 0; k < this.worlds.size(); ++k) {
      this.worlds.get(k).tracker.updatePlayers();
    }
    // CraftBukkit end

    for (k = 0; k < this.C.size(); ++k) {
      ((IUpdatePlayerListBox) this.C.get(k)).a();
    }

    try {
      this.b();
    } catch (Exception exception) {
      log.log(Level.WARNING, "Unexpected exception while parsing console command", exception);
    }

    this.f[this.ticks % 100] = System.nanoTime() - i;
    this.u[this.ticks % 100] = Packet.n - this.E;
    this.E = Packet.n;
    this.v[this.ticks % 100] = Packet.o - this.F;
    this.F = Packet.o;
    this.w[this.ticks % 100] = Packet.l - this.G;
    this.G = Packet.l;
    this.x[this.ticks % 100] = Packet.m - this.H;
    this.H = Packet.m;
  }
Example #9
0
  private void w() {
    long i = System.nanoTime();
    ArrayList arraylist = new ArrayList();
    Iterator iterator = trackerList.keySet().iterator();

    while (iterator.hasNext()) {
      String s = (String) iterator.next();
      int j = ((Integer) trackerList.get(s)).intValue();

      if (j > 0) {
        trackerList.put(s, Integer.valueOf(j - 1));
      } else {
        arraylist.add(s);
      }
    }

    int k;

    for (k = 0; k < arraylist.size(); ++k) {
      trackerList.remove(arraylist.get(k));
    }

    AxisAlignedBB.a();
    Vec3D.a();
    ++this.ticks;

    for (k = 0; k < this.worldServer.length; ++k) {
      long l = System.nanoTime();

      if (k == 0 || this.propertyManager.getBoolean("allow-nether", true)) {
        WorldServer worldserver = this.worldServer[k];

        if (this.ticks % 20 == 0) {
          this.serverConfigurationManager.a(
              new Packet4UpdateTime(worldserver.getTime()), worldserver.worldProvider.dimension);
        }

        worldserver.doTick();

        while (true) {
          if (!worldserver.updateLights()) {
            worldserver.tickEntities();
            break;
          }
        }
      }

      this.g[k][this.ticks % 100] = System.nanoTime() - l;
    }

    this.networkListenThread.a();
    this.serverConfigurationManager.tick();

    for (k = 0; k < this.tracker.length; ++k) {
      this.tracker[k].updatePlayers();
    }

    for (k = 0; k < this.C.size(); ++k) {
      ((IUpdatePlayerListBox) this.C.get(k)).a();
    }

    try {
      this.b();
    } catch (Exception exception) {
      log.log(Level.WARNING, "Unexpected exception while parsing console command", exception);
    }

    this.f[this.ticks % 100] = System.nanoTime() - i;
    this.u[this.ticks % 100] = Packet.n - this.E;
    this.E = Packet.n;
    this.v[this.ticks % 100] = Packet.o - this.F;
    this.F = Packet.o;
    this.w[this.ticks % 100] = Packet.l - this.G;
    this.G = Packet.l;
    this.x[this.ticks % 100] = Packet.m - this.H;
    this.H = Packet.m;
  }
Example #10
0
  public void w_() {
    super.w_();
    if (this.lastPitch == 0.0F && this.lastYaw == 0.0F) {
      float f = MathHelper.a(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.e, this.f, this.g);

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

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

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

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

      if (i == this.h && j == this.i) {
        ++this.k;
        if (this.k == 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.k = 0;
        this.l = 0;
      }
    } else {
      ++this.l;
      Vec3D vec3d = Vec3D.create(this.locX, this.locY, this.locZ);
      Vec3D vec3d1 =
          Vec3D.create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
      MovingObjectPosition movingobjectposition = this.world.rayTrace(vec3d, vec3d1, false, true);

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

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

      int k;
      float f1;

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

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

          if (movingobjectposition1 != null) {
            double d1 = vec3d.b(movingobjectposition1.f);

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

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

      float f2;

      if (movingobjectposition != null) {
        // CraftBukkit start
        ProjectileHitEvent phe = new ProjectileHitEvent((Projectile) this.getBukkitEntity());
        this.world.getServer().getPluginManager().callEvent(phe);
        // CraftBukkit end
        if (movingobjectposition.entity != null) {
          f2 = MathHelper.a(this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ);
          int l = (int) Math.ceil((double) f2 * 2.0D);

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

          DamageSource damagesource = null;

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

          // CraftBukkit start
          boolean stick;
          if (entity instanceof EntityLiving) {

            org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity();
            Projectile projectile = (Projectile) this.getBukkitEntity();

            EntityDamageByEntityEvent event =
                new EntityDamageByEntityEvent(
                    projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, l);
            Bukkit.getPluginManager().callEvent(event);

            if (event.isCancelled()) {
              stick = !projectile.doesBounce();
            } else {
              // this function returns if the arrow should stick in or not, i.e. !bounce
              stick = movingobjectposition.entity.damageEntity(damagesource, event.getDamage());
            }
          } else {
            stick = movingobjectposition.entity.damageEntity(damagesource, l);
          }
          if (stick) {
            // CraftBukkit end
            if (movingobjectposition.entity instanceof EntityLiving) {
              ++((EntityLiving) movingobjectposition.entity).aH;
            }

            this.world.makeSound(
                this, "random.bowhit", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
            this.die();
          } else {
            this.motX *= -0.10000000149011612D;
            this.motY *= -0.10000000149011612D;
            this.motZ *= -0.10000000149011612D;
            this.yaw += 180.0F;
            this.lastYaw += 180.0F;
            this.l = 0;
          }
        } else {
          this.e = movingobjectposition.b;
          this.f = movingobjectposition.c;
          this.g = movingobjectposition.d;
          this.h = this.world.getTypeId(this.e, this.f, this.g);
          this.i = this.world.getData(this.e, this.f, this.g);
          this.motX = (double) ((float) (movingobjectposition.f.a - this.locX));
          this.motY = (double) ((float) (movingobjectposition.f.b - this.locY));
          this.motZ = (double) ((float) (movingobjectposition.f.c - this.locZ));
          f2 = MathHelper.a(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.world.makeSound(
              this, "random.bowhit", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
          this.inGround = true;
          this.shake = 7;
          this.d = false;
        }
      }

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

      this.locX += this.motX;
      this.locY += this.motY;
      this.locZ += this.motZ;
      f2 = MathHelper.a(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 f3 = 0.99F;

      f1 = 0.05F;
      if (this.az()) {
        for (int i1 = 0; i1 < 4; ++i1) {
          float f4 = 0.25F;

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

        f3 = 0.8F;
      }

      this.motX *= (double) f3;
      this.motY *= (double) f3;
      this.motZ *= (double) f3;
      this.motY -= (double) f1;
      this.setPosition(this.locX, this.locY, this.locZ);
    }
  }
  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);
            }
          }
        }
      }
    }
  }
Example #12
0
  public void a() {
    float f = this.size;
    byte b0 = 16;

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

    for (i = 0; i < b0; ++i) {
      for (j = 0; j < b0; ++j) {
        for (k = 0; k < b0; ++k) {
          if (i == 0 || i == b0 - 1 || j == 0 || j == b0 - 1 || k == 0 || k == b0 - 1) {
            double d3 = (double) ((float) i / ((float) b0 - 1.0F) * 2.0F - 1.0F);
            double d4 = (double) ((float) j / ((float) b0 - 1.0F) * 2.0F - 1.0F);
            double d5 = (double) ((float) k / ((float) b0 - 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) {
                f1 -= (Block.byId[k1].a(this.source) + 0.3F) * f2;
              }

              if (f1 > 0.0F) {
                this.g.add(new ChunkPosition(l, i1, j1));
              }

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

    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.b(
            this.source,
            AxisAlignedBB.b(
                (double) i, (double) k, (double) i2, (double) j, (double) l1, (double) j2));
    Vec3D vec3d = Vec3D.create(this.posX, this.posY, this.posZ);

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

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

        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
        CraftServer server = ((WorldServer) this.world).getServer();
        org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity();
        DamageCause damageType;
        int damageDone = (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
          // TODO: get the x/y/z of the tnt block?
          // does this even get called ever? @see EntityTNTPrimed - not BlockTNT or whatever
          damageType = EntityDamageEvent.DamageCause.BLOCK_EXPLOSION;

          EntityDamageByBlockEvent event =
              new EntityDamageByBlockEvent(null, damagee, damageType, damageDone);
          server.getPluginManager().callEvent(event);

          if (!event.isCancelled()) {
            entity.damageEntity(this.source, event.getDamage());
            entity.motX += d0 * d10;
            entity.motY += d1 * d10;
            entity.motZ += d2 * d10;
          }
        } else {
          org.bukkit.entity.Entity damager = this.source.getBukkitEntity();
          damageType = EntityDamageEvent.DamageCause.ENTITY_EXPLOSION;

          EntityDamageByEntityEvent event =
              new EntityDamageByEntityEvent(damager, damagee, damageType, damageDone);
          server.getPluginManager().callEvent(event);

          if (!event.isCancelled()) {
            entity.damageEntity(this.source, event.getDamage());

            entity.motX += d0 * d10;
            entity.motY += d1 * d10;
            entity.motZ += d2 * d10;
          }
        }
        // CraftBukkit end
      }
    }

    this.size = f;
    ArrayList arraylist = new ArrayList();

    arraylist.addAll(this.g);
    if (this.a) {
      for (int l2 = arraylist.size() - 1; l2 >= 0; --l2) {
        ChunkPosition chunkposition = (ChunkPosition) arraylist.get(l2);
        int i3 = chunkposition.x;
        int j3 = chunkposition.y;
        int k3 = chunkposition.z;
        int l3 = this.world.getTypeId(i3, j3, k3);
        int i4 = this.world.getTypeId(i3, j3 - 1, k3);

        if (l3 == 0 && Block.o[i4] && this.h.nextInt(3) == 0) {
          this.world.setTypeId(i3, j3, k3, Block.FIRE.id);
        }
      }
    }
  }
  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);
    }
  }
Example #14
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();
    }
  }
Example #15
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();
    }
  }
Example #16
0
  public MovingObjectPosition a(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) {
    this.updateShape(world, i, j, k);
    vec3d = vec3d.add((double) (-i), (double) (-j), (double) (-k));
    vec3d1 = vec3d1.add((double) (-i), (double) (-j), (double) (-k));
    Vec3D vec3d2 = vec3d.a(vec3d1, this.minX);
    Vec3D vec3d3 = vec3d.a(vec3d1, this.maxX);
    Vec3D vec3d4 = vec3d.b(vec3d1, this.minY);
    Vec3D vec3d5 = vec3d.b(vec3d1, this.maxY);
    Vec3D vec3d6 = vec3d.c(vec3d1, this.minZ);
    Vec3D vec3d7 = vec3d.c(vec3d1, this.maxZ);

    if (!this.a(vec3d2)) {
      vec3d2 = null;
    }

    if (!this.a(vec3d3)) {
      vec3d3 = null;
    }

    if (!this.b(vec3d4)) {
      vec3d4 = null;
    }

    if (!this.b(vec3d5)) {
      vec3d5 = null;
    }

    if (!this.c(vec3d6)) {
      vec3d6 = null;
    }

    if (!this.c(vec3d7)) {
      vec3d7 = null;
    }

    Vec3D vec3d8 = null;

    if (vec3d2 != null && (vec3d8 == null || vec3d.b(vec3d2) < vec3d.b(vec3d8))) {
      vec3d8 = vec3d2;
    }

    if (vec3d3 != null && (vec3d8 == null || vec3d.b(vec3d3) < vec3d.b(vec3d8))) {
      vec3d8 = vec3d3;
    }

    if (vec3d4 != null && (vec3d8 == null || vec3d.b(vec3d4) < vec3d.b(vec3d8))) {
      vec3d8 = vec3d4;
    }

    if (vec3d5 != null && (vec3d8 == null || vec3d.b(vec3d5) < vec3d.b(vec3d8))) {
      vec3d8 = vec3d5;
    }

    if (vec3d6 != null && (vec3d8 == null || vec3d.b(vec3d6) < vec3d.b(vec3d8))) {
      vec3d8 = vec3d6;
    }

    if (vec3d7 != null && (vec3d8 == null || vec3d.b(vec3d7) < vec3d.b(vec3d8))) {
      vec3d8 = vec3d7;
    }

    if (vec3d8 == null) {
      return null;
    } else {
      byte b0 = -1;

      if (vec3d8 == vec3d2) {
        b0 = 4;
      }

      if (vec3d8 == vec3d3) {
        b0 = 5;
      }

      if (vec3d8 == vec3d4) {
        b0 = 0;
      }

      if (vec3d8 == vec3d5) {
        b0 = 1;
      }

      if (vec3d8 == vec3d6) {
        b0 = 2;
      }

      if (vec3d8 == vec3d7) {
        b0 = 3;
      }

      return new MovingObjectPosition(i, j, k, b0, vec3d8.add((double) i, (double) j, (double) k));
    }
  }
Example #17
0
  public void b_() {
    O = p;
    P = q;
    Q = r;
    super.b_();
    if (a > 0) {
      a--;
    }
    if (f) {
      int i = this.l.a(b, c, d);

      if (i != e) {
        f = false;
        s *= W.nextFloat() * 0.2F;
        t *= W.nextFloat() * 0.2F;
        u *= W.nextFloat() * 0.2F;
        al = 0;
        am = 0;
      } else {
        al++;
        if (al == 1200) {
          q();
        }
        return;
      }
    } else {
      am++;
    }
    Vec3D vec3d = Vec3D.b(p, q, r);
    Vec3D vec3d1 = Vec3D.b(p + s, q + t, r + u);
    MovingObjectPosition movingobjectposition = this.l.a(vec3d, vec3d1);

    vec3d = Vec3D.b(p, q, r);
    vec3d1 = Vec3D.b(p + s, q + t, r + u);
    if (movingobjectposition != null) {
      vec3d1 =
          Vec3D.b(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c);
    }
    if (!this.l.z) {
      Entity entity = null;
      List list = this.l.b(((Entity) (this)), z.a(s, t, u).b(1.0D, 1.0D, 1.0D));
      double d1 = 0.0D;

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

        if (!entity1.c_() || entity1 == ak && am < 5) {
          continue;
        }
        float f4 = 0.3F;
        AxisAlignedBB axisalignedbb = entity1.z.b(f4, f4, f4);
        MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);

        if (movingobjectposition1 == null) {
          continue;
        }
        double d2 = vec3d.a(movingobjectposition1.f);

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

      if (entity != null) {
        movingobjectposition = new MovingObjectPosition(entity);
      }
    }
    if (movingobjectposition != null) {
      if (movingobjectposition.g != null) {
        if (!movingobjectposition.g.a(((Entity) (ak)), 0)) {;
        }
      }
      if (!this.l.z && W.nextInt(8) == 0) {
        byte byte0 = 1;

        if (W.nextInt(32) == 0) {
          byte0 = 4;
        }
        for (int k = 0; k < byte0; k++) {
          EntityChicken entitychicken = new EntityChicken(this.l);

          entitychicken.c(p, q, r, v, 0.0F);
          this.l.a(((Entity) (entitychicken)));
        }
      }
      for (int j = 0; j < 8; j++) {
        this.l.a("snowballpoof", p, q, r, 0.0D, 0.0D, 0.0D);
      }

      q();
    }
    p += s;
    q += t;
    r += u;
    float f1 = MathHelper.a(s * s + u * u);

    v = (float) ((Math.atan2(s, u) * 180D) / 3.1415927410125732D);
    for (w = (float) ((Math.atan2(t, f1) * 180D) / 3.1415927410125732D);
        w - y < -180F;
        y -= 360F) {;
    }
    for (; w - y >= 180F; y += 360F) {;
    }
    for (; v - x < -180F; x -= 360F) {;
    }
    for (; v - x >= 180F; x += 360F) {;
    }
    w = y + (w - y) * 0.2F;
    v = x + (v - x) * 0.2F;
    float f2 = 0.99F;
    float f5 = 0.03F;

    if (v()) {
      for (int i1 = 0; i1 < 4; i1++) {
        float f3 = 0.25F;

        this.l.a("bubble", p - s * (double) f3, q - t * (double) f3, r - u * (double) f3, s, t, u);
      }

      f2 = 0.8F;
    }
    s *= f2;
    t *= f2;
    u *= f2;
    t -= f5;
    a(p, q, r);
  }
Example #18
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);
          }
        }
      }
    }
  }
Example #19
0
  public MovingObjectPosition a(Vec3D vec3d, Vec3D vec3d1) {
    Vec3D vec3d2 = vec3d.a(vec3d1, this.a);
    Vec3D vec3d3 = vec3d.a(vec3d1, this.d);
    Vec3D vec3d4 = vec3d.b(vec3d1, this.b);
    Vec3D vec3d5 = vec3d.b(vec3d1, this.e);
    Vec3D vec3d6 = vec3d.c(vec3d1, this.c);
    Vec3D vec3d7 = vec3d.c(vec3d1, this.f);

    if (!this.b(vec3d2)) {
      vec3d2 = null;
    }

    if (!this.b(vec3d3)) {
      vec3d3 = null;
    }

    if (!this.c(vec3d4)) {
      vec3d4 = null;
    }

    if (!this.c(vec3d5)) {
      vec3d5 = null;
    }

    if (!this.d(vec3d6)) {
      vec3d6 = null;
    }

    if (!this.d(vec3d7)) {
      vec3d7 = null;
    }

    Vec3D vec3d8 = null;

    if (vec3d2 != null
        && (vec3d8 == null || vec3d.distanceSquared(vec3d2) < vec3d.distanceSquared(vec3d8))) {
      vec3d8 = vec3d2;
    }

    if (vec3d3 != null
        && (vec3d8 == null || vec3d.distanceSquared(vec3d3) < vec3d.distanceSquared(vec3d8))) {
      vec3d8 = vec3d3;
    }

    if (vec3d4 != null
        && (vec3d8 == null || vec3d.distanceSquared(vec3d4) < vec3d.distanceSquared(vec3d8))) {
      vec3d8 = vec3d4;
    }

    if (vec3d5 != null
        && (vec3d8 == null || vec3d.distanceSquared(vec3d5) < vec3d.distanceSquared(vec3d8))) {
      vec3d8 = vec3d5;
    }

    if (vec3d6 != null
        && (vec3d8 == null || vec3d.distanceSquared(vec3d6) < vec3d.distanceSquared(vec3d8))) {
      vec3d8 = vec3d6;
    }

    if (vec3d7 != null
        && (vec3d8 == null || vec3d.distanceSquared(vec3d7) < vec3d.distanceSquared(vec3d8))) {
      vec3d8 = vec3d7;
    }

    if (vec3d8 == null) {
      return null;
    } else {
      byte b0 = -1;

      if (vec3d8 == vec3d2) {
        b0 = 4;
      }

      if (vec3d8 == vec3d3) {
        b0 = 5;
      }

      if (vec3d8 == vec3d4) {
        b0 = 0;
      }

      if (vec3d8 == vec3d5) {
        b0 = 1;
      }

      if (vec3d8 == vec3d6) {
        b0 = 2;
      }

      if (vec3d8 == vec3d7) {
        b0 = 3;
      }

      return new MovingObjectPosition(0, 0, 0, b0, vec3d8);
    }
  }
  /** Called to update the entity's position/logic. */
  public void F_() {
    aA();

    if (timeInAir == 30) {
      setEntityDead();
    }

    world.a("smoke", locX, locY, locZ, 0.0D, 0.0D, 0.0D);

    if (inGround) {
      int i = world.getTypeId(xTile, yTile, zTile);

      if (i != inTile) {
        inGround = false;
        motX *= random.nextFloat() * 0.2F;
        motY *= random.nextFloat() * 0.2F;
        motZ *= random.nextFloat() * 0.2F;
        timeInTile = 0;
        timeInAir = 0;
      }
    } else {
      timeInAir++;
    }

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

    if (movingobjectposition != null) {
      vec3d1 =
          Vec3D.create(
              movingobjectposition.pos.a, movingobjectposition.pos.b, movingobjectposition.pos.c);
    }

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

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

      if (!entity1.o_()
          || (entity1 == owner || owner != null && entity1 == owner.vehicle) && timeInAir < 5
          || serverSpawned) {
        continue;
      }

      float f = 0.3F;
      AxisAlignedBB axisalignedbb = entity1.boundingBox.grow(f, f, f);
      MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);

      if (movingobjectposition1 == null) {
        continue;
      }

      double d1 = vec3d.b(movingobjectposition1.pos);

      if (d1 < d || d == 0.0D) {
        vec3d2 = movingobjectposition1.pos;
        entity = entity1;
        d = d1;
      }
    }

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

    if (movingobjectposition != null) {
      if (movingobjectposition.entity != null) {
        int k = damage;

        if ((owner instanceof IMonster) && (movingobjectposition.entity instanceof EntityHuman)) {
          if (world.difficulty == 0) {
            k = 0;
          }

          if (world.difficulty == 1) {
            k = k / 3 + 1;
          }

          if (world.difficulty == 3) {
            k = (k * 3) / 2;
          }
        }

        k = checkHeadshot(movingobjectposition, vec3d2, k);

        if (movingobjectposition.entity instanceof EntityLiving) {
          WarTools.attackEntityIgnoreDelay(
              (EntityLiving) movingobjectposition.entity, DamageSource.projectile(this, owner), k);
        } else {
          movingobjectposition.entity.damageEntity(DamageSource.projectile(this, owner), k);
        }

        movingobjectposition.entity.setOnFire(300);
      } else {
        xTile = movingobjectposition.b;
        yTile = movingobjectposition.c;
        zTile = movingobjectposition.d;

        if (world.getTypeId(xTile, yTile, zTile) == Block.ICE.id && Block.ICE.m() < 1000000F) {
          Block.ICE.remove(world, xTile, yTile, zTile);
        } else {
          byte byte0 = (byte) (motX > 0.0D ? 1 : -1);
          byte byte1 = (byte) (motY > 0.0D ? 1 : -1);
          byte byte2 = (byte) (motZ > 0.0D ? 1 : -1);
          boolean flag =
              world.getTypeId(xTile - byte0, yTile, zTile) == 0
                  || world.getTypeId(xTile - byte0, yTile, zTile) == Block.SNOW.id;
          boolean flag1 =
              world.getTypeId(xTile, yTile - byte1, zTile) == 0
                  || world.getTypeId(xTile, yTile - byte1, zTile) == Block.SNOW.id;
          boolean flag2 =
              world.getTypeId(xTile, yTile, zTile - byte2) == 0
                  || world.getTypeId(xTile, yTile, zTile - byte2) == Block.SNOW.id;

          if (flag) {
            world.setTypeId(xTile - byte0, yTile, zTile, Block.FIRE.id);
          }

          if (flag1) {
            world.setTypeId(xTile, yTile - byte1, zTile, Block.FIRE.id);
          }

          if (flag2) {
            world.setTypeId(xTile, yTile, zTile - byte2, Block.FIRE.id);
          }
        }
      }

      setEntityDead();
    }

    locX += motX;
    locY += motY;
    locZ += motZ;
    setRotationToVelocity();

    if (world.a(boundingBox, Material.WATER, this)) {
      setEntityDead();
    }

    setPosition(locX, locY, locZ);
  }