Struct Schematic

Source
pub struct Schematic { /* private fields */ }
Expand description

A struct holding infomation about a schematic

Implementations§

Source§

impl Schematic

Source

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}
Source

pub fn set_block(&mut self, x: usize, y: usize, z: usize, block: Block)

Sets a block in the schematic

Source

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}
Source

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§

Source§

impl Clone for Schematic

Source§

fn clone(&self) -> Schematic

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Schematic

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.