Imported serde::Deserialize to avoid spelling it out frequently.
This commit is contained in:
parent
a0260acd8b
commit
03fcdc2e32
@ -1,26 +1,27 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
use serde::Deserialize;
|
||||||
|
|
||||||
use crate::level::WorldError;
|
use crate::level::WorldError;
|
||||||
|
|
||||||
const BLOCKS_JSON: &str = include_str!("../../assets/blocks.json");
|
const BLOCKS_JSON: &str = include_str!("../../assets/blocks.json");
|
||||||
|
|
||||||
#[derive(serde::Deserialize, Debug, Clone, PartialEq, Eq)]
|
#[derive(Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct BlockDefinition {
|
pub struct BlockDefinition {
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
kind: String,
|
kind: String,
|
||||||
block_set_type: Option<String>,
|
block_set_type: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(serde::Deserialize, Debug, Clone, PartialEq, Eq)]
|
#[derive(Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct BlockState {
|
pub struct BlockState {
|
||||||
default: Option<bool>,
|
default: Option<bool>,
|
||||||
id: i64,
|
id: i64,
|
||||||
properties: Option<HashMap<String, String>>,
|
properties: Option<HashMap<String, String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(serde::Deserialize, Debug, Clone, PartialEq, Eq)]
|
#[derive(Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct BlocksElement {
|
pub struct BlocksElement {
|
||||||
definition: BlockDefinition,
|
definition: BlockDefinition,
|
||||||
properties: Option<HashMap<String, Vec<String>>>,
|
properties: Option<HashMap<String, Vec<String>>>,
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use fastnbt::LongArray;
|
use fastnbt::LongArray;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
coordinates::{ChunkCoordinates, ChunkRelativeBlockCoordinates},
|
coordinates::{ChunkCoordinates, ChunkRelativeBlockCoordinates},
|
||||||
@ -14,27 +15,27 @@ pub struct ChunkData {
|
|||||||
pub heightmaps: ChunkHeightmaps,
|
pub heightmaps: ChunkHeightmaps,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(serde::Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
#[serde(rename_all = "PascalCase")]
|
#[serde(rename_all = "PascalCase")]
|
||||||
struct PaletteEntry {
|
struct PaletteEntry {
|
||||||
name: String,
|
name: String,
|
||||||
properties: Option<HashMap<String, String>>,
|
properties: Option<HashMap<String, String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(serde::Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
struct ChunkSectionBlockStates {
|
struct ChunkSectionBlockStates {
|
||||||
data: Option<LongArray>,
|
data: Option<LongArray>,
|
||||||
palette: Vec<PaletteEntry>,
|
palette: Vec<PaletteEntry>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(serde::Deserialize, serde::Serialize, Debug, Clone)]
|
#[derive(Deserialize, Serialize, Debug, Clone)]
|
||||||
#[serde(rename_all = "UPPERCASE")]
|
#[serde(rename_all = "UPPERCASE")]
|
||||||
pub struct ChunkHeightmaps {
|
pub struct ChunkHeightmaps {
|
||||||
motion_blocking: LongArray,
|
motion_blocking: LongArray,
|
||||||
world_surface: LongArray,
|
world_surface: LongArray,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(serde::Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
struct ChunkSection {
|
struct ChunkSection {
|
||||||
#[serde(rename = "Y")]
|
#[serde(rename = "Y")]
|
||||||
@ -42,7 +43,7 @@ struct ChunkSection {
|
|||||||
block_states: Option<ChunkSectionBlockStates>,
|
block_states: Option<ChunkSectionBlockStates>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(serde::Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
struct ChunkNbt {
|
struct ChunkNbt {
|
||||||
#[serde(rename = "DataVersion")]
|
#[serde(rename = "DataVersion")]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user