| Crates.io | blockpedia |
| lib.rs | blockpedia |
| version | 0.1.2 |
| created_at | 2025-07-07 01:05:40.437092+00 |
| updated_at | 2025-07-07 06:53:20.521735+00 |
| description | A comprehensive Rust library for Minecraft block data with advanced color analysis and palette generation |
| homepage | https://github.com/Nano112/blockpedia |
| repository | https://github.com/Nano112/blockpedia |
| max_upload_size | |
| id | 1740557 |
| size | 2,085,223 |
A comprehensive Rust library for Minecraft block data with advanced color analysis and gradient palette generation.
Blockpedia provides programmatic access to Minecraft block information, including properties, color data extracted from real textures, and sophisticated palette generation capabilities. Perfect for building tools, mods, or applications that need to work with Minecraft block data.
git clone https://github.com/Nano112/blockpedia.git
cd blockpedia
cargo build --release
cargo install --path .
cargo run --bin blockpedia-cli
use blockpedia::{get_block, BLOCKS, queries::*};
// Get a specific block
let stone = get_block("minecraft:stone").unwrap();
println!("Stone properties: {:?}", stone.properties());
// Search for blocks
let redstone_blocks: Vec<_> = find_blocks_by_property("powered", "true").collect();
println!("Found {} powered blocks", redstone_blocks.len());
// Color analysis
if let Some(color) = stone.extras.color {
println!("Stone color: #{:02X}{:02X}{:02X}",
color.rgb[0], color.rgb[1], color.rgb[2]);
}
use blockpedia::color::palettes::{PaletteGenerator, GradientMethod};
use blockpedia::color::ExtendedColorData;
// Create a gradient between two colors
let red = ExtendedColorData::from_rgb(255, 0, 0);
let blue = ExtendedColorData::from_rgb(0, 0, 255);
let gradient = PaletteGenerator::generate_gradient_palette(
red, blue, 10, GradientMethod::LinearOklab
);
// Generate themed palettes
let sunset = PaletteGenerator::generate_sunset_palette(8);
let ocean = PaletteGenerator::generate_ocean_palette(6);
// Export to various formats
let css = PaletteGenerator::export_palette_css(&gradient);
let gpl = PaletteGenerator::export_palette_gpl(&gradient, "My Gradient");
The interactive CLI provides six specialized tabs for exploring block data:
[1] Color Coverage Analysis - See 44.6% coverage statistics
[2] Color Palette Analysis - Group blocks by color families
[3] Color Similarity Search - Find blocks similar to stone gray
[4] Color Statistics - Brightness, averages, extremes
[5] Gradient Palettes - Generate gradients between blocks
[6] Themed Palettes - Sunset, ocean, fire themes
[n] Search by Name - e.g., 'stone', 'wool'
[p] Search by Property - e.g., 'delay:1', 'facing:north'
[c] Search by Color - e.g., '#FF0000', '#7D7D7D'
[a] Advanced Query Builder - Complex multi-filter queries
[r] Reset Filters - Clear all active filters
use blockpedia::{BLOCKS, queries::*, get_block};
// Basic block access
let dirt = get_block("minecraft:dirt")?;
println!("Block: {}", dirt.id());
// Property-based searches
let stairs: Vec<_> = find_blocks_by_property("shape", "straight").collect();
let waterlogged: Vec<_> = find_blocks_by_property("waterlogged", "true").collect();
// Pattern searches
let wool_blocks: Vec<_> = search_blocks("*wool").collect();
let stone_variants: Vec<_> = search_blocks("*stone*").collect();
// Statistical analysis
let stats = get_property_stats();
println!("Unique properties: {}", stats.total_unique_properties);
println!("Average properties per block: {:.2}", stats.average_properties_per_block);
// Block families
let families = get_block_families();
for (family, blocks) in families {
println!("{}: {} blocks", family, blocks.len());
}
use blockpedia::color::*;
// Extract colors from textures
let color = extract_dominant_color(Path::new("assets/textures/stone.png"))?;
println!("Dominant color: {:?}", color.rgb);
// Color space conversions
let extended = ExtendedColorData::from_rgb(128, 64, 192);
println!("HSL: {:?}", extended.hsl);
println!("Oklab: {:?}", extended.oklab);
println!("Hex: {}", extended.hex_string());
// Color similarity
let target = ExtendedColorData::from_rgb(125, 125, 125);
let similar_blocks: Vec<_> = BLOCKS.values()
.filter(|block| {
if let Some(color) = block.extras.color {
color.to_extended().distance_oklab(&target) < 20.0
} else {
false
}
})
.collect();
use blockpedia::{BlockState, transforms::{Direction, BlockShape}};
// Rotation operations
let repeater = BlockState::parse("minecraft:repeater[facing=north,delay=2]")?;
let rotated = repeater.rotate_clockwise()?; // Now faces east
let rotated_180 = repeater.rotate_180()?; // Now faces south
let rotated_ccw = repeater.rotate_counter_clockwise()?; // Now faces west
// Material variants - preserve shape and properties
let oak_stairs = BlockState::parse("minecraft:oak_stairs[facing=north,half=top]")?;
let stone_stairs = oak_stairs.with_material("stone")?; // minecraft:stone_stairs[facing=north,half=top]
// Shape variants - preserve material and compatible properties
let stone_block = BlockState::new("minecraft:stone")?;
let stone_stairs = stone_block.with_shape(BlockShape::Stairs)?; // minecraft:stone_stairs[facing=north,half=bottom,shape=straight]
let stone_slab = stone_block.with_shape(BlockShape::Slab)?; // minecraft:stone_slab[type=bottom]
// Discover available variants
let oak_stairs = BlockState::new("minecraft:oak_stairs")?;
let materials = oak_stairs.available_materials()?; // ["acacia", "andesite", "bamboo", ...]
let shapes = oak_stairs.available_shapes()?; // [Stairs, Slab, Full, Wall, Fence, ...]
// Complex transformations
let complex_stairs = BlockState::parse("minecraft:oak_stairs[facing=west,half=top,shape=inner_left]")?;
let rotated_stone = complex_stairs
.rotate_clockwise()? // facing=north, shape=inner_right
.with_material("stone_brick")?; // minecraft:stone_brick_stairs[facing=north,half=top,shape=inner_right]
// Axis rotation for logs and pillars
let log = BlockState::parse("minecraft:oak_log[axis=x]")?;
let rotated_log = log.rotate_clockwise()?; // axis=z
Blockpedia features a sophisticated color system with real texture data:
use blockpedia::color::extraction::{ColorExtractor, ExtractionMethod};
let extractor = ColorExtractor::new(ExtractionMethod::MostFrequent { bins: 16 });
let color = extractor.extract_color(&image)?;
// Different extraction methods
let average = ExtractionMethod::Average;
let clustering = ExtractionMethod::Clustering { k: 5 };
let edge_weighted = ExtractionMethod::EdgeWeighted;
use blockpedia::color::palettes::{GradientMethod, PaletteGenerator};
// Linear RGB - Simple RGB interpolation
let rgb_gradient = PaletteGenerator::generate_gradient_palette(
start_color, end_color, 10, GradientMethod::LinearRgb
);
// Linear HSL - Hue-based interpolation (smooth color wheel transitions)
let hsl_gradient = PaletteGenerator::generate_gradient_palette(
start_color, end_color, 10, GradientMethod::LinearHsl
);
// Linear Oklab - Perceptually uniform (most natural to human eye)
let oklab_gradient = PaletteGenerator::generate_gradient_palette(
start_color, end_color, 10, GradientMethod::LinearOklab
);
// Cubic Bezier - Smooth curves with acceleration/deceleration
let bezier_gradient = PaletteGenerator::generate_gradient_palette(
start_color, end_color, 10, GradientMethod::CubicBezier
);
let colors = vec![
ExtendedColorData::from_rgb(255, 0, 0), // Red
ExtendedColorData::from_rgb(255, 255, 0), // Yellow
ExtendedColorData::from_rgb(0, 255, 0), // Green
ExtendedColorData::from_rgb(0, 0, 255), // Blue
];
let rainbow = PaletteGenerator::generate_multi_gradient_palette(
colors, 20, GradientMethod::LinearOklab
);
// Pre-designed palettes for common use cases
let sunset = PaletteGenerator::generate_sunset_palette(8); // Warm reds to deep blues
let ocean = PaletteGenerator::generate_ocean_palette(6); // Light to deep blues
let fire = PaletteGenerator::generate_fire_palette(5); // Yellows to deep reds
let forest = PaletteGenerator::generate_forest_palette(7); // Light to dark greens
// Dynamic palettes based on existing colors
let base_color = ExtendedColorData::from_rgb(128, 64, 192);
let monochrome = PaletteGenerator::generate_monochrome_palette(base_color, 9);
let complementary = PaletteGenerator::generate_complementary_palette(&base_color);
// CSS Variables
let css = PaletteGenerator::export_palette_css(&palette);
/*
:root {
--color-1: #FF0000;
--color-2: #FF8000;
--color-3: #FFFF00;
}
*/
// GIMP Palette (.gpl)
let gpl = PaletteGenerator::export_palette_gpl(&palette, "Sunset Gradient");
// Adobe Photoshop (.aco)
let aco_data = PaletteGenerator::export_palette_aco_data(&palette);
std::fs::write("palette.aco", aco_data)?;
use blockpedia::{BLOCKS, queries::*};
let redstone_blocks: Vec<_> = BLOCKS.values()
.filter(|block| {
block.id().contains("redstone") ||
block.has_property("powered") ||
block.has_property("signal_strength")
})
.collect();
println!("Found {} redstone components", redstone_blocks.len());
use blockpedia::{BLOCKS, color::palettes::PaletteGenerator};
// Get colors from wood blocks
let wood_colors: Vec<_> = BLOCKS.values()
.filter(|block| block.id().contains("wood") || block.id().contains("log"))
.filter_map(|block| block.extras.color.map(|c| c.to_extended()))
.collect();
let wood_palette = PaletteGenerator::generate_distinct_palette(&wood_colors, 8);
let css_export = PaletteGenerator::export_palette_css(&wood_palette);
use blockpedia::{BLOCKS, color::ExtendedColorData};
fn find_blocks_for_color_scheme(target_color: ExtendedColorData, tolerance: f32) -> Vec<&'static BlockFacts> {
BLOCKS.values()
.filter(|block| {
if let Some(color) = block.extras.color {
color.to_extended().distance_oklab(&target_color) <= tolerance
} else {
false
}
})
.collect()
}
let sage_green = ExtendedColorData::from_rgb(158, 184, 156);
let matching_blocks = find_blocks_for_color_scheme(sage_green, 25.0);
# Clone the repository
git clone https://github.com/Nano112/blockpedia.git
cd blockpedia
# Download texture data (optional, for color extraction)
cargo run --bin download-textures
# Build in development mode
cargo build
# Run tests
cargo test
# Build CLI in release mode
cargo build --release --bin blockpedia-cli
# Use alternative data source
BLOCKPEDIA_DATA_SOURCE=MCPropertyEncyclopedia cargo build
# Skip texture downloads (for CI/limited bandwidth)
BLOCKPEDIA_SKIP_TEXTURES=1 cargo build
Blockpedia supports multiple data sources:
The build system automatically fetches and caches data from these sources.
# Run all tests
cargo test
# Run specific test suites
cargo test --test gradient_palettes_test
cargo test color
cargo test queries
# Test with different data sources
BLOCKPEDIA_DATA_SOURCE=MCPropertyEncyclopedia cargo test
# Generate test coverage
cargo tarpaulin --out html
git checkout -b feature/amazing-feature)cargo test)cargo fmt)cargo clippy)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
๐ Home โข ๐ Documentation โข ๐ Issues โข ๐ฌ Discussions
Made with โค๏ธ by Nano112