コード例 #1
0
  protected void func_35201_a(ItemStack itemstack, int i) {
    if (itemstack.getItemUseAction() == EnumAction.drink) {
      worldObj.playSoundAtEntity(
          this, "random.drink", 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F);
    }
    if (itemstack.getItemUseAction() == EnumAction.eat) {
      for (int j = 0; j < i; j++) {
        Vec3D vec3d =
            Vec3D.createVector(
                ((double) rand.nextFloat() - 0.5D) * 0.10000000000000001D,
                Math.random() * 0.10000000000000001D + 0.10000000000000001D,
                0.0D);
        vec3d.rotateAroundX((-rotationPitch * 3.141593F) / 180F);
        vec3d.rotateAroundY((-rotationYaw * 3.141593F) / 180F);
        Vec3D vec3d1 =
            Vec3D.createVector(
                ((double) rand.nextFloat() - 0.5D) * 0.29999999999999999D,
                (double) (-rand.nextFloat()) * 0.59999999999999998D - 0.29999999999999999D,
                0.59999999999999998D);
        vec3d1.rotateAroundX((-rotationPitch * 3.141593F) / 180F);
        vec3d1.rotateAroundY((-rotationYaw * 3.141593F) / 180F);
        vec3d1 = vec3d1.addVector(posX, posY + (double) getEyeHeight(), posZ);
        worldObj.spawnParticle(
            (new StringBuilder())
                .append("iconcrack_")
                .append(itemstack.getItem().shiftedIndex)
                .toString(),
            vec3d1.xCoord,
            vec3d1.yCoord,
            vec3d1.zCoord,
            vec3d.xCoord,
            vec3d.yCoord + 0.050000000000000003D,
            vec3d.zCoord);
      }

      worldObj.playSoundAtEntity(
          this,
          "random.eat",
          0.5F + 0.5F * (float) rand.nextInt(2),
          (rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F);
    }
  }