azalea_protocol/packets/game/
clientbound_recipe_book_add_packet.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
use azalea_buf::McBuf;
use azalea_protocol_macros::ClientboundGamePacket;

use super::clientbound_update_recipes_packet::{Ingredient, SlotDisplayData};

#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundRecipeBookAddPacket {
    pub entries: Vec<Entry>,
    pub replace: bool,
}

#[derive(Clone, Debug, McBuf)]
pub struct Entry {
    pub contents: RecipeDisplayEntry,
    pub flags: u8,
}

#[derive(Clone, Debug, McBuf)]
pub struct RecipeDisplayEntry {
    #[var]
    pub id: u32,
    pub display: RecipeDisplayData,
    // ByteBufCodecs.OPTIONAL_VAR_INT
    #[var]
    pub group: u32,
    pub category: azalea_registry::RecipeBookCategory,
    pub crafting_requirements: Option<Vec<Ingredient>>,
}

/// [`azalea_registry::RecipeDisplay`]
#[derive(Clone, Debug, McBuf)]
pub enum RecipeDisplayData {
    Shapeless(ShapelessCraftingRecipeDisplay),
    Shaped(ShapedCraftingRecipeDisplay),
    Furnace(FurnaceRecipeDisplay),
    Stonecutter(StonecutterRecipeDisplay),
    Smithing(SmithingRecipeDisplay),
}

#[derive(Clone, Debug, McBuf)]
pub struct ShapelessCraftingRecipeDisplay {
    pub ingredients: Vec<SlotDisplayData>,
    pub result: SlotDisplayData,
    pub crafting_station: SlotDisplayData,
}
#[derive(Clone, Debug, McBuf)]
pub struct ShapedCraftingRecipeDisplay {
    #[var]
    pub width: u32,
    #[var]
    pub height: u32,
    pub ingredients: Vec<SlotDisplayData>,
    pub result: SlotDisplayData,
    pub crafting_station: SlotDisplayData,
}
#[derive(Clone, Debug, McBuf)]
pub struct FurnaceRecipeDisplay {
    pub ingredient: SlotDisplayData,
    pub fuel: SlotDisplayData,
    pub result: SlotDisplayData,
    pub crafting_station: SlotDisplayData,
    #[var]
    pub duration: u32,
    pub experience: f32,
}
#[derive(Clone, Debug, McBuf)]
pub struct StonecutterRecipeDisplay {
    pub input: SlotDisplayData,
    pub result: SlotDisplayData,
    pub crafting_station: SlotDisplayData,
}
#[derive(Clone, Debug, McBuf)]
pub struct SmithingRecipeDisplay {
    pub template: SlotDisplayData,
    pub base: SlotDisplayData,
    pub addition: SlotDisplayData,
    pub result: SlotDisplayData,
    pub crafting_station: SlotDisplayData,
}