Botcraft 1.21.4
Loading...
Searching...
No Matches
RecipeDataCraftingShaped.hpp
Go to the documentation of this file.
1#if PROTOCOL_VERSION > 347 /* > 1.12.2 */ && PROTOCOL_VERSION < 768 /* < 1.21.2 */
2#pragma once
3
8
9namespace ProtocolCraft
10{
11 class RecipeDataCraftingShaped : public RecipeData
12 {
13 private:
14 using THIS = RecipeDataCraftingShaped;
15 std::vector<Ingredient> ReadIngredients(ReadIterator& iter, size_t& length) const
16 {
17 std::vector<Ingredient> ingredients(GetWidth() * GetHeight());
18 for (size_t i = 0; i < ingredients.size(); ++i)
19 {
20 ingredients[i] = ReadData<Ingredient>(iter, length);
21 }
22 return ingredients;
23 }
24
25 void WriteIngredients(const std::vector<Ingredient>& ingredients, WriteContainer& container) const
26 {
27 // TODO: assert that ingredients.size() == GetWidth() * GetHeight()
28 for (int i = 0; i < ingredients.size(); ++i)
29 {
30 WriteData<Ingredient>(ingredients[i], container);
31 }
32 }
33
34#if PROTOCOL_VERSION < 765 /* < 1.20.3 */
35 SERIALIZED_FIELD(Width, VarInt);
36 SERIALIZED_FIELD(Height, VarInt);
37#endif
38 SERIALIZED_FIELD(Group, std::string);
39#if PROTOCOL_VERSION > 760 /* > 1.19.2*/
40 SERIALIZED_FIELD(CookingBookCategory, VarInt);
41#endif
42#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
43 SERIALIZED_FIELD(Width, VarInt);
44 SERIALIZED_FIELD(Height, VarInt);
45#endif
46 SERIALIZED_FIELD(Ingredients, Internal::CustomType<std::vector<Ingredient>, &THIS::ReadIngredients, &THIS::WriteIngredients>);
47 SERIALIZED_FIELD(Result, Slot);
48#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
49 SERIALIZED_FIELD(ShowNotification, bool);
50#endif
51
53 };
54}
55#endif
#define DECLARE_READ_WRITE_SERIALIZE
Define auto serializable utilities and declare ReadImpl, WriteImpl and SerializeImpl virtual function...
#define SERIALIZED_FIELD(Name,...)