Skip to content

Commit ebc330c

Browse files
[world_exporter] create world conversion tool
1 parent a423ac4 commit ebc330c

File tree

8 files changed

+1049
-211
lines changed

8 files changed

+1049
-211
lines changed

Cargo.lock

Lines changed: 496 additions & 204 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace]
2-
members = ["crates/proc_macros", "crates/redpiler_graph"]
2+
members = ["crates/proc_macros", "crates/redpiler_graph", "crates/world_exporter"]
33

44
[package]
55
name = "mchprs"
@@ -84,3 +84,5 @@ quote = "1"
8484
tracing-subscriber = "0.3"
8585
tracing-appender = "0.2"
8686
paste = "1.0"
87+
chrono = "0.4"
88+
clap = { version = "4.5", features = ["derive"] }

crates/blocks/src/blocks/mod.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ mod props;
22

33
use crate::{BlockColorVariant, BlockDirection, BlockFacing, BlockProperty, SignType};
44
use mchprs_proc_macros::BlockTransform;
5+
use mchprs_utils::map;
56
pub use props::*;
67
use std::collections::HashMap;
78

@@ -117,6 +118,15 @@ impl Block {
117118
| 10757..=10758 // Large Fern
118119
)
119120
}
121+
122+
pub fn properties(&self) -> HashMap<&'static str, String> {
123+
if matches!(self, Block::SmoothStoneSlab {} | Block::QuartzSlab {}) {
124+
return map! {
125+
"type" => "top".to_string()
126+
};
127+
}
128+
self.gen_properties()
129+
}
120130
}
121131

122132
#[test]
@@ -289,7 +299,7 @@ macro_rules! blocks {
289299
}
290300
}
291301

292-
pub fn properties(&self) -> HashMap<&'static str, String> {
302+
pub fn gen_properties(&self) -> HashMap<&'static str, String> {
293303
let mut props = HashMap::new();
294304
match self {
295305
$(
@@ -904,7 +914,7 @@ blocks! {
904914
from_names(_name): {
905915
"smooth_stone_slab" => {}
906916
},
907-
get_name: "smooth_stone_slab[type=top]",
917+
get_name: "smooth_stone_slab",
908918
transparent: true,
909919
cube: true,
910920
},

crates/world/src/storage.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl PalettedBitBuffer {
136136
}
137137
}
138138

139-
fn load(
139+
pub fn load(
140140
entries: usize,
141141
bits_per_entry: u8,
142142
longs: Vec<u64>,
@@ -218,6 +218,18 @@ impl PalettedBitBuffer {
218218
self.data.entries
219219
}
220220

221+
pub fn palette(&self) -> &[u32] {
222+
&self.palette
223+
}
224+
225+
pub fn data(&self) -> &[u64] {
226+
&self.data.longs
227+
}
228+
229+
pub fn bits_per_entry(&self) -> u8 {
230+
self.data.bits_per_entry as u8
231+
}
232+
221233
#[cfg(feature = "networking")]
222234
fn encode_packet(&self) -> PalettedContainer {
223235
if self.use_palette && self.palette.len() == 1 {
@@ -303,15 +315,15 @@ impl ChunkSection {
303315
}
304316

305317
pub fn data(&self) -> &[u64] {
306-
&self.buffer.data.longs
318+
self.buffer.data()
307319
}
308320

309321
pub fn palette(&self) -> &[u32] {
310-
&self.buffer.palette
322+
self.buffer.palette()
311323
}
312324

313325
pub fn bits_per_block(&self) -> u8 {
314-
self.buffer.data.bits_per_entry as u8
326+
self.buffer.bits_per_entry()
315327
}
316328

317329
pub fn block_count(&self) -> u32 {

crates/world_exporter/Cargo.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
[package]
3+
name = "mchprs_world_exporter"
4+
authors.workspace = true
5+
description.workspace = true
6+
edition.workspace = true
7+
homepage.workspace = true
8+
keywords.workspace = true
9+
readme.workspace = true
10+
version.workspace = true
11+
license.workspace = true
12+
repository.workspace = true
13+
14+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
15+
16+
[dependencies]
17+
mchprs_blocks = { path = "../blocks" }
18+
mchprs_save_data = { path = "../save_data" }
19+
mchprs_utils = { path = "../utils" }
20+
mchprs_world = { path = "../world" }
21+
serde = { workspace = true }
22+
hematite-nbt = { workspace = true }
23+
anyhow = { workspace = true }
24+
chrono = { workspace = true }
25+
clap = { workspace = true }

0 commit comments

Comments
 (0)