pub struct Schematic { /* private fields */ }
Expand description
A struct holding infomation about a schematic
Implementations§
Source§impl Schematic
impl Schematic
Sourcepub fn new(data_version: i32, size_x: u16, size_y: u16, size_z: u16) -> Self
pub fn new(data_version: i32, size_x: u16, size_y: u16, size_z: u16) -> Self
Initialize a new schematic filled with minecraft:air
Examples found in repository?
examples/test.rs (line 4)
3fn main() {
4 let mut schem = mcschem::Schematic::new(mcschem::data_version::MC_1_18_2, 1, 2, 1);
5
6 schem.set_block_entity(
7 0, 0, 0,
8 mcschem::Block::from_str("minecraft:barrel[facing=north,open=false]").unwrap(),
9 mcschem::BlockEntity::Barrel {
10 items: mcschem::utils::barrel_ss(3)
11 }
12 );
13
14 schem.set_block_entity(
15 0, 1, 0,
16 mcschem::Block::from_str("minecraft:oak_sign[rotation=8,waterlogged=false]").unwrap(),
17 mcschem::BlockEntity::SignPre1D20 {
18 glowing: true,
19 color: "lime".to_string(),
20 line_1: r#"["Line 1"]"#.to_string(),
21 line_2: r#"["Line 2"]"#.to_string(),
22 line_3: r#"["Line 3"]"#.to_string(),
23 line_4: r#"["Line 4"]"#.to_string()
24 }
25 );
26
27 let mut file = std::fs::File::create("schematic.schem").unwrap();
28 schem.export(&mut file).unwrap();
29}
Sourcepub fn set_block(&mut self, x: usize, y: usize, z: usize, block: Block)
pub fn set_block(&mut self, x: usize, y: usize, z: usize, block: Block)
Sets a block in the schematic
Sourcepub fn set_block_entity(
&mut self,
x: usize,
y: usize,
z: usize,
block: Block,
be: BlockEntity,
)
pub fn set_block_entity( &mut self, x: usize, y: usize, z: usize, block: Block, be: BlockEntity, )
Sets a block entity in the schematic
Examples found in repository?
examples/test.rs (lines 6-12)
3fn main() {
4 let mut schem = mcschem::Schematic::new(mcschem::data_version::MC_1_18_2, 1, 2, 1);
5
6 schem.set_block_entity(
7 0, 0, 0,
8 mcschem::Block::from_str("minecraft:barrel[facing=north,open=false]").unwrap(),
9 mcschem::BlockEntity::Barrel {
10 items: mcschem::utils::barrel_ss(3)
11 }
12 );
13
14 schem.set_block_entity(
15 0, 1, 0,
16 mcschem::Block::from_str("minecraft:oak_sign[rotation=8,waterlogged=false]").unwrap(),
17 mcschem::BlockEntity::SignPre1D20 {
18 glowing: true,
19 color: "lime".to_string(),
20 line_1: r#"["Line 1"]"#.to_string(),
21 line_2: r#"["Line 2"]"#.to_string(),
22 line_3: r#"["Line 3"]"#.to_string(),
23 line_4: r#"["Line 4"]"#.to_string()
24 }
25 );
26
27 let mut file = std::fs::File::create("schematic.schem").unwrap();
28 schem.export(&mut file).unwrap();
29}
Sourcepub fn export<W: Write>(&self, writer: &mut W) -> Result<(), NbtIoError>
pub fn export<W: Write>(&self, writer: &mut W) -> Result<(), NbtIoError>
Export the schematic to a writer
Examples found in repository?
examples/test.rs (line 28)
3fn main() {
4 let mut schem = mcschem::Schematic::new(mcschem::data_version::MC_1_18_2, 1, 2, 1);
5
6 schem.set_block_entity(
7 0, 0, 0,
8 mcschem::Block::from_str("minecraft:barrel[facing=north,open=false]").unwrap(),
9 mcschem::BlockEntity::Barrel {
10 items: mcschem::utils::barrel_ss(3)
11 }
12 );
13
14 schem.set_block_entity(
15 0, 1, 0,
16 mcschem::Block::from_str("minecraft:oak_sign[rotation=8,waterlogged=false]").unwrap(),
17 mcschem::BlockEntity::SignPre1D20 {
18 glowing: true,
19 color: "lime".to_string(),
20 line_1: r#"["Line 1"]"#.to_string(),
21 line_2: r#"["Line 2"]"#.to_string(),
22 line_3: r#"["Line 3"]"#.to_string(),
23 line_4: r#"["Line 4"]"#.to_string()
24 }
25 );
26
27 let mut file = std::fs::File::create("schematic.schem").unwrap();
28 schem.export(&mut file).unwrap();
29}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Schematic
impl RefUnwindSafe for Schematic
impl Send for Schematic
impl Sync for Schematic
impl Unpin for Schematic
impl UnwindSafe for Schematic
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more