Struct minecraft_assets::api::AssetPack [−][src]
pub struct AssetPack { /* fields omitted */ }Expand description
Top-level API for accessing Minecraft assets.
Implementations
Returns a new AssetPack that can read data from the given directory.
The provided root_dir should be the directory that contains the
assets/ and/or data/ directories.
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");Returns a new AssetPack that uses the given ResourceProvider.
Loads the BlockStates of the block with the provided id.
Example
let states = assets.load_blockstates("stone");
let states = assets.load_blockstates("minecraft:dirt");Loads the block Model identified by the given name or path, as well
as all of its parents and ancestors.
The models are returned as a list, with the first element being the model that was originally requested, the next element being its parent, and so on with the last element being the topmost parent.
Example
let models = assets.load_block_model_recursive("block/cube_all").unwrap();
let expected = vec![
assets.load_block_model("block/cube_all").unwrap(),
assets.load_block_model("block/cube").unwrap(),
assets.load_block_model("block/block").unwrap(),
];
assert_eq!(models, expected);Loads the item Model identified by the given name or path, as well
as all of its parents and ancestors.
The models are returned as a list, with the first element being the model that was originally requested, the next element being its parent, and so on with the last element being the topmost parent.
Example
let models = assets.load_item_model_recursive("item/diamond_hoe").unwrap();
let expected = vec![
assets.load_item_model("item/diamond_hoe").unwrap(),
assets.load_item_model("item/handheld").unwrap(),
assets.load_item_model("item/generated").unwrap(),
];
assert_eq!(models, expected);