From 3920ce90c7f2194f2d0844b0ffe0a7abed0f5fec Mon Sep 17 00:00:00 2001 From: Nathan Ruiz Date: Sun, 6 Nov 2022 22:01:47 +0000 Subject: [PATCH] Support pre-1.13 drops format --- src/models/block.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/models/block.rs b/src/models/block.rs index c0dc07b..9bdf8d6 100644 --- a/src/models/block.rs +++ b/src/models/block.rs @@ -13,7 +13,7 @@ pub struct Block { pub material: Option, pub harvest_tool: Option>, pub variations: Option>, - pub drops: Vec, + pub drops: Vec, pub transparent: bool, pub emit_light: u8, pub filter_light: u8, @@ -40,6 +40,25 @@ pub struct Variation { pub description: Option, } +#[derive(Deserialize, Debug, Clone)] +#[serde(untagged)] +pub enum DropId { + Id(u32), + IdWithMetadata { id: u32, metadata: u32 }, +} + +#[derive(Deserialize, Debug, Clone)] +#[serde(rename_all(deserialize = "camelCase", serialize = "snake_case"))] +#[serde(untagged)] +pub enum Drop { + Id(u32), + DropInfo { + drop: DropId, + min_count: Option, + max_count: Option, + } +} + #[derive(Deserialize, Debug, Clone)] // The fields in this part of the schema are not camelCase. #[serde(rename_all(serialize = "snake_case"))]