vintage_schematics/convert/
mod.rs

1//! Schematic conversion logic.
2
3use crate::formats::internal::PropertyMap;
4
5pub mod block;
6pub mod entities;
7pub mod material;
8pub mod mods;
9
10fn determine_orientation(properties: &PropertyMap) -> Option<&str> {
11	properties
12		.iter()
13		.find_map(|(k, v)| match k.as_str() {
14			"north" | "south" | "east" | "west" if v == "true" => Some(k),
15			_ => None,
16		})
17		.map(String::as_str)
18}
19
20/// Reverses the orientation of a block, e.g. "north" becomes "south".
21///
22/// Many blocks in Minecraft mean "facing east" to mean "attached to the east side of a block" (and therefore sticking
23/// out in the west axis).
24/// Their Vintage Story equivalent blocks will typically use "facing east" to mean "with its back to the east" (and
25/// therefore sticking out in the east axis).
26///
27/// For example, an east-facing Minecraft ladder should become a west-facing Vintage Story ladder.
28fn reverse_orientation(orientation: &str) -> &str {
29	match orientation {
30		"north" => "south",
31		"south" => "north",
32		"east" => "west",
33		_ => "east",
34	}
35}
36
37fn orientation_to_radians(facing: &str) -> f32 {
38	match facing {
39		"north" => 0.0,
40		"east" => std::f32::consts::PI * 3.0 / 2.0,
41		"south" => std::f32::consts::PI,
42		_ => std::f32::consts::FRAC_PI_2,
43	}
44}