minecraft-assets
A Rust library for reading asset files and resource packs for any version of Minecraft.
Example
use minecraft_assets::api::AssetPack;
let assets = AssetPack::at_path("~/.minecraft/");
// Load the block states for `oak_planks`
let states = assets.load_blockstates("oak_planks").unwrap();
let variants = states.variants().unwrap();
assert_eq!(variants.len(), 1);
let model_properties = &variants[""].models()[0];
assert_eq!(model_properties.model, "block/oak_planks");
Documentation
This library is #![warn(missing_docs)]
, so the documentation is very complete:
Feature checklist
Assets parsing
-
assets/
/blockstates/*.json -
assets/
/font/*.json -
assets/
/lang/*.json -
assets/
/models/block/*.json -
assets/
/models/item/*.json -
assets/
/particles/*.json -
assets/
/shaders/{post,program}/*.json -
assets/
/textures/*.mcmeta -
assets/
/sounds.json -
assets/pack.mcmeta
Data parsing
-
data/
/advancements/**/*.json -
data/
/loot_tables/**/*.json -
data/
/recipes/*.json -
data/
/structures/**/*.json -
data/
/tags/**/*.json
minecraft-assets
Projects using - Brine: A multi-version Minecraft client written using Bevy.
- Maybe your project here! :)
Tests
Integration tests in tests/
use the actual asset files from the minecraft-assets
repository.
That repository is fairly large (~1 GB), so the tests in tests/
do not run by default. If you'd like to run them, use the tests/setup.sh
script:
$ ./tests/setup.sh
This script will fetch the minecraft-assets
repository and check out a few different versions at various paths in tests/
. Then you can run the tests by enabling the tests
feature:
$ cargo test --features tests
License
Licensed under either of
- Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (http://opensource.org/licenses/MIT)
at your option.
Copyright Ben Reeves 2022
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.