예제 #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);
    }
  }
예제 #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_();
    }
  }
예제 #3
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);
    }
  }
예제 #4
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);
  }
예제 #5
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));
    }
  }