minect/structure/
nbt.rs

1// Minect is library that allows a program to connect to a running Minecraft instance without
2// requiring any Minecraft mods.
3//
4// © Copyright (C) 2021-2023 Adrodoc <adrodoc55@googlemail.com> & skess42 <skagaros@gmail.com>
5//
6// This file is part of Minect.
7//
8// Minect is free software: you can redistribute it and/or modify it under the terms of the GNU
9// General Public License as published by the Free Software Foundation, either version 3 of the
10// License, or (at your option) any later version.
11//
12// Minect is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
13// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14// Public License for more details.
15//
16// You should have received a copy of the GNU General Public License along with Minect.
17// If not, see <http://www.gnu.org/licenses/>.
18
19use serde::{Deserialize, Serialize};
20use std::collections::BTreeMap;
21
22#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
23pub(crate) struct Structure {
24    #[serde(rename = "DataVersion")]
25    pub(crate) data_version: i32,
26    pub(crate) size: Vec<i32>,
27    // size: [i32; 3],
28    pub(crate) palette: Vec<PaletteBlock>,
29    pub(crate) blocks: Vec<StructureBlock>,
30    pub(crate) entities: Vec<StructureEntity>,
31}
32
33#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
34pub(crate) struct PaletteBlock {
35    #[serde(rename = "Name")]
36    pub(crate) name: String,
37    #[serde(rename = "Properties", default)]
38    pub(crate) properties: BTreeMap<String, String>,
39}
40
41#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
42pub(crate) struct StructureBlock {
43    pub(crate) state: i32,
44    // state: usize,
45    pub(crate) pos: Vec<i32>,
46    // pos: [i32; 3],
47    pub(crate) nbt: Option<nbt::Value>,
48}
49
50#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
51pub(crate) struct StructureEntity {
52    pub(crate) pos: Vec<f64>,
53    // pos: [f64; 3],
54    pub(crate) block_pos: Vec<i32>,
55    // block_pos: [i32; 3],
56    pub(crate) nbt: nbt::Value,
57}