Crate piston_mc

Crate piston_mc 

Source
Expand description

§Piston-MC

A Rust library for interacting with Mojang’s Piston Meta API to fetch Minecraft version manifests, download game clients/servers, and manage game assets.

§Features

  • Version Manifest Fetching - Query all Minecraft versions from Mojang’s official API
  • Client & Server Downloads - Download Minecraft client and server JARs with progress tracking
  • Library Downloads - Download game libraries including platform-specific native libraries
  • Asset Management - Download and validate game assets (textures, sounds, etc.)
  • Java Runtime Management - Fetch and install Java runtimes for any platform
  • Patch Notes - Fetch patch notes for Java Edition, Bedrock Edition, Dungeons, and Launcher
  • News - Fetch Minecraft news from Mojang’s launcher content API
  • SHA1 Validation - Verify file integrity after downloads
  • Parallel Downloads - Configurable concurrent downloads for faster asset retrieval
  • Progress Reporting - Real-time download progress via async channels

§Installation

Add to your Cargo.toml:

[dependencies]
piston-mc = "0.0.1-alpha"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }

§Quick Start

use piston_mc::manifest_v2::ManifestV2;

#[tokio::main]
async fn main() {
	// Fetch the version manifest
	let manifest = ManifestV2::fetch().await.expect("Failed to fetch manifest");

	// Display latest versions
	println!("Latest Release: {}", manifest.latest.release);
	println!("Latest Snapshot: {}", manifest.latest.snapshot);

	// Get a specific version and download the client
	if let Ok(Some(version)) = manifest.version("1.21.4").await {
		version.download_client("client.jar", true, None).await.unwrap();
	}
}

§Modules

ModuleDescription
ManifestV2Fetch and query the Minecraft version manifest
VersionManifestDetailed version info with client/server downloads
AssetsDownload and validate game assets
JavaFetch and install Java runtimes from Mojang
PatchNotesFetch patch notes for all Minecraft editions
DownloadUtilFile download utilities with progress tracking
ShaValidationSHA1 file hash validation

§Examples

The library includes several examples demonstrating common use cases:

ExampleDescription
get_minecraft_versionsFetch and list all Minecraft versions
get_specific_minecraft_versionGet detailed info for a specific version
download_minecraft_clientDownload a client JAR
download_minecraft_client_with_progressDownload client with progress reporting
download_minecraft_serverDownload a server JAR
download_minecraft_server_with_progressDownload server with progress reporting
download_librariesDownload game libraries with progress
download_assetsDownload game assets with progress
get_java_installation_filesList files in a Java runtime
install_javaInstall Java runtime with progress
get_java_patch_notesFetch Java Edition patch notes
get_bedrock_patch_notesFetch Bedrock Edition patch notes
get_dungeons_patch_notesFetch Minecraft Dungeons patch notes
get_launcher_patch_notesFetch Minecraft Launcher patch notes

Run examples with:

cargo run --example get_minecraft_versions
cargo run --example download_minecraft_client

§API Sources

This library fetches data from Mojang’s official APIs:

APIURL
Version Manifesthttps://piston-meta.mojang.com/mc/game/version_manifest_v2.json
Java Runtimeshttps://piston-meta.mojang.com/v1/products/java-runtime/2ec0cc96c44e5a76b9c8b7c39df7210883d12871/all.json
Asset CDNhttps://resources.download.minecraft.net/
Java Patch Noteshttps://launchercontent.mojang.com/javaPatchNotes.json
Bedrock Patch Noteshttps://launchercontent.mojang.com/bedrockPatchNotes.json
Dungeons Patch Noteshttps://launchercontent.mojang.com/dungeonsPatchNotes.json
Launcher Patch Noteshttps://launchercontent.mojang.com/launcherPatchNotes_v2.json
Newshttps://launchercontent.mojang.com/news.json

§Requirements

  • Rust 2024 Edition
  • Tokio async runtime

Modules§

assets
The Assets module provides functionality for downloading and validating Minecraft game assets (textures, sounds, etc.) from Mojang’s resource CDN.
java
The Java module provides functionality for fetching and installing Java runtimes from Mojang’s Piston API. This enables automatic Java runtime management for Minecraft launchers.
manifest_v2
The ManifestV2 module provides access to Mojang’s Piston Meta API, allowing you to fetch and query the Minecraft version manifest.
sha_validation
The ShaValidation module provides SHA1 hash validation for files, ensuring downloaded files are not corrupted or tampered with.
version_manifest
The VersionManifest module provides detailed information about a specific Minecraft version, including download URLs for the client and server JARs, asset information, and launch arguments.

Macros§

debug
error
info
warn